Back to Insights
21 Jun 20265 min readAI & LLMs

The Tokens Your Agent Wastes Aren't in the Config. They're in the Transcript.

You can lint what an agent is allowed to do — its permissions, its MCP servers, its context budget. We've written those tools. But none of them tell you what the agent actually did once it started working. And what it did, it turns out, includes a lot of paying for the same thing twice.

Coding agents waste context in a handful of boringly predictable ways: they read the same file again, they read a file right after editing it, they re-run the same command, they re-grep the same pattern. Each redundant tool result is real tokens — paid for on the turn it lands, and then carried forward in context on every turn after. One developer watched their Claude Code bill hit $1,600 and put it well: "I wasn't burning tokens on bad prompts. I was burning them on invisible architecture."

So we made the architecture visible. agent-waste reads a Claude Code session transcript, reconstructs every tool call and the size of the result it returned, and reports what got wasted.

What it found in one real session

We pointed it at a single large, real session — 3,174 tool calls — from one of our own machines:

agent-waste — <session>.jsonl  (3174 tool calls)

  ● duplicate reads          ≈34,383 tok wasted — same file read more than once
      2× redundant  ≈10,513 tok  …/huddle/references/steps/step-02-discussion.md
  ● re-reads after own edit  ≈44,796 tok wasted — read a file THIS session just edited
      11× redundant  ≈ 8,296 tok  …/memory/MEMORY.md
       7× redundant  ≈ 5,088 tok  …/forecaster/features.py
  ● repeated commands         ≈6,291 tok wasted — an identical Bash command run again
      ran 3×  ≈ 2,651 tok  python3 …/huddle/scripts/global_state.py

  ● ≈85,469 tokens of redundant tool results across this session (estimate; ~4 chars/token).

Eighty-five thousand tokens of redundant tool results in one session — roughly 40% of a 200k window's worth, spent re-fetching things the agent had already seen. The single worst offender: a MEMORY.md file read eleven times after the agent itself had edited it.

That last category is the interesting one, because it's not even a judgment call. Claude Code's own Read-tool guidance literally tells the agent: "Do NOT re-read a file you just edited to verify — Edit/Write would have errored if the change failed, and the harness tracks file state for you." The agent re-read it anyway, eleven times. The harness already knew the new contents; the re-reads bought nothing but tokens.

How it works

The transcripts live at ~/.claude/projects/<slug>/<session>.jsonl — one JSON object per line. An assistant tool call shows up as a tool_use block (name, input, id); the result comes back in the next user turn as a tool_result block with a matching tool_use_id. agent-waste links the two so it can size each result, then walks the calls in order and tracks, per file, whether the agent had already read or edited it:

  • First read of a file → justified, free.
  • Read again, no edit since → a duplicate read. The content is already in context.
  • Read again after the agent edited it → the read-after-own-edit anti-pattern above.
  • Identical Bash / Grep / Glob repeated → flagged, with the repeats' result size as the waste.

The wasted-token figures are an estimate — ~4 chars/token of the repeated payloads; Claude's exact tokenizer isn't public — so read them as a signal for which habits cost you, not a bill. And it's deliberately honest about false positives: re-running your tests or re-checking git status after a change is legitimate. The tool says "here's where to look," not "every line is a bug." A --threshold-tokens gate lets you fail a self-audit in CI when waste crosses a line; --json feeds a dashboard.

One caveat we put right in the README: the transcript format is undocumented and reverse-engineered — Anthropic ships no spec, and the fields drift across Claude Code versions. So agent-waste skips anything it doesn't recognize and degrades gracefully rather than pretending the format is stable.

Why this isn't ccusage (or codeburn)

If you've optimized Claude Code costs, you know ccusage — the excellent token-and-cost aggregator. It answers how much did I spend. It does not answer what did I waste — it sums usage, it doesn't look for redundancy. codeburn goes further and flags files re-read across sessions and a low read-to-edit ratio. What neither does is catch the within-session patterns that hurt most: the read-immediately-after-edit, the duplicate command, the repeated grep. That triad — specific, named, and measured in tokens — is exactly what agent-waste reports. ccusage tells you the bill arrived; agent-waste tells you which habit wrote it.

(There's also a clever read-once hook that prevents redundant reads live — its author measured ~40% of read-tokens saved on one session. That's the prevention side of the same coin; agent-waste is the audit side. Use both.)

The point isn't the tool — it's the habit it measures

Run it on your own busiest session and you'll almost certainly find a five-figure token number hiding in re-reads. The fix isn't subtle: trust the edit (the harness already confirmed it), keep one copy of a file's content in your head instead of re-fetching it, and don't re-run a search you already ran. If you're building agents, the same lesson points at tooling: a read-once guard, returning diffs instead of whole files, capping verbose command output. Infracost cut Claude's token use 79% just by making their CLI output smaller to read — same lever, upstream.

The convenience of an agent that can read anything, anytime, hides how often it reads the same thing. Now you can count it.

agent-waste is a single file, no dependencies — point it at a .jsonl and see your number. → Talk to us if you're tuning an agent's token economy.


Prior art, credited: ccusage owns usage/cost aggregation; codeburn does cross-session re-read and read:edit analysis; the read-once hook prevents redundant reads at runtime. agent-waste's niche is the post-hoc, within-session behavioral audit — the read-after-edit / duplicate-command / repeated-search triad, in tokens. Counts are estimates; the transcript format is undocumented and version-dependent.


Get the tool → agent-waste in agent-ops — open source (MIT), a single dependency-free script, part of our toolkit for running coding agents in production.

AI agentscosttranscriptsefficiency

Found this useful?