When a coding agent is running, the bill can look pretty tame. The moment you stop reading its output, though, costs can jump - sometimes a lot. The culprit is prompt-cache lifetime: a cache that expires turns what should have been a cheap cached read into an expensive rewrite of the conversation up to that point.
In a 30-day look at coding-agent traffic, Claude lost 15.2% of its spend to pauses between five and 30 minutes. GPT lost 0.8% in the same pause window. The cache read/write multipliers were the same for the comparison; the real difference was default cache lifetime - five minutes for Claude vs. at least 30 minutes for GPT.
This matters if you build coding agents, manage model spend, or pick a provider for a team. The goal here is to spell out how the timer affects each turn, what the production data does (and doesn't) prove, how to estimate the cost of your own pauses, and which mitigations are actually worth testing. The practical takeaway is simple: if your token cost sheet doesn't mention cache lifetime, it's missing a line item that can dominate long, interactive sessions.
Why cache lifetime changes the bill
A coding agent grows a conversation on every turn. That context isn't just chat text - it includes instructions, tool definitions, user requests, and the results of earlier tool calls: code diffs, test output, and file contents. By turn twenty, there's often a big chunk of earlier content that's been repeated so many times it starts to look like a refund request.
Prompt caching is what keeps that repeated prefix cheap. Instead of paying the full input rate every time, you pay more to write tokens into the cache once, then less to read them on later turns. In the pricing used for this comparison, both providers charged 1.25x the input price for a cache write and 0.05x for a cache read. Also, a successful read refreshes the cache timer.
So the key variable is how long the cache stays available when nothing is happening. In this comparison, Claude's default cache lifetime was five minutes. GPT's was at least 30 minutes. If a developer pauses for eight minutes, Claude may have to write the full conversation prefix again, while GPT can still serve it as a low-cost cache read.
The math makes the "why" hard to ignore: a 1.25x write costs 25 times as much as a 0.05x read for the same tokens. On a 210,000-token Claude Opus session, that eight-minute pause can turn a cache read of roughly $0.04 into a write of about $1.05 at list price. Longer conversations mean a bigger prefix - and therefore more expensive rebuilds when the cache drops.
| Cache setting in the comparison | Claude Opus 5.5 / Sonnet 5.5 | GPT-6.1 Sol |
|---|---|---|
| Cache read | 0.05x input price | 0.05x input price |
| Default cache write | 1.25x input price | 1.25x input price |
| Default lifetime | 5 minutes | 30 minutes minimum |
| Longer option | 1 hour at 2.0x write | 12 hours at 2.5x write in the Responses API |
This doesn't automatically mean Claude is always more expensive. Short sessions may finish before the first cache expiry, and output tokens (or other costs) can dominate in some workloads. But for long-running, interactive work - where people pause to inspect a diff, answer a message, or get coffee - the default lifetime becomes a real cost dimension. Not a footnote.
What production traffic shows
This analysis covered 30 days of coding-agent traffic, from October 24 to November 22, 2026, across Claude Code, OpenCode, Codex, Pi, and Kilo. It compared traffic on Anthropic's API, Amazon Bedrock, Vertex AI, OpenAI, and Azure. Importantly, the analysis used token and billing counters, not prompt text.
Across pauses longer than five minutes, cache rebuilds accounted for 23.1% of the Claude bill and 9.3% of the GPT bill. The biggest separation was the five-to-30-minute window: 15.2% of Claude spend vs. 0.8% of GPT spend. Once pauses went past 30 minutes, the two lines started looking more similar: 7.8% for Claude and 8.5% for GPT. At that point, both default caches were usually already gone.
| Pause length | Claude share of bill lost | GPT share of bill lost |
|---|---|---|
| 5-10 minutes | 8.0% | 0.4% |
| 10-15 minutes | 3.5% | 0.2% |
| 15-30 minutes | 3.8% | 0.2% |
| 30-60 minutes | 2.6% | 3.5% |
| Over 60 minutes | 5.2% | 4.9% |
| All pauses over 5 minutes | 23.1% | 9.3% |
One thing that surprised me: the "overnight gaps must be the real problem" assumption doesn't hold up by itself. Overnight pauses do create misses, but the 30-minute cache misses did too. The extra cost tied to a five-minute default piles up when someone comes back after a shorter interruption and continues the same large conversation.
The analysis also checked whether user behavior explained the gap. For sessions lasting one to four hours, both groups averaged 3.3 main-agent pauses over five minutes per session. In four-to-24-hour sessions, the counts were 5.9 for Claude and 5.9 for GPT. Looking only at OpenCode - where tool threads use persistent conversation IDs on both model families - the pause-rebuild share was 30.6% on Claude and 11.3% on GPT. The five-to-30-minute window accounted for most of that difference.
That said, there are limits. These numbers describe one traffic sample: the routes, tools, model mix, and pricing in that 30-day window - not every developer setup, not every future model configuration. Pause patterns, prompt sizes, cache behavior, and the share of spend coming from output all affect results. Treat these numbers as evidence of a mechanism, and as a reason to inspect your own logs - not as a universal forecast.
How to estimate the cost of pauses
Start with the turns where a conversation continues after an idle gap. A cache miss isn't just "a request after a pause." It's a request that resends a large prior prefix without getting much cached overlap. In this analysis, a pause miss meant a continuing turn after a gap over five minutes that read less than 10% of the previous prompt from cache.
For your own traffic, group continuing turns by time since the previous request and compare cache-read tokens with cache-creation tokens. A typical miss shows cache reads dropping quickly while cache creation grows toward the size of the prompt prefix. Then estimate the avoidable spend using the difference between the write and read prices - rather than counting the whole write as "new cost."
A useful first-pass calculation is:
Pause cost = missed prefix tokens × (cache-write rate − cache-read rate)
Apply it to each miss, then sum by model, session length, and pause interval. Don't collapse everything into one total if you care about provider differences: the five-to-30-minute cliff matters. Also compare pause frequency and prompt size. Frequent interruptions with short context might stay relatively cheap; fewer pauses in very long sessions can get expensive per miss.
For a like-for-like model comparison, keep the prompt and usage pattern as constant as you can. In this comparison, Claude Sonnet 5.5 and GPT-6.1 Sol were both listed at $2 per million input tokens and $10 per million output tokens. A five-to-30-minute miss cost roughly the same when it happened - about $0.35 on Sonnet and $0.37 on GPT at the median prompt size. But the miss rate was very different: 81.2% for Sonnet vs. 2.3% for GPT. That produced an expected cost of about $0.28 vs. $0.008 per pause.
So just comparing input and output rates can mislead. Similar per-token rates don't guarantee similar realized costs when cache expiry rates differ. And a longer TTL isn't automatically cheaper for every workload - model quality, output volume, tool usage, latency, and the write premium that comes with longer cache settings can still dominate.
For a rough team estimate, multiply the expected cost per pause by the number of eligible pauses per developer, then by the number of developers. Treat it as directional, not as a promise of exact budget impact. The source analysis used an illustration with four five-to-30-minute pauses per workday; your logs should tell you what's actually happening in your environment.
Which fixes are worth testing
The simplest approach isn't "keep every cache alive forever." Pings have a cost, and pings sent after the developer is done are just wasted money. The right policy depends on how likely someone is to return before expiry, how big the cached prefix is, and how deep the conversation goes.
Here are the tested approaches and their trade-offs:
| Approach | Approximate net Claude bill saving | Main trade-off |
|---|---|---|
| Adaptive keep-alive pings | 8%-9% | Requires retaining and resending the last request body; API limits apply |
| Two fixed pings on each idle main turn | 7%-9% | Sends pings even when a short thread is unlikely to resume |
| Switch to a 1-hour cache after the first expiry | 5%-7% | Accepts one miss before using the longer lifetime |
| Use a 1-hour cache from turn one | Model-dependent; can increase cost | Most sessions pay the higher write rate without benefiting enough |
| Switch a warm 5-minute cache to 1 hour mid-session | About 0% in tested Anthropic API and Vertex routes | Can rewrite the full prompt at the higher write rate |
Adaptive keep-alive pings had the strongest measured result. The tested pattern resent the exact last request after about 4.5 minutes of idle, with max_tokens set to zero, to keep the cache warm without generating a normal response. Live checks confirmed cache reads and survival beyond 13.5 minutes on the tested routes. Replaying the production traffic estimated an 8%-9% net reduction in Claude coding spend when pings were limited by turn depth.
This isn't a universal drop-in fix. The agent has to retain the previous request body and send it to the same provider, region, and credentials. The API rejects this approach in some configurations, including certain thinking, structured-output, forced-tool, and batch requests. Also, some longer sessions ended up spending more on terminal pings than the saved rebuilds outweighed - even though the overall replay reduced spend. Practically: stop pinging once a resume becomes unlikely.
A one-hour cache can help, but paying for it from turn one can be wasteful. The longer option increases the write multiplier from 1.25x to 2.0x. In the measured traffic, 87%-89% of sessions that started with it paid more overall. Switching after the five-minute window expires is more targeted: the first request after the miss writes the prompt into the longer-lived cache without paying the premium on every earlier write.
And don't assume you can safely "upgrade" a warm cache entry mid-session. In live tests on the Anthropic API and Vertex, changing from a warm five-minute cache to one-hour markers triggered a full prompt rewrite at the higher rate. Test on the exact provider and route you use before deploying any cache policy. Bedrock behaved differently in the reported tests - another reason not to generalize from a single endpoint.
If you want an implementation order that doesn't waste time:
- Measure first. Identify continuing turns after five minutes and quantify the avoidable write-minus-read cost.
- Separate short and long sessions. Short threads might not justify keep-alive logic; deeper main-agent conversations are more likely to benefit.
- Test one mitigation on real traffic. Compare net spend, including ping writes - not just cache-hit rate.
- Keep subagents and short jobs simple. Apply heavier keep-alive policies to main threads only when context and return likelihood justify it.
- Validate provider-specific behavior. Confirm cache timing, request constraints, and billing changes on your actual route.
The decision rule is straightforward: keep a cache only when the expected cost of a future rewrite is bigger than the cost of keeping it warm. That depends on return probability and context size, not on a blanket preference for the longest TTL.
Conclusion
The main lesson isn't that one model family is always cheaper. It's that cache lifetime changes the cost of ordinary human behavior. A five-minute default can turn a coffee break or careful diff review into a full-context rewrite. A longer default keeps the same prefix warm.
If you run coding agents, measure cache reads and writes around the pauses you actually take before changing providers or adding keep-alive logic. Include the mitigation's own cost, test on the routes you deploy, and apply extra machinery only to sessions where long context and likely returns justify it. Cache lifetime belongs next to input and output rates in every real coding-agent cost comparison.
