See what your AI coding agent actually did, and what it cost.
One command reads the Claude Code and Codex session logs already on your machine and tells you where the money went and what was avoidable: long context re-sent every turn, caches rebuilt after breaks, stuck retries. No config, no API key, nothing uploaded.
Or uvx --from agent-trajectory-diff agentdiff, or /agentdiff:report inside Claude Code.
A real week from the author's own logs · session names changed
Your bill shows a total. Not a reason.
On real Claude Code usage, most of the spend isn't the model writing code. It's context habits. Every finding names the session and the file or command involved, with a dollar estimate.
Long context, re-sent every turn
Each turn re-reads the whole conversation. Past a few hundred thousand tokens, most of your bill is the model re-reading what it already saw.
→One session per task. /compact before it gets huge.
Cache rebuilt after a break
Come back to a long session after the prompt cache expired and the entire context is written again at cache-write prices. One resume of an 818k-token session cost $6.38.
→After a long break, start fresh instead of resuming.
Stuck retries and repeated failures
The same command failing the same way, again and again, or one kind of command failing all session long.
→Fix the setup step, cwd or flaky test once.
Re-reads and identical calls
Unchanged files read repeatedly, and identical calls returning identical output. Cost with no new information.
→Point the agent at the right section; keep notes in CLAUDE.md.
One command. Zero setup.
Claude Code and Codex already write a log of every session to disk. AgentDiff reads them. Nothing to configure, no account, no key.
Inside Claude Code
Install the plugin once, then run /agentdiff:report in any session. Claude shows the report and explains what to change. It can also pick it up when you ask why usage is high.
Any terminal with Node
npx fetches a tiny launcher that runs AgentDiff with uv, pipx or your Python 3.10+, whichever you have.
Python people
Run it once with uv, or install it with pip, pipx or uv tool install. The command is agentdiff.
pip install agent-trajectory-diffpipx install agent-trajectory-diffnpm i -g @kerrshift/agentdiff/agentdiff:report --since 30dOptions
How the numbers are computed
- Reads ~/.claude/projects (or $CLAUDE_CONFIG_DIR), including subagent transcripts.
- Counts each billed request once. Claude Code repeats usage on every content block, and resumed or forked sessions copy their parent's history.
- Prices per model at Anthropic list prices, with cache reads and both cache-write TTLs (5-minute and 1-hour). Fast mode included.
- Reads Codex rollouts from ~/.codex/sessions ($CODEX_HOME) and prices each turn with the model it used, including OpenAI's long-context and Fast tiers. Codex logs carry no cost, so those figures are API-equivalent estimates.
- Uses Claude Code's own cost counter as the total when a session has one; the gap shows up as background calls not in the transcript.
- On Pro/Max plans these are API-equivalent costs: still the clearest view of which sessions and habits use the most.
Private by design. Session logs contain your source code. AgentDiff reads them locally, makes no network calls and has no telemetry.
Supported: Claude Code and OpenAI Codex CLI. Planned: Gemini CLI, Cursor.
A trajectory regression gate for your CI.
Building your own agent with LangGraph, CrewAI, the OpenAI Agents SDK or OpenTelemetry? AgentDiff compares each PR's agent run against a recorded baseline and fails the build on runaway tool loops or cost spikes. It handles non-deterministic agents with N-run baselines, posts a verdict on the PR, and re-baselines with a /agentdiff approve comment.
Instant root-cause diagnosis right in GitHub PRs.
Engineers never have to hunt through raw terminal logs or third-party web apps. AgentDiff posts an actionable diagnostic comment directly to the Pull Request review timeline.
refactor(prompt): parse customer records with new schema #42
main from feat/parse-schema⛔ AgentDiff · Trajectory Regression Check (Exit Code 1)
Candidate execution trajectory breached regression tolerances against golden baseline.
| Gate | Measured | Threshold | Verdict |
|---|---|---|---|
| TDI (Trajectory Divergence) | 0.4285 | ≤ 0.2500 | ❌ FAIL |
| Stagnant Tool Retries | 3 loops | 0 loops | ❌ FAIL |
| Token Budget Delta | +148.2% | ≤ 10.0% | ❌ FAIL |
execute_sql node repeated 3 consecutive times with identical parameters without state progress.
f8c21a9max_tdi = 0.25
max_consecutive_loops = 0
max_token_delta_percent = 10.0
Works with your existing agent stack. Zero code rewrite.
You shouldn’t have to re-architect your codebase to protect your agents. AgentDiff connects directly to your existing telemetry formats and framework runtimes.
LangGraph
State Checkpoint DAGsIngest native JSON trace dumps from LangGraph directly into AgentDiff's deterministic regression engine. Sub-5ms parsing speed, zero telemetry lock-in, and full DAG verification.
# Ingest native LangGraph Checkpoints with zero instrumentation
from agentdiff import load_trace, compare
baseline = load_trace("runs/langgraph_golden.json")
candidate = load_trace("runs/langgraph_pr.json")
# Compare execution paths across cycles & tool nodes
report = compare(baseline, candidate)
assert report.stagnant_loops == 0Everything you need to know.
The spend report first, then the CI gate. Anything else, ask on GitHub.
Find out where your agent budget went.
One command, about ten seconds, nothing uploaded. Building your own agents too? The same package gates them in CI.
- uses: kerrshift/agentdiff/.github/actions/[email protected] with: baseline: baselines/default.envelope.json candidate: traces/candidate.json