What Coding Agents Do to Your Inference Bill
I watched an agent re-read the same three files four times before it touched a single line, and every one of those reads was a full billable call.
Tens of calls a day versus hundreds
A developer working with a model directly makes maybe 20 to 40 calls in a working day, each one a deliberate question typed by a person who wanted an answer. An agent working the same task autonomously makes calls to plan, to read a file, to run a tool, to check what the tool returned, to re-plan when the result wasn’t what it expected, to retry when a diff didn’t apply cleanly. Almost none of that shows up as a “question” a person would recognize asking. It’s the loop doing its job, and the loop is not shy about how many times it goes around.
Why the loop gets expensive
Three mechanics, all compounding.
The context grows every turn. Most agent frameworks carry forward everything read and done so far into each new step, so the token count per call climbs across a session instead of resetting the way a fresh chat message would.
Retries aren’t free. A tool call that errors, or a diff that fails to apply, triggers another full round trip carrying the accumulated context, not a cheap retry of just the failed piece.
Re-planning happens more than people expect going in. An agent that hits an unexpected result from a file read or a failed test frequently redoes part of its plan, and that’s another full call with everything so far attached.
That’s what happened with the three re-reads I watched. The agent’s plan assumed a function lived in one file, didn’t find it, read a second file to check, still didn’t find it, read a third, found nothing useful there either, and went back to the first file with a different search term because the second attempt had added enough new context that the original file’s contents were worth reconsidering. Four reads, one answer, and every single read carried forward whatever had accumulated by that point in the session.
Gemini 3.1 Pro’s 1,048,576 token input window is part of why this is survivable at all, a long agent loop can legitimately carry an enormous amount of accumulated context per turn without hitting a wall. The same capability is exactly what makes an unwatched loop expensive. Nothing about a bigger window forces the loop to prune what it’s carrying.
Opus 5, which launched 24 July 2026, ships low, medium, and high effort settings plus a fast mode that runs about 2.5 times faster, and that cuts the same problem from the other direction. An agent defaulting to high effort on every trivial file read is paying for reasoning it never needed. The fast mode exists because most of an agent’s calls really are that trivial.
Measure cost per completed task, not cost per request
Cost per request tells you almost nothing for an agent, because the number of requests per task is itself the variable that’s out of control. Two runs of the identical task can differ by five times in call count depending on how many retries or re-plans happened along the way. The number that actually matters is total cost to carry one task from start to a working result, tracked per task, not averaged across whatever the loop happened to do that day.
Attribute cost per caller, not just per project
If every agent in your stack calls out with the same API key, you can see the total bill and nothing past that. The fix is a task or session identifier that rides along on every call an agent makes, so the aggregate number can be split back out afterward: which agent, which task, which run actually generated which part of it.
This only works if the caller passes that identifier in the first place. If every agent call arrives with the same key and no task id attached, no amount of tracking on the receiving end will tell you afterward which run cost what. The identifier has to go in at the call site, it can’t be reconstructed later from a bill that never had it.
None of this is optional infrastructure you get to later. The first time somebody asks “why did last week’s refactor cost what it cost,” the answer is either a task id that was there from the start, or a shrug.
The router half of Smart Inference already tracks actual, not estimated, cost on every inference request. That’s the raw material a per-task number needs. It can’t invent a task id that was never in the request to begin with, that part has to come from how your agents call it.
A monthly total tells you the loop is expensive. It does not tell you which loop.