agent-alibi 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. agent_alibi-0.1.0/PKG-INFO +162 -0
  2. agent_alibi-0.1.0/README.md +145 -0
  3. agent_alibi-0.1.0/pyproject.toml +54 -0
  4. agent_alibi-0.1.0/pyproject.toml.orig +50 -0
  5. agent_alibi-0.1.0/src/alibi/__init__.py +1 -0
  6. agent_alibi-0.1.0/src/alibi/backward.py +496 -0
  7. agent_alibi-0.1.0/src/alibi/chunking.py +115 -0
  8. agent_alibi-0.1.0/src/alibi/cli.py +391 -0
  9. agent_alibi-0.1.0/src/alibi/config.py +69 -0
  10. agent_alibi-0.1.0/src/alibi/drift.py +58 -0
  11. agent_alibi-0.1.0/src/alibi/evaluate.py +336 -0
  12. agent_alibi-0.1.0/src/alibi/forward.py +190 -0
  13. agent_alibi-0.1.0/src/alibi/judges/__init__.py +66 -0
  14. agent_alibi-0.1.0/src/alibi/judges/base.py +23 -0
  15. agent_alibi-0.1.0/src/alibi/judges/openrouter.py +81 -0
  16. agent_alibi-0.1.0/src/alibi/judges/typesafe.py +94 -0
  17. agent_alibi-0.1.0/src/alibi/localize.py +138 -0
  18. agent_alibi-0.1.0/src/alibi/mcp_server.py +41 -0
  19. agent_alibi-0.1.0/src/alibi/routing.py +51 -0
  20. agent_alibi-0.1.0/src/alibi/sources/__init__.py +3 -0
  21. agent_alibi-0.1.0/src/alibi/sources/agentracer.py +70 -0
  22. agent_alibi-0.1.0/src/alibi/sources/agentrx.py +77 -0
  23. agent_alibi-0.1.0/src/alibi/sources/auto.py +30 -0
  24. agent_alibi-0.1.0/src/alibi/sources/base.py +11 -0
  25. agent_alibi-0.1.0/src/alibi/sources/claudecode.py +51 -0
  26. agent_alibi-0.1.0/src/alibi/sources/jsonfile.py +36 -0
  27. agent_alibi-0.1.0/src/alibi/sources/langsmith.py +40 -0
  28. agent_alibi-0.1.0/src/alibi/sources/longrca.py +75 -0
  29. agent_alibi-0.1.0/src/alibi/sources/trajerrbench.py +69 -0
  30. agent_alibi-0.1.0/src/alibi/types.py +57 -0
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-alibi
3
+ Version: 0.1.0
4
+ Summary: We check whether your agent has an alibi for what it did.
5
+ License-Expression: MIT
6
+ Requires-Dist: langchain-typesafe>=0.0.1a2
7
+ Requires-Dist: langsmith>=0.12.6
8
+ Requires-Dist: mcp>=2.2,<3
9
+ Requires-Dist: numpy>=2.5.3
10
+ Requires-Dist: openai>=3.16.0
11
+ Requires-Dist: pyarrow>=25.0.1
12
+ Requires-Dist: pydantic>=2
13
+ Requires-Dist: python-dotenv>=1.2.3
14
+ Requires-Python: >=3.12
15
+ Project-URL: Homepage, https://github.com/ahmedezz26/alibi
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Alibi
19
+
20
+ [![CI](https://github.com/ahmedezz26/alibi/actions/workflows/ci.yml/badge.svg)](https://github.com/ahmedezz26/alibi/actions/workflows/ci.yml)
21
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
22
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
23
+
24
+ **We check whether your agent has an alibi for what it did.**
25
+
26
+ Alibi finds where a long AI-agent run went wrong. It borrows the playbook of automotive
27
+ driver-assistance systems: treat the run as a time series, filter it forward, detect the
28
+ fault, then smooth backward to the moment it began. The only sensor is Jev, TypeSafe AI's
29
+ System One model, which answers with calibrated probabilities instead of text.
30
+
31
+ It is built for long traces, where reading everything at once breaks down: on real coding
32
+ failures of 59K to 120K tokens, a single whole-trace read found the root-cause step in 0%
33
+ of cases; Alibi found it in 16% and 7.8%, and points to the right neighbourhood (within
34
+ 3 steps) in 21% and 17%.
35
+
36
+ ## How it works
37
+
38
+ ```mermaid
39
+ flowchart LR
40
+ A[Trace] --> B[10K-token chapters]
41
+ B --> C[Forward filter:<br/>Jev rates each chapter]
42
+ C -->|memory card| C
43
+ C --> D[CUSUM alarm<br/>on health]
44
+ D --> E[Look back from the alarm:<br/>chapter + per-step evidence]
45
+ E --> F[Top 3 steps to read,<br/>earliest strong suspect first]
46
+ ```
47
+
48
+ | Stage | What happens | Driver-assistance analogue |
49
+ |---|---|---|
50
+ | Chapters | 10K-token windows with overlap, read one at a time | Measurement frames |
51
+ | Forward filter | Jev rates health and 4 warning signs per chapter; a memory card of numbers carries state forward | Recursive filter (predict + update) |
52
+ | CUSUM | Accumulates health drift; the first alarm marks the failure chapter | Fault detection |
53
+ | Look-back | Re-reads the alarm chapter and every earlier one in parallel, with hindsight | Fixed-interval (RTS-style) smoothing |
54
+ | Pick | P(chapter) x evidence per step; the earliest step within 80% of the top score | Fault-onset estimation |
55
+
56
+ ## What you get
57
+
58
+ A short trace is refused, without spending a call:
59
+
60
+ $ alibi diagnose examples/sample_trace.json
61
+ Trace is 219 tokens, under the 50,000-token threshold: a single direct read is
62
+ enough; Alibi adds value on long traces.
63
+
64
+ A long one comes back as three steps to read, in order. This is a real run from the
65
+ locked TrajErrBench set (a Claude Opus coding agent failing on a qutebrowser issue),
66
+ replayed from its recorded result:
67
+
68
+ $ alibi diagnose trace.json
69
+ Read these 3 steps first, in order.
70
+ 80,778 tokens, 10 chapters, alarm at chapter 6; 17 Jev calls, 35 s, $0.0096
71
+ 1. step 74 (assistant), chapter 6, score 0.277
72
+ 'Now I see the full picture. The test on line 458 expects
73
+ `str(proc.outcome) == 'Testprocess crashed.'` for SIGSEGV...'
74
+ 2. step 76 (assistant), chapter 6, score 0.202
75
+ '## Phase 5: FIX ANALYSIS\n\nNow I have a clear understanding. Let me
76
+ implement the changes to `guiprocess.py`...'
77
+ 3. step 78 (assistant), chapter 6, score 0.178
78
+ 'Now let me implement all the changes:\nTool calls:\nstr_replace_editor(...'
79
+
80
+ Step 74 is the labelled root cause: the agent reads the test wrong and every later
81
+ edit builds on that reading. Being right at rank 1 happens on 16% of these traces;
82
+ the honest claim is that three steps out of 118 is a much smaller haystack.
83
+
84
+ ## Results
85
+
86
+ Locked test sets, each run once against a pass bar written down beforehand:
87
+
88
+ | Test set | Traces | Median length | Alibi exact step | Alibi within 3 steps | Whole-trace read, exact |
89
+ |---|---|---|---|---|---|
90
+ | TrajErrBench SWE-Bench Pro (real coding failures) | 56 | 59K tokens | 16% | 21% | 0% (p = 0.004) |
91
+ | LongRCA SWE-bench Pro (real coding failures) | 90 | 120K tokens | 7.8% | 16.7% | 0% (p = 0.016) |
92
+ | LongRCA WebArena (real web-task failures) | 48 | 38K tokens | 12.5% | 20.8% | 16.9% published (no clear difference) |
93
+
94
+ Against published methods on the LongRCA leaderboard (all on DeepSeek-V4-Flash; exact
95
+ root step, same 128 SWE-bench Pro failures):
96
+
97
+ | Method | Exact root step |
98
+ |---|---|
99
+ | RCTA | 38.3% |
100
+ | **Alibi (Jev)** | **10.2%** |
101
+ | ECHO | 7.8% |
102
+ | FALAT | 2.3% |
103
+ | All-at-once (whole trace) | 1.6% |
104
+ | Step-by-step | 0.8% |
105
+ | Binary search | 0.8% |
106
+
107
+ Alibi ties ECHO (Fisher p = 0.66) and trails RCTA (p < 0.000001), which traces each
108
+ suspect back to the handoff instruction between agents.
109
+
110
+ ## When to use it, and when not to
111
+
112
+ - Use it for traces of tens of thousands of tokens or more (default gate: 50K tokens).
113
+ - Do not use it for short traces: a single direct read by any capable model is enough,
114
+ and Alibi says so without spending a call.
115
+ - Treat the output as "read these 3 steps first", not as a verdict.
116
+
117
+ ## Speed and cost
118
+
119
+ - Each chapter is one Jev call, and chapters are judged in parallel on the way back. A
120
+ 38K-token trace is 4.6 chapters and 15 seconds of judge time; a 120K-token trace is
121
+ 17 chapters and about 48 seconds. No reasoning tokens are generated.
122
+ - Cost scales with trace length: about $0.10 per million trace tokens at Jev's price of
123
+ $0.042 per million input tokens (roughly $0.01 for a 100K-token trace).
124
+
125
+ ## Install
126
+
127
+ Claude Code:
128
+
129
+ /plugin marketplace add ahmedezz26/alibi
130
+ /plugin install alibi@alibi
131
+
132
+ Set `TYPESAFE_API_KEY` in your environment. Then ask Claude Code: "Why did my last
133
+ session go wrong?"
134
+
135
+ Command line:
136
+
137
+ uv tool install git+https://github.com/ahmedezz26/alibi
138
+ ALIBI_JUDGE_BACKEND=typesafe ALIBI_ALLOW_PAID_MODELS=1 TYPESAFE_API_KEY=... \
139
+ alibi diagnose path/to/trace.json
140
+
141
+ ## Privacy
142
+
143
+ Traces above the length gate are sent to TypeSafe's API; below it, nothing leaves your
144
+ machine. There is no telemetry. Claude Code session parsing is best effort: the transcript
145
+ format is internal to Claude Code and may change. Session transcripts often contain source
146
+ code and secrets, so read [SECURITY.md](SECURITY.md) before diagnosing one.
147
+
148
+ ## Contributing
149
+
150
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Plumbing, adapters, bug fixes and docs are welcome as
151
+ ordinary pull requests; changes to the estimation method need a pre-registered measurement,
152
+ for the reason the research log makes obvious.
153
+
154
+ ## Background
155
+
156
+ Alibi started as an experiment by an ADAS engineer: can the tracking filters used in cars
157
+ work on AI-agent traces? The research log with every pre-registered test, including the
158
+ ones that failed, is in [docs/research-log.md](docs/research-log.md).
159
+
160
+ ## License
161
+
162
+ MIT
@@ -0,0 +1,145 @@
1
+ # Alibi
2
+
3
+ [![CI](https://github.com/ahmedezz26/alibi/actions/workflows/ci.yml/badge.svg)](https://github.com/ahmedezz26/alibi/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
6
+
7
+ **We check whether your agent has an alibi for what it did.**
8
+
9
+ Alibi finds where a long AI-agent run went wrong. It borrows the playbook of automotive
10
+ driver-assistance systems: treat the run as a time series, filter it forward, detect the
11
+ fault, then smooth backward to the moment it began. The only sensor is Jev, TypeSafe AI's
12
+ System One model, which answers with calibrated probabilities instead of text.
13
+
14
+ It is built for long traces, where reading everything at once breaks down: on real coding
15
+ failures of 59K to 120K tokens, a single whole-trace read found the root-cause step in 0%
16
+ of cases; Alibi found it in 16% and 7.8%, and points to the right neighbourhood (within
17
+ 3 steps) in 21% and 17%.
18
+
19
+ ## How it works
20
+
21
+ ```mermaid
22
+ flowchart LR
23
+ A[Trace] --> B[10K-token chapters]
24
+ B --> C[Forward filter:<br/>Jev rates each chapter]
25
+ C -->|memory card| C
26
+ C --> D[CUSUM alarm<br/>on health]
27
+ D --> E[Look back from the alarm:<br/>chapter + per-step evidence]
28
+ E --> F[Top 3 steps to read,<br/>earliest strong suspect first]
29
+ ```
30
+
31
+ | Stage | What happens | Driver-assistance analogue |
32
+ |---|---|---|
33
+ | Chapters | 10K-token windows with overlap, read one at a time | Measurement frames |
34
+ | Forward filter | Jev rates health and 4 warning signs per chapter; a memory card of numbers carries state forward | Recursive filter (predict + update) |
35
+ | CUSUM | Accumulates health drift; the first alarm marks the failure chapter | Fault detection |
36
+ | Look-back | Re-reads the alarm chapter and every earlier one in parallel, with hindsight | Fixed-interval (RTS-style) smoothing |
37
+ | Pick | P(chapter) x evidence per step; the earliest step within 80% of the top score | Fault-onset estimation |
38
+
39
+ ## What you get
40
+
41
+ A short trace is refused, without spending a call:
42
+
43
+ $ alibi diagnose examples/sample_trace.json
44
+ Trace is 219 tokens, under the 50,000-token threshold: a single direct read is
45
+ enough; Alibi adds value on long traces.
46
+
47
+ A long one comes back as three steps to read, in order. This is a real run from the
48
+ locked TrajErrBench set (a Claude Opus coding agent failing on a qutebrowser issue),
49
+ replayed from its recorded result:
50
+
51
+ $ alibi diagnose trace.json
52
+ Read these 3 steps first, in order.
53
+ 80,778 tokens, 10 chapters, alarm at chapter 6; 17 Jev calls, 35 s, $0.0096
54
+ 1. step 74 (assistant), chapter 6, score 0.277
55
+ 'Now I see the full picture. The test on line 458 expects
56
+ `str(proc.outcome) == 'Testprocess crashed.'` for SIGSEGV...'
57
+ 2. step 76 (assistant), chapter 6, score 0.202
58
+ '## Phase 5: FIX ANALYSIS\n\nNow I have a clear understanding. Let me
59
+ implement the changes to `guiprocess.py`...'
60
+ 3. step 78 (assistant), chapter 6, score 0.178
61
+ 'Now let me implement all the changes:\nTool calls:\nstr_replace_editor(...'
62
+
63
+ Step 74 is the labelled root cause: the agent reads the test wrong and every later
64
+ edit builds on that reading. Being right at rank 1 happens on 16% of these traces;
65
+ the honest claim is that three steps out of 118 is a much smaller haystack.
66
+
67
+ ## Results
68
+
69
+ Locked test sets, each run once against a pass bar written down beforehand:
70
+
71
+ | Test set | Traces | Median length | Alibi exact step | Alibi within 3 steps | Whole-trace read, exact |
72
+ |---|---|---|---|---|---|
73
+ | TrajErrBench SWE-Bench Pro (real coding failures) | 56 | 59K tokens | 16% | 21% | 0% (p = 0.004) |
74
+ | LongRCA SWE-bench Pro (real coding failures) | 90 | 120K tokens | 7.8% | 16.7% | 0% (p = 0.016) |
75
+ | LongRCA WebArena (real web-task failures) | 48 | 38K tokens | 12.5% | 20.8% | 16.9% published (no clear difference) |
76
+
77
+ Against published methods on the LongRCA leaderboard (all on DeepSeek-V4-Flash; exact
78
+ root step, same 128 SWE-bench Pro failures):
79
+
80
+ | Method | Exact root step |
81
+ |---|---|
82
+ | RCTA | 38.3% |
83
+ | **Alibi (Jev)** | **10.2%** |
84
+ | ECHO | 7.8% |
85
+ | FALAT | 2.3% |
86
+ | All-at-once (whole trace) | 1.6% |
87
+ | Step-by-step | 0.8% |
88
+ | Binary search | 0.8% |
89
+
90
+ Alibi ties ECHO (Fisher p = 0.66) and trails RCTA (p < 0.000001), which traces each
91
+ suspect back to the handoff instruction between agents.
92
+
93
+ ## When to use it, and when not to
94
+
95
+ - Use it for traces of tens of thousands of tokens or more (default gate: 50K tokens).
96
+ - Do not use it for short traces: a single direct read by any capable model is enough,
97
+ and Alibi says so without spending a call.
98
+ - Treat the output as "read these 3 steps first", not as a verdict.
99
+
100
+ ## Speed and cost
101
+
102
+ - Each chapter is one Jev call, and chapters are judged in parallel on the way back. A
103
+ 38K-token trace is 4.6 chapters and 15 seconds of judge time; a 120K-token trace is
104
+ 17 chapters and about 48 seconds. No reasoning tokens are generated.
105
+ - Cost scales with trace length: about $0.10 per million trace tokens at Jev's price of
106
+ $0.042 per million input tokens (roughly $0.01 for a 100K-token trace).
107
+
108
+ ## Install
109
+
110
+ Claude Code:
111
+
112
+ /plugin marketplace add ahmedezz26/alibi
113
+ /plugin install alibi@alibi
114
+
115
+ Set `TYPESAFE_API_KEY` in your environment. Then ask Claude Code: "Why did my last
116
+ session go wrong?"
117
+
118
+ Command line:
119
+
120
+ uv tool install git+https://github.com/ahmedezz26/alibi
121
+ ALIBI_JUDGE_BACKEND=typesafe ALIBI_ALLOW_PAID_MODELS=1 TYPESAFE_API_KEY=... \
122
+ alibi diagnose path/to/trace.json
123
+
124
+ ## Privacy
125
+
126
+ Traces above the length gate are sent to TypeSafe's API; below it, nothing leaves your
127
+ machine. There is no telemetry. Claude Code session parsing is best effort: the transcript
128
+ format is internal to Claude Code and may change. Session transcripts often contain source
129
+ code and secrets, so read [SECURITY.md](SECURITY.md) before diagnosing one.
130
+
131
+ ## Contributing
132
+
133
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Plumbing, adapters, bug fixes and docs are welcome as
134
+ ordinary pull requests; changes to the estimation method need a pre-registered measurement,
135
+ for the reason the research log makes obvious.
136
+
137
+ ## Background
138
+
139
+ Alibi started as an experiment by an ADAS engineer: can the tracking filters used in cars
140
+ work on AI-agent traces? The research log with every pre-registered test, including the
141
+ ones that failed, is in [docs/research-log.md](docs/research-log.md).
142
+
143
+ ## License
144
+
145
+ MIT
@@ -0,0 +1,54 @@
1
+ [project]
2
+ name = "agent-alibi"
3
+ version = "0.1.0"
4
+ description = "We check whether your agent has an alibi for what it did."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.12"
8
+ dependencies = [
9
+ "langchain-typesafe>=0.0.1a2",
10
+ "langsmith>=0.12.6",
11
+ "mcp>=2.2,<3",
12
+ "numpy>=2.5.3",
13
+ "openai>=3.16.0",
14
+ "pyarrow>=25.0.1",
15
+ "pydantic>=2",
16
+ "python-dotenv>=1.2.3",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://github.com/ahmedezz26/alibi"
21
+
22
+ [project.scripts]
23
+ alibi = "alibi.cli:main"
24
+ alibi-mcp = "alibi.mcp_server:main"
25
+
26
+ [build-system]
27
+ requires = ["uv_build>=0.12.5,<0.13.0"]
28
+ build-backend = "uv_build"
29
+
30
+ [tool.uv.build-backend]
31
+ module-name = "alibi"
32
+
33
+ [tool.pytest.ini_options]
34
+ testpaths = ["tests"]
35
+
36
+ [tool.ruff]
37
+ line-length = 100
38
+ extend-exclude = ["docs"]
39
+
40
+ [tool.ruff.lint]
41
+ select = [
42
+ "E",
43
+ "F",
44
+ "I",
45
+ "UP",
46
+ "B",
47
+ ]
48
+
49
+ [dependency-groups]
50
+ dev = [
51
+ "anyio>=4.15.1",
52
+ "pytest>=9.1.1",
53
+ "ruff>=0.16.8",
54
+ ]
@@ -0,0 +1,50 @@
1
+ [project]
2
+ name = "agent-alibi"
3
+ version = "0.1.0"
4
+ description = "We check whether your agent has an alibi for what it did."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.12"
8
+ dependencies = [
9
+ "langchain-typesafe>=0.0.1a2",
10
+ "langsmith>=0.12.6",
11
+ "mcp>=2.2,<3",
12
+ "numpy>=2.5.3",
13
+ "openai>=3.16.0",
14
+ "pyarrow>=25.0.1",
15
+ "pydantic>=2",
16
+ "python-dotenv>=1.2.3",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://github.com/ahmedezz26/alibi"
21
+
22
+ [build-system]
23
+ requires = ["uv_build>=0.12.5,<0.13.0"]
24
+ build-backend = "uv_build"
25
+
26
+ # The distribution is "agent-alibi" on PyPI ("alibi" is taken); the import package stays "alibi".
27
+ [tool.uv.build-backend]
28
+ module-name = "alibi"
29
+
30
+ [dependency-groups]
31
+ dev = [
32
+ "anyio>=4.15.1",
33
+ "pytest>=9.1.1",
34
+ "ruff>=0.16.8",
35
+ ]
36
+
37
+ [tool.pytest.ini_options]
38
+ testpaths = ["tests"]
39
+
40
+ [tool.ruff]
41
+ line-length = 100
42
+ # `ruff format` rewrites python code blocks inside markdown, which mangles the docs.
43
+ extend-exclude = ["docs"]
44
+
45
+ [tool.ruff.lint]
46
+ select = ["E", "F", "I", "UP", "B"]
47
+
48
+ [project.scripts]
49
+ alibi = "alibi.cli:main"
50
+ alibi-mcp = "alibi.mcp_server:main"
@@ -0,0 +1 @@
1
+ """Alibi: agent-trace triage via state estimation over windowed judge calls."""