whatbroke-cli 0.2.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arthi Arumugam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ <div align="center">
2
+
3
+ # whatbroke
4
+
5
+ **Diff your AI agent's behavior between two runs.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/whatbroke-cli)](https://www.npmjs.com/package/whatbroke-cli) [![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
8
+
9
+ [English](README.md) · [简体中文](readme/README.zh-CN.md) · [日本語](readme/README.ja.md) · [한국어](readme/README.ko.md) · [Español](readme/README.es.md) · [Português](readme/README.pt-BR.md) · [Français](readme/README.fr.md) · [Deutsch](readme/README.de.md) · [Русский](readme/README.ru.md) · [हिन्दी](readme/README.hi.md)
10
+
11
+ </div>
12
+
13
+ Swap a model, tweak a prompt, bump a framework version, then run `whatbroke` and see exactly what changed: which tool calls disappeared, which arguments drifted, where cost and latency moved, and which outputs flipped.
14
+
15
+ Text diffs can't see this. Your agent can say "your subscription is cancelled" while silently skipping the `cancel_subscription` call. The words look fine. The behavior broke.
16
+
17
+ ![whatbroke diff output showing a dropped tool call and changed refund amount after a model swap](.github/demo.svg)
18
+
19
+ That's a real failure mode from swapping to a cheaper model. The agent got 75% cheaper, kept passing the vibe check, and stopped actually cancelling subscriptions. It also started refunding $425 instead of $42.50.
20
+
21
+ ## Install
22
+
23
+ ```
24
+ npm install -g whatbroke-cli
25
+ ```
26
+
27
+ Or run it directly:
28
+
29
+ ```
30
+ npx whatbroke-cli diff before.jsonl after.jsonl
31
+ ```
32
+
33
+ Try it right now with the bundled example traces:
34
+
35
+ ```
36
+ git clone https://github.com/arthi-arumugam-git/whatbroke
37
+ cd whatbroke && npm install && npm run build
38
+ node dist/cli.js diff examples/support-agent-gpt4o.jsonl examples/support-agent-gpt5mini.jsonl
39
+ ```
40
+
41
+ ## How it works
42
+
43
+ 1. Record a trace of your agent doing its job (a plain JSONL file, one event per line).
44
+ 2. Change something. Model, prompt, framework version, tool descriptions, anything.
45
+ 3. Record a trace of the new version doing the same job.
46
+ 4. `whatbroke diff old.jsonl new.jsonl`
47
+
48
+ whatbroke aligns runs by id, aligns tool calls within each run, and reports:
49
+
50
+ | Finding | Severity |
51
+ |---|---|
52
+ | Run started failing, tool call dropped, tool now errors, output gone, run missing | breaking |
53
+ | Tool args changed, new tool calls, tools reordered, output changed, latency or cost regression | changed |
54
+ | Model changed, large token swings, run now succeeds | info |
55
+
56
+ Exit code is 1 when something breaking shows up, so you can put it straight into CI:
57
+
58
+ ```yaml
59
+ - run: node run-agent-suite.js --out traces/current.jsonl
60
+ - run: npx whatbroke-cli diff traces/baseline.jsonl traces/current.jsonl --md >> "$GITHUB_STEP_SUMMARY"
61
+ ```
62
+
63
+ `--fail-on warning` if you want stricter gates, `--fail-on never` if you just want the report.
64
+
65
+ ## Flaky agents
66
+
67
+ Agents don't do the same thing twice, so a single before/after comparison can blame the change for noise the agent was already making. Record each scenario a few times and suffix the run ids:
68
+
69
+ ```
70
+ refund-flow#1, refund-flow#2, refund-flow#3
71
+ ```
72
+
73
+ whatbroke notices the suffixes, compares every before sample against every after sample, and puts a rate on each finding:
74
+
75
+ ```
76
+ ! issue_refund called with different args (amount) (6/9 run pairs)
77
+ ```
78
+
79
+ Anything that also flaps between two *baseline* samples gets demoted to flaky info, because your agent behaved that way before the change too. Breaking findings that show up in under half the pairs soften to warnings. What's left is signal.
80
+
81
+ ## Recording traces
82
+
83
+ The trace format is deliberately boring: JSONL you can write from any language in ten minutes.
84
+
85
+ ```jsonl
86
+ {"type":"run_start","run":"refund-flow","meta":{"model":"gpt-4o"}}
87
+ {"type":"llm_call","run":"refund-flow","model":"gpt-4o","latency_ms":900,"tokens":{"input":512,"output":128},"cost_usd":0.004}
88
+ {"type":"tool_call","run":"refund-flow","name":"lookup_order","args":{"order_id":"A-1042"}}
89
+ {"type":"output","run":"refund-flow","content":"Refund issued."}
90
+ {"type":"run_end","run":"refund-flow","status":"ok"}
91
+ ```
92
+
93
+ The fastest way to get one is the proxy. Zero code changes, any language:
94
+
95
+ ```
96
+ whatbroke record --out traces/current.jsonl
97
+ ```
98
+
99
+ Then point your agent at it and run it exactly as you always do:
100
+
101
+ ```
102
+ OPENAI_BASE_URL=http://127.0.0.1:4141/v1 node my-agent.js
103
+ # or
104
+ ANTHROPIC_BASE_URL=http://127.0.0.1:4141 node my-agent.js
105
+ ```
106
+
107
+ Every LLM call, tool call, and final answer lands in the trace. Streaming works, responses pass through untouched. If you drive several scenarios, send an `x-whatbroke-run` header per request to name the runs.
108
+
109
+ If you're in Node, the SDK wraps your existing client and records everything automatically:
110
+
111
+ ```ts
112
+ import { Recorder } from "whatbroke";
113
+ import OpenAI from "openai";
114
+
115
+ const rec = new Recorder({ file: "traces/current.jsonl", run: "refund-flow" });
116
+ const openai = rec.wrapOpenAI(new OpenAI());
117
+
118
+ // use openai exactly as before; llm calls and tool calls are captured
119
+ await runMyAgent(openai);
120
+
121
+ rec.output(finalAnswer);
122
+ rec.end("ok");
123
+ ```
124
+
125
+ `rec.wrapAnthropic(client)` does the same for the Anthropic SDK. For everything else there's `rec.llmCall()`, `rec.toolCall()`, `rec.output()`, `rec.end()`, or just write the JSONL yourself.
126
+
127
+ ## Options
128
+
129
+ ```
130
+ whatbroke diff <before.jsonl> <after.jsonl>
131
+
132
+ --json machine-readable output
133
+ --md markdown output, drop it in a PR comment
134
+ --fail-on <level> exit 1 on: breaking (default), warning, never
135
+ --latency <ratio> flag latency regressions above this ratio (default 1.5)
136
+ --cost <ratio> flag cost increases above this ratio (default 1.25)
137
+ --no-outputs skip comparing final outputs
138
+
139
+ whatbroke record --out <trace.jsonl>
140
+
141
+ --port <n> port to listen on (default 4141)
142
+ --run <name> run id when no x-whatbroke-run header is sent
143
+ --target <url> forward everything to this origin instead
144
+ ```
145
+
146
+ ## Why not just use evals?
147
+
148
+ Use both. Evals score each version against a rubric. whatbroke answers a different question: what exactly changed between these two versions, at the tool-call level, with no rubric to write and no judge to pay for. It's the thing you run five minutes after a new model drops, before deciding whether your eval suite even needs to run.
149
+
150
+ Deterministic, offline, no API keys, no accounts. Your traces never leave your machine.
151
+
152
+ ## Roadmap
153
+
154
+ - [x] Multi-sample runs, so flaky behavior shows up as a flap rate instead of noise
155
+ - [x] Proxy capture (`whatbroke record`), traces without touching your code
156
+ - [ ] Importers for LangSmith and Langfuse trace exports
157
+ - [ ] Python recorder
158
+ - [ ] `whatbroke watch` to auto-diff against a baseline while you iterate
159
+ - [ ] Semantic output comparison (opt-in, bring your own key)
160
+
161
+ Issues and PRs welcome. If whatbroke caught something silently breaking in your agent, I'd genuinely love to hear about it.
162
+
163
+ ## License
164
+
165
+ MIT