Somewhere around the eighth turn of a refactor, the arithmetic stops resembling a conversation. The agent has read forty files, run the tests twice and repaired one failure. Every turn re-sends the repository context, the tool schema and the system prompt, and the model has seen all of it before. You are paying full price for a reread.
Caching is the fix, and it is the largest single lever in agent coding. Anthropic charges a cache read at 5% of the input rate on Claude Sonnet 5.5 and Opus 5.5, and 2.5% on Fable 5.1. DeepSeek charges 2%, which at the off-peak input rate is $0.003 per million tokens.
But the number that matters is not on any price list. It is how much of your prompt is stable from one turn to the next, and nothing in the vendor documentation can tell you that about your own repository.
The argument in three steps: caching prices repetition, the write premium sets a deadline on the prefix, and the saving is bigger than the one you get by switching to a cheaper model.
Caching prices repetition, not tokens
Read the published rates as a statement about what the vendors think you are buying. Anthropic's base input for Claude Sonnet 5.5 is $2.00 per million tokens, the cache read is $0.10 and the cache write is $2.50. The first read of a cached prefix costs a quarter more than a normal prompt; every read after it costs a twentieth.
That shape only makes sense if the vendor expects the same text to arrive repeatedly. A one-shot prompt never earns the write premium back. A twenty-turn agent session earns it on the second turn and keeps earning it for the other eighteen.
DeepSeek's schedule is the same idea with the premium removed. There is no published write charge, and the hit price is 2% of the off-peak input rate: $0.003 per million against $0.15. A cache miss costs exactly what the prompt would have cost anyway, so on DeepSeek caching is not a decision you can get wrong.
The prices differ by more than an order of magnitude, but the mechanism behind them is identical: the discount is attached to a prefix, not to a request.
The write premium is a deadline on your prefix
A cache write costs 1.25x base input on Anthropic's 5-minute tier, and the entry is only worth buying if something reads it before it expires. One read pays the 25% back; a second read is profit. The 1-hour tier costs 2x and needs two reads before it breaks even.
This is a latency decision disguised as a pricing decision. Terminal agents usually finish a turn in seconds, so a 5-minute TTL covers the gap between turns and the 1-hour tier is a premium for sessions with long human pauses. A developer who leaves for lunch between turns is the customer for the expensive cache; an automated test loop is not.
The failure mode is subtler than expiry. Cache keys are prefix-based, so the cached span ends at the first byte that differs from the previous request. An agent that reorders file reads, inserts a timestamp at the top of the system prompt, or regenerates its tool schema per turn invalidates everything downstream of the change.
Pay the write premium, then throw the prefix away, and you have paid 25% more than not caching at all.
A stable prefix beats a cheaper model
Take a concrete session. A 60,000-token repository context, re-sent across twenty turns, plus 8,000 tokens of new conversation and tool output each turn. That is 1.2M tokens of prefix and 160,000 tokens of fresh input, and at Sonnet's $2.00 input rate with no caching it costs $2.72 before a single output token.
Now cache it. One 60,000-token write at $2.50, 90% of the 1.2M prefix reads hitting at $0.10, and the rest at the base rate: $0.82, a 70% saving. That is one write and twenty turns, and the result is not sensitive to small changes in the hit rate – at 80% the same session still saves more than half.
Compare the alternative. Dropping from Claude Opus 5.5 to Claude Sonnet 5.5 cuts the input rate by 50% and costs you two intelligence points. Caching the Sonnet session cuts the bill by 70% and costs you nothing but a stable prompt.
That is the whole argument for doing this first.
The counter-case is real: an agent whose work is genuinely different on every turn – a fresh web page per request, a different repository per task, a tool that rewrites its own schema – has almost nothing stable to cache, and will see a hit rate closer to zero than to 90%. The diagnostic is one line of logging on the provider's usage object, which reports cached tokens separately from fresh ones. If the hit rate is under 50%, the prompt is the problem, and no vendor switch will fix it.
What would change the conclusion: a vendor pricing cache reads at the full input rate, or an agent framework that guarantees byte-identical prefixes. Neither exists. Until one does, the cheapest token in agent coding is the one you have already paid for.