agent-alibi 0.1.0__py3-none-any.whl

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.
@@ -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,30 @@
1
+ alibi/__init__.py,sha256=106VQ9QhFYONJcypz1Q-u9gGGsQL4FP06mi0_1E4K2w,80
2
+ alibi/backward.py,sha256=-9Zxav59z5WkS5D__qLnDmhkj7QDKKkv3TLgP0tFSLY,20217
3
+ alibi/chunking.py,sha256=TZOtcmST3MbA-YDHFo_x82pUJ9MF_-GjMa_dNbpiVHQ,4426
4
+ alibi/cli.py,sha256=TPxw44R69XUkQaVUD4GCtJ2mQyqLMqXeMuQ-1q0OOOY,15828
5
+ alibi/config.py,sha256=unF7Q6zqZo6AP-hEJE8HPZH6X59wQYHVIKeGYdECNro,3500
6
+ alibi/drift.py,sha256=9VKW_tAfDUN8Z_44Rc8zrHxoJlczHrorgOcCmxrBz0M,1940
7
+ alibi/evaluate.py,sha256=ZCsbH1wuszSiaD3JXjTTN0J-lJHj21lGW5ExT-sQCaA,12893
8
+ alibi/forward.py,sha256=MSeB44M0hvN6Hn5rQGsLK3V_re2JISXyltnrmSLkFc0,6654
9
+ alibi/judges/__init__.py,sha256=esY3Zy9UKV4kOxvwsslPR96v52gSyh1PlXjtBZ2-TRc,2365
10
+ alibi/judges/base.py,sha256=4OOcvFBHsWYyWe-aO0k8xYP6a9FBwxUFTrewh6mCirc,588
11
+ alibi/judges/openrouter.py,sha256=mM0Gro7ZCM5m0wxnw5Xxa2iT0ym3WDjpnNp9-q34KdA,2916
12
+ alibi/judges/typesafe.py,sha256=fLleDwjj4vMfRSQeUcBPNzshE3tsFFqIPqzTIWSrKkE,3510
13
+ alibi/localize.py,sha256=fQ5PkALVGhTL0OTWDAe1xtIBaq-lbWzC8_yKdoscfdY,4851
14
+ alibi/mcp_server.py,sha256=nJGbiTUZeRDmAPF_VLuC9nnb9dOjqBxs49UQpcLc6gE,1563
15
+ alibi/routing.py,sha256=UgevgRxCT6ASnWIlWOkETpN47rPb8bpK9oPsuJAjscM,1963
16
+ alibi/sources/__init__.py,sha256=7r-4QCNMrd-1Cd-rcOimGybjZ7iTa2L_LXzLFnZTNDA,70
17
+ alibi/sources/agentracer.py,sha256=PR8Xl1IymsO8ToowFhBMwcpRnQB_tq1Lvw1kq3UWiB8,2404
18
+ alibi/sources/agentrx.py,sha256=dp5BmeFG74uGMQ0f8XEwvEv6P5Jmcng0tzM2htMisFQ,2716
19
+ alibi/sources/auto.py,sha256=4wuVmyGkaNurxEKa2WNPfERh4x_GkezgwkGy5TFfdMQ,1080
20
+ alibi/sources/base.py,sha256=qOkCtOOauIMR7rR0VyLZ295S04ToQYgigedrWd8WU1Q,265
21
+ alibi/sources/claudecode.py,sha256=ch_pRwpDI9W19TetJUrn96iB2ok90wdlprXzWO57OQ4,1817
22
+ alibi/sources/jsonfile.py,sha256=yxEz1-d3ohElppOEfh3Q2SnyMi_se0I39n5tr-Bt088,1131
23
+ alibi/sources/langsmith.py,sha256=bZyKrN5a7qRjwXbuBp8zG_tmJF2p-3en2f9NeQUbu6w,1333
24
+ alibi/sources/longrca.py,sha256=g1kFv-OlJYgUYN7BjU4SNCGhrcuA2B6Nmmu5op3tbkk,2635
25
+ alibi/sources/trajerrbench.py,sha256=RTHRsM86kU0pjrKikU1qNzG_A0_kzivnDF0pVRqtqps,2358
26
+ alibi/types.py,sha256=vhSt0GEeAmGjXmAxs1h7J3qMOhH2KmD4_noNfHbBCcw,1599
27
+ agent_alibi-0.1.0.dist-info/WHEEL,sha256=R1d3uUTbmXM1FHXH_itQashbrqrOSVj-hvBCpmkIIGE,81
28
+ agent_alibi-0.1.0.dist-info/entry_points.txt,sha256=YKWFOthViAh9z8XRpHrDbfAkJLVkagDWAs3iHQdqD0o,76
29
+ agent_alibi-0.1.0.dist-info/METADATA,sha256=zEHVBTRGBytqbuRVw7j4YH80Rb6Cwk8w675f8vD62Ls,6952
30
+ agent_alibi-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.12.17
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ alibi = alibi.cli:main
3
+ alibi-mcp = alibi.mcp_server:main
4
+
alibi/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Alibi: agent-trace triage via state estimation over windowed judge calls."""