"An agent is just a prompt in a loop" is true, and it is the most expensive word in that sentence. Over 36 real agent sessions on this repository β 5,352 turns of actual work β the models read 1.2 billion tokens of context to produce 6.3 million tokens of output. That is 192 tokens read for every token written.
It is the standard explanation and it is accurate. The model answers, something runs a tool, the result goes back, the model answers again. Nothing exotic.
What the sentence hides is the word loop. A language model has no memory between calls, so every turn has to resend the entire conversation β the instructions, every tool result so far, every previous answer β before the model can add one more sentence to it. The loop is not repeating a prompt. It is repeating a prompt that gets longer every time.
That is easy to say and rarely priced. This page prices it, on real work.
Every Claude Code session leaves a transcript, and each assistant turn in it carries an exact usage record: input tokens, output tokens, and the split between tokens read fresh and tokens served from cache. Those transcripts are the dataset β the agent sessions that built this website, including the four explainers next to this one.
Start with the shape of it. Here is every token the models handled across all 36 sessions, drawn to scale β everything read on the left, everything written on the right.
Before an agent does anything at all β before you have asked it a question β it has to be told what it is and what tools exist. Those instructions and tool schemas are sent on every single call.
That is the floor. Say "hello" to an agent and you have already paid it. Ask a chat model the same thing and the whole request is a few dozen tokens.
From that floor, each turn adds whatever happened β a file read, a command's output, the model's own answer β and all of it is resent next time. The line below is the median context across 6 sessions that all ran to at least 200 turns, so every point is the same sessions measured later, not a shrinking group of survivors.
Because it cannot. There is a hard ceiling on how much a model can be shown at once, and long before the cost becomes absurd the conversation hits it. What happens then is visible in the data as a cliff.
| Session | At turn | Context before | After | Dropped | Kind |
|---|
If the model is re-reading an enormous conversation on every turn, it is worth asking what that conversation is made of. Measured across every block in every session, by size:
Share of all content added to the conversation, by character count. Character counts rather than tokens, because the ratio between them is close enough across these kinds of text that the shares hold.
There is a reason this is affordable at all. Because each turn resends a conversation that is mostly identical to the last one, almost all of it can be served from cache β charged at a tenth of the normal input rate rather than the full one.
The obvious response to a big bill is to switch to a cheaper model. β
But that reasoning prices the model and ignores the loop. Here is the same measured growth curve run on both rate cards β a cheap model working through a task turn by turn, against an expensive model answering once:
| Turns | Cheap model, in a loop | Expensive model, one answer | Which is dearer |
|---|
Count turns, not tokens. Tokens are the unit you are billed in; turns are the unit you control. Every turn you remove takes its own cost and every future re-read of it.
Keep tool output small at the source. β Reading 40 lines instead of a whole file, or grepping instead of dumping, is not a small saving β that text is re-read on every remaining turn of the conversation.
Make sure caching is actually on. β It is the single largest lever measured here, and it is a configuration flag rather than a redesign.
Start a new session when the task changes. A fresh conversation goes back to the floor. Carrying an hour of unrelated history into a new task means paying for that history on every turn of it.
Do not assume a cheaper model fixes a long loop. Section 8. It buys you a few dozen turns, then the loop is back in charge.
Ten questions on the method and the findings. The explanations are worth reading even when you get it right.
Token counts were read from this project's own Claude Code session transcripts by website/scripts/build-agentcost-data.py, which emits counts and nothing else; the derived per-turn counts are committed in this repository. Measured β. Prices were read from Anthropic's published table on β and are applied per model and per cache type.
The arithmetic is not hard: take the context size at the last turn, halve it, multiply by the number of turns. That is roughly what you read to get there β and it is the number that decides your bill, not the length of the answer.
More explainers β