Trace study11 September 2026·7 min

Where a tool-using agent's money goes

514 coding-agent sessions and 43,948 API calls, analysed without reading a line of content. 70 % of the bill is cache reads, 64 % of those are tool results, and 42 % of cache writes should not have happened.

64 %of cache reads are tool results

In a tool-using agent the bill is not in the tokens you send. It is in the context you re-read on every call. We took 514 local Claude Code sessions — 192 main sessions, 322 subagents — and 43,948 API calls, and priced them at pay-as-you-go API rates from the usage metadata alone. No prompt, no result, no file name was read.

ItemTokensAPI-equivalent costShare
Input (uncached)749k$60 %
Cache write283M$2,22421 %
Cache read12.9B$7,51870 %
Output33.5M$9649 %
43,948 calls. Cache-hit rate per call: 97 %. Only 70 calls ran with a cold cache.

The cache works. Its size is what costs.

Mean context per call is about 294k tokens. The 28 % of calls made with more than 400k tokens of context make up 50 % of the cost. A session that drags a one-million-token context around pays for it on every single turn, at cache-read price, forever.

What fills the context: tool results

Tool results are only 9 % of the tokens ever written — the agent's own output, reasoning and tool arguments weigh more. But a result, once written, is re-read on every later call. Counted in token-turns, 64 % of all cache reads are tool results: shell output 40 %, file reads 21 %, simulator screenshots 19 %, browser pages 13 %.

Truncating them changes little: capping every result at 2,000 tokens removes 22 % of their tokens. Deduplicating them changes less: 3 % of file-read tokens are re-reads of an unchanged file. What changes everything is evicting a result from the context once it has been used — which is what Anthropic's clear_tool_uses does, and what most harnesses only half do.

The cache is rewritten twice as often as it should be

Of 283M tokens written to the cache, 28 % are normal growth and 24 % are resumptions after a pause of more than an hour. The remaining 42 % — 119M tokens, about $750 at Opus prices — are prefix invalidations in the middle of a session, minutes apart, with no model or effort change. In the two worst sessions, 71 of 83 full rewrites and 58 of 77 happen less than five minutes after the previous one. A $1,700 session contains roughly $300 of pure rewriting.

Text compression attacks an item that weighs 0 % of this bill. For agents, the levers are eviction, prefix stability and session hygiene — and all three are measurable from usage metadata without reading content.

What Tokeen does with this

  • Tool-result compression runs once, when the result enters the context, so every later turn re-reads a smaller block at cache price.
  • Compression is deterministic, so the prefix stays byte-identical across turns and never triggers a rewrite by itself.
  • The dashboard flags prefix invalidations and contexts above 400k tokens per session, with the cost attached.

Limits: costs are API-equivalent (a subscription was likely in use); result tokens are estimated with a public tokenizer (about −15 % vs the provider's); images counted as 1,500 tokens; invalidation attribution is heuristic.

More research

Stop paying for filler. Compress every prompt on one fast, deterministic layer.

Tokeen is in private beta. Request access and see the savings on your own prompts within the week.