One PR Billed 156M Tokens. Cap the Reads, Not the Rate.

A published trace of one 800-line pull request shows a coding agent billed roughly 156 million tokens to produce 289,000 — 98% of the volume was cache re-reads of context re-sent on every one of 512 turns. Coding-agent cost is set by turns per task and the width of each read, not by the model's rate card.

By Rajesh Beri·September 3, 2026·12 min read
Share:
An office photocopier mid-run in a quiet workroom, a single stapled paper original still lying on the open glass while a tall stack of identical copies spills out of the output tray onto the floor.

Illustration generated using AI

Your coding-agent bill is not a model-price problem. It is a retrieval-scope problem, and the gap between those two readings is roughly two orders of magnitude. On 1 September, Sonar research engineer Antonio Aversa published the full instrumented trace of one ordinary 800-line pull request: 512 model round-trips, 106,000 fresh input tokens, 3.1 million cache-write tokens, 152.8 million cache-read tokens, and 289,000 tokens of output. Roughly 156 million tokens billed, for about $41. The agent produced 0.19% of what it was charged for.

If your finance model for coding agents is a per-token rate card and a seat count, it is tracking neither of the two variables that actually move the number.

What 156 Million Tokens Actually Bought

Almost none of the bill was the model thinking; nearly all of it was the same context being re-sent. In Aversa's trace the context window peaked at 458,700 tokens on a task that amounted to mirroring existing C# call-site resolution into Python. Cache reads — context the agent had already paid to write once, re-read on every subsequent turn — were 152.8 million of the 156 million tokens billed. That is 98% of the volume, spent re-reading things the session already knew.

It was not one unlucky session. Across 18 comparable single-ticket pull requests in the same repository the team measured an average of roughly 234 million context tokens each, about 700 round-trips, an average cost near $65 and a median near $52, with context windows peaking between 450,000 and 975,000 tokens.

Three caveats, and they matter. The post does not name the model, and the dollar figures rest on a stated cache-read rate of about $0.20 per million tokens — so treat the $41 as directionally right and model-dependent, and the token counts, which are what the argument rests on, as the hard evidence. It does not name the agent or harness either, which is the larger omission: turn count is a property of the harness, not the model, and 512 round-trips is the number this whole thesis turns on. And Sonar sells the fix — the post closes by pitching Sonar Vortex, its own agent harness, and the trace was run against the repo of SemSitter, its own semantic-navigation engine. The instrumentation is unusually good and the figures are internally consistent. It is still one vendor measuring one repository.


A Read Costs Its Tokens Times Every Remaining Turn

The unit of cost in an agent session is not the read; it is the read multiplied by the number of turns that follow it. Aversa traces one over-read end to end: the agent needed a ~67-line function and pulled the whole 618-line file, 6,472 tokens, wasting about 5,770 immediately. That file then sat in the transcript for roughly 470 more turns, which turned a single sloppy read into about 2.7 million cache-read tokens and roughly $0.54. One cat of one file.

The billing mechanic behind that is documented, not theoretical. Anthropic's prompt-caching reference states the multipliers plainly: cache reads bill at 0.1x the base input price, 5-minute cache writes at 1.25x and 1-hour writes at 2x, and the read is charged on every request that uses the cached content. A 90% discount applied to a linearly growing prefix, once per turn, is still a quadratic.

Independent analyst Martin Alderson derived the same shape from published price cards three weeks earlier and put numbers on it. In his worked comparison of a 20-turn versus a 100-turn agentic session starting from 60k of context, Claude Opus 5 goes from $2.32 to $21.34 while the cache-read share of the bill rises from 44.9% to 76.4%; GPT 5.6 Sol goes from $2.16 to $36.20 with the share rising from 48.1% to 81.6%. Five times the turns, roughly nine to seventeen times the cost. His conclusion is the sentence to take into your next planning meeting: "even cutting the number of turns down by 10% reduces cost per agent run by around 16%."

Vantage's cost breakdown lands in the same place from a different direction, estimating that input tokens are roughly 85% of agentic session cost and that a session opening at ~5,000 input tokens per request is carrying ~20,000 by turn 30 and ~35,000 by turn 50 — figures its own table labels illustrative rather than measured. Weigh the three sources accordingly: one instrumented trace, one model built from published price cards, one estimate. They agree on direction, and only the first is a measurement. In all three, the output is a rounding error.

Turn count is not the whole variable, either, and the best evidence on that point is not a vendor's. In a workload characterisation of agentic systems, Yuan et al. report that context growth is not simply a proxy for turn count — SWE-bench Pro accumulated the largest contexts, averaging 69,000 to 80,000 tokens, despite other workloads showing longer turn-count tails — and conclude that serving has to manage repeated model re-entry and sustained context growth. That cuts against reducing this to a turn-count story, and in favour of the other half: how wide each read is matters independently of how many times you re-send it.

The Price Cut Moves the Multiplier, Not the Exponent

The obvious objection is that vendors are already pricing this away, and the timing makes it a fair one. On 1 September Anthropic shipped Claude Fable 5.1 at the same $10 / $50 per-million input and output rates while cutting cache reads 75%, from $1.00 to $0.25 per million — a multiplier of 0.025x base input rather than the usual 0.1x, per the caching docs. Anthropic's own claim is that this cuts typical bills about 25% and highly agentic ones up to 45%.

Take the steel-man seriously: at 0.025x, Aversa's 152.8 million cache reads cost a quarter of what they did. That is a real, large saving on a real, large line item.

It still does not change the shape of the curve. A price cut divides the constant; the turn count is in the exponent, and nothing about the September rate card reduces how many times an agent re-reads a 618-line file. Worse, the two can move against each other. Artificial Analysis measured Fable 5.1 at $3.76 per Intelligence Index task against Fable 5's $3.14 — 20% more per task — because the newer model emits about 1.7 times as many output tokens. A cheaper cache read on a longer session is not automatically a cheaper session. We covered which model the new multiplier actually favours when the price change landed; this is the other half of that story, and it is the half you control.


Your Telemetry Standard Has No Word for This

You almost certainly cannot see the 98% in your dashboard, because the standard your dashboard implements does not have a name for it. The OpenTelemetry GenAI semantic conventions define gen_ai.client.token.usage with a gen_ai.token.type attribute, and the well-known values are exactly two: input and output. There is no cache-read token type in the spec.

So a conformant instrumentation collapses 152.8 million cache-read tokens and 106,000 fresh input tokens into a single "input" number. The bill's dominant term and its smallest term are reported as the same metric. Every provider returns the split — Anthropic exposes cache_read_input_tokens on each response — but if your observability layer maps to the semantic convention and stops there, that field never reaches a chart. This is the same class of gap we hit when span attributes turned out to be the billing unit in LLM observability tools: the number you are governed by is not the number you are shown.

An agent turn is one full model round-trip: the agent sends the entire accumulated transcript, the model responds, a tool runs, and the result is appended. It is the unit your cost scales with, and almost nobody meters it.

Long Context Is Worse, Not Just Dearer

The unusual thing about this problem is that the cheap fix and the accurate fix are the same fix. Chroma's context-rot study tested 18 models and found performance degrades as input length grows, even on simple retrieval tasks, and that a single semantically-similar distractor is enough to push performance below baseline. Two limits are worth holding onto: not every model appears in every experiment, and the tasks are retrieval benchmarks — needle-in-a-haystack, long chat histories — run on the GPT-4.1 / Claude 4 / Gemini 2.5 / Qwen3 generation, not on coding sessions with today's models. Carrying it across to an agent transcript is an inference, not a finding. It is a reasonable one: that 618-line file the agent did not need is a close semantic near-miss for the 67 lines it did need, it is being re-read 470 times, and you are paying for the privilege.

Anthropic's context-management release quantifies the other side. In a 100-turn web-search evaluation, clearing stale tool results cut token consumption 84% while letting agents finish workflows that previously died of context exhaustion; context editing alone improved task performance 29%, and 39% combined with the file-backed memory tool. Note whose evaluation that is — it is the vendor's internal agentic-search set, not yours — but the direction is corroborated by independent work, and the mechanism is not mysterious.

Practically, this is a settings problem before it is a procurement problem. WorkOS published a concrete configuration for exactly this: a 320,000-token context window with 64,000 reserved and 40,000 kept recent, which triggers compaction at 256,000 rather than letting a session run to a million. Their reason for capping below the maximum is not cost at all — it is that the default 20,000-token recent-context window "works out to roughly 5 to 20 turns," and that models miss critical actions far more often when those actions are buried behind hundreds of thousands of tokens of benign activity.

What the Fix Is Actually Worth

Narrower retrieval saves real money, and the honest number is smaller than the headline. Sonar's own product benchmark — its case for selling you graph-based code navigation instead of grep — measured six refactoring tasks across Java, Python, TypeScript and C# on Claude Opus 4.8, ten runs per condition, gated on compiling and passing tests. Median cost reductions ranged from 34% on a Java self-typing task down to 6% on a TypeScript one, with input tokens down 11–31%.

Read the 6%, not the 34%. That is a vendor measuring its own product on tasks it chose, and the spread across six tasks is wide enough to tell you the benefit is real but task-dependent. A 20% median cost reduction on a $65-per-PR workload is worth having; it is not a category change, and any vendor quoting you the top of that range is quoting you their best case. The category change is in the turn count, and that is yours to control regardless of which navigation tool you buy — the same conclusion we reached about specifying work in machine-checkable form rather than prose, and about capping agent retries before an upstream incident turns them into a billing event.


Where to Put the Caps

This Week:

  1. Pull seven days of agent API responses and sum cache_read_input_tokens separately from input_tokens. If your dashboard cannot produce that split, you have not been looking at your bill — you have been looking at a subtotal. Langfuse and its peers can record the field; the semantic convention will not do it for you.
  2. Take your three most expensive sessions and count round-trips. Write the number on the same slide as the token cost. Cost climbs faster than the count does — on Alderson's numbers a 10% cut in turns takes about 16% off the run — so it is the budget line, not a curiosity.
  3. Grep your agent's tool definitions for a whole-file read with no line range. That is where the 618-line reads come from.

This Month:

  1. Set a compaction threshold and a turn ceiling per task class, and make them defaults rather than advice. Start from a published configuration — 320K window, 64K reserve, 40K kept recent — and then tune it against your own traces.
  2. Turn on tool-result clearing or context editing where your provider supports it, and re-run your existing eval set with it on. If you do not have an eval set, that is the actual finding of this exercise.
  3. Give the agent a symbol-level read tool. The cheapest possible retrieval improvement is a read_function that returns 67 lines instead of 618.

Before Renewal:

  1. Rebuild the unit of budget. Cost per merged pull request, not cost per seat and not cost per million tokens. At Sonar's $52 median per PR — one repository's number, so measure your own — a 25-engineer team shipping 40 PRs a week is a six-figure line item that no seat count predicts.
  2. Put two numbers in every coding-agent proof of concept: median round-trips and median cache-read tokens per merged PR, measured on your repository. Make them acceptance criteria, the way we argued for scoring pilots pass/fail on completion rather than average quality. A vendor that will not report turn counts is selling you an unmetered meter.
  3. If you are negotiating consumption pricing with Cursor, GitHub Copilot or anyone else, negotiate the cap and the visibility, not only the rate — the same posture that applies to consumption contracts generally.

The Bottom Line

Engineers have seen this exact bug before, in a different costume. It is the N+1 query: the price of a single database round-trip was never the problem, the count was, and no amount of negotiating a cheaper database fixed an ORM that issued 4,000 of them. Teams that shaved the per-query cost got a 10% win; teams that eliminated the queries got the order of magnitude. Coding agents have reproduced the pattern faithfully, with one twist — the cached prefix means each turn re-pays for every turn before it, so the curve bends up rather than running flat.

The vendors will keep cutting the cache-read multiplier, because it is the cheapest concession they can make and it photographs well. Take it. Then go and count your turns, because that is the number they cannot cut for you. When the cost of a run is the thing you are actually buying, the rate card is the one line on the invoice you have no leverage over.

Every other line is an engineering decision you already own.

Continue Reading

Share:

Frequently Asked Questions

Why do AI coding agents cost so much more than the token price suggests?

Because the whole accumulated transcript is re-sent on every turn. In Sonar's published trace of one 800-line pull request, 152.8 million of the 156 million tokens billed were cache reads of context the session had already paid to write, spread across 512 model round-trips. Output was 289,000 tokens, about 0.19% of the bill's volume.

What is a cache read token and how is it priced?

A cache read is previously-cached context re-sent with a new request. Anthropic's docs price cache reads at 0.1x the base input rate on most models, with 5-minute cache writes at 1.25x and 1-hour writes at 2x. The discount is large, but the read is charged on every single request that uses the cached content.

Does cutting agent turns actually reduce cost much?

Yes, disproportionately. Because each turn re-reads a context that grows with turn count, the cache-read term grows quadratically and total cost climbs faster than the turn count does. In Martin Alderson's modelling from published price cards, five times the turns is nine to seventeen times the cost depending on the model, and he estimates that cutting turns by 10% reduces cost per agent run by around 16%.

Did Anthropic's 75% cache-read price cut fix this?

It reduces the multiplier, not the curve. Claude Fable 5.1 cut cache reads from $1.00 to $0.25 per million tokens on 1 September 2026, and Anthropic claims 25% to 45% lower bills. But Artificial Analysis measured Fable 5.1 at $3.76 per task against Fable 5's $3.14, because it emits about 1.7 times the output tokens.

Why does my observability dashboard not show cache read tokens?

The OpenTelemetry GenAI semantic conventions define gen_ai.client.token.usage with only two well-known gen_ai.token.type values, input and output. There is no cache-read type, so conformant instrumentation collapses cache reads into the input figure. Providers do return the split, such as Anthropic's cache_read_input_tokens field, but you have to record it deliberately.

What settings reduce coding agent context cost?

Compact well below the maximum window and clear stale tool results. WorkOS publishes a 320,000-token window with 64,000 reserved and 40,000 kept recent, which triggers compaction at 256,000. Anthropic reports that clearing stale tool results cut token consumption 84% in a 100-turn search evaluation while improving task performance 29%.

Newsletter

Stay Ahead of the Curve

Weekly enterprise AI insights for technology leaders. No spam, no vendor pitches—unsubscribe anytime.

Subscribe

Latest Articles

View All →