Every File Your Agent Reads Stays on the Bill. One Refactor Cost $14.29

September 2, 2026
11 min read

September 2, 2026
11 min read
Sonar published a cost measurement this week that is more useful than the product it is selling.
The headline is that semantic code navigation makes coding agents cheaper. That is true, and the size of the effect is modest and task-dependent. The number I would actually write down is the baseline: a single behaviour-preserving refactor of an open-source Java class cost $14.29 in model spend.
Not a sprint. Not a feature. One commit.
The methodology deserves credit before the findings, because it is stricter than most vendor benchmarks.
Sonar's setup
Six refactoring commits from real open-source projects
That last line is the one that makes the rest worth reading. A cost comparison where the cheaper side is allowed to fail is not a cost comparison — it is a measurement of how quickly you can produce something wrong. Gating on compile-and-test is the same discipline as Thinkingbox grading the database rather than the transcript, and it is still rare enough to be worth naming.
Here is the sentence that explains the whole phenomenon, in Sonar's own words:
Every file the agent reads to build that map stays resident in the conversation context for the rest of the run.
This is the part most cost discussions get wrong. The expensive thing is not reading the file. It is that the file, once read, is carried in context and re-billed on every subsequent turn of the loop.
Read eight files on turn three of a forty-turn run, and you have not paid for eight file reads. You have paid for eight files × thirty-seven turns.
And the reason agents read whole files is structural: text search can find where a symbol appears, but it cannot answer "where is this actually used" — so the agent opens candidates to find out. The fix Sonar built is a queryable graph of the code (classes, methods, fields, interfaces and their relationships) that answers trace-callers or get-type-hierarchy directly, so fewer files ever enter the context.
Why this is the same disease as the MCP tool catalogue
In the MCP roadmap piece the cost was the tool catalogue: every tool, description and parameter schema loaded into context at session start, whether or not the task needed it, and paid for again on the next task. Here it is source files. Same disease, different carrier — content loaded unconditionally and then billed repeatedly. The cure is the same too: make loading conditional, and let the agent fetch on demand.
The absolute figures are the part founders should sit with, because almost nobody has measured their own.
Token movement tracked the money: input tokens down 11–31%, output tokens down 4–35%.
The marketing figure attached to this work is "up to 36% cheaper." The measured range is roughly −6% to −34%, and the authors say plainly why:
The navigation engine will not help on tasks where navigation is not the constraint.
They go further, noting the wins appeared on "the same small, behaviour-preserving change repeated across every implementation of a shared abstraction," and that "the gain is tied to the kind of work, so it is not promised on every task."
That is unusually honest for vendor research, and it is worth crediting rather than sneering at. Sonar sells the fix, so discount the framing — but they published the task where their product only managed 6%, named the condition under which it does nothing, and disclosed that their graph trades type-resolution precision against a compiler in exchange for freshness. Most vendor benchmarks do none of those three.
The saving is not the lesson. The lesson is that per-task cost is now a real number and you probably do not know yours.
There is also a straightforward connection to yesterday's McKinsey finding that 32% of organisations have skipped a software purchase to build with coding agents instead. If a single refactor costs ten dollars of model spend, the "we'll just build it" business case needs a line item most of those decisions did not have. That does not make the decision wrong. It makes the arithmetic less obvious than it looks in a demo.
Six tasks is six tasks. Real refactors from real projects, which is much better than synthetic ones, but a sample this size supports a direction and not a rate. The honest claim is "navigation-heavy refactors got meaningfully cheaper on these six," not "your bill drops a third."
The baseline is an expensive configuration. Opus 4.8 at high effort with subagents on is close to the top of the cost curve by design — that is the right choice for measuring a ceiling, and it means the dollar figures are not what a cheaper model on a smaller codebase would produce.
Cost is not the only axis. A configuration that reads fewer files is cheaper and may also be worse informed. The compile-and-test gate protects against the crudest version of that, but it does not tell you whether the change was good — only that it built and the targeted tests stayed green.
Sonar measured what a coding agent costs to complete a real refactoring commit, gated on compilation and passing tests, and published the range: $1.71 to $14.29 per task on a high-effort frontier configuration. Semantic navigation cut that by 6% to 34% depending on whether navigation was the binding constraint.
The mechanism is worth carrying around even if you never buy the product: a file your agent reads is not billed once, it is billed on every turn until the run ends. That is why long agent loops get expensive in a way that feels disproportionate to the work done, and it is the same shape as the MCP tool catalogue problem.
Go and measure five of your own tasks end to end. The interesting number is not the discount somebody is selling. It is the baseline you have never looked at.
Sources: Sonar, "Cut your coding agent's cost with semantic code navigation" · Sonar Vortex product page · Sonar Vortex context documentation · Task costs, token deltas, the methodology and the quoted caveats are as published by Sonar, who sell the tool being measured; the reading and the cautions in section 6 are mine.
IdeaToMVP Academy
4-week live cohort for founders. Learn to ship AI agents, scope MVPs, and automate your business — taught by the same team that writes these guides.