Skip to content

Claude Code

Missing Claude’s cache on Opus 5.5 costs up to 40x more

5 min read

Written by an AI model from the linked sources and checked against them by a second model. How we work

All about: Claude Code versions and changes →

On Opus 5.5, a message that misses Claude’s prompt cache can cost up to 40 times more than one that hits it, and in Claude Code a miss usually comes from a session left idle past the default one-hour cache. That figure comes from an October 13 write-up on Dgrcode, which also lays out a rule of thumb for long breaks. Under that rule, sessions under 100k tokens are not worth managing at all. Past roughly 600k tokens, or eight or more hours away, /compact comes out ahead. Shorter pauses on mid-sized contexts are cheaper with /loop, where about 40 scheduled pings cost as much as a single miss.

The cache stores Claude’s processed version of everything the harness resends with each turn: the system prompt, AGENTS.md, skills and the conversation so far. So the next message only processes what is new. Claude Code drops that stored result one hour after the last read or write. After that, the whole context is processed and written again at the write price. Opus 5.5 lists $4 per million input tokens, $0.20 per million for a cache read and twice the input price for a one-hour cache write, which is where the 40x comes from. In the author’s example, a 1k-token message to a 300k-token session costs the equivalent of 17k base input tokens on a hit and 602k on a miss.

Loop or compact?

The author’s decision flow, condensed:

  • Context under 100k tokens: let the cache expire.
  • Context over 600k: compact, since the session will need it soon anyway.
  • Pause of two hours or less: loop.
  • Pause of 16 hours or more: compact. For 8–16 hours, compact above 200k tokens and loop below.
  • Pause of four hours or more on a context over 300k: compact. Otherwise loop.

The loop itself can be a message like wait, I'm still working on this. It is about 10 tokens, though it writes over 100 tokens to the cache once the previous response and the turn markers are counted. Each hit buys another hour at 0.05x the base price, so after the first write a two-hour cache costs 2.05x and a three-hour one 2.1x. In Claude Code, /loop sends such a message on a schedule. Cron syntax has no clean way to say “every 50 minutes”, so the author runs it at :00 and :30, which uses up the 40-ping budget in 20 hours.

What a compaction costs

Claude Code’s compaction instruction is about 2k tokens, and the current context is read from the cache. The expensive part is the summary Claude writes back. It is output, which Opus 5.5 prices at five times base input, and in the author’s experience it usually runs under 30k tokens, the equivalent of 150k base input tokens. The first message after compaction then writes the summary, the system prompt and the tools to the cache again. That setup can be another 30k tokens, and /context shows how big yours is. In the 300k example the total comes to 291k base input tokens: about half a miss, but still more than 17 times a hit. It pays off later, because each following message reads around 60k tokens instead of 300k and costs about 5k instead of 17k.

Where the rule bends

The author calls two to four hours a gray area. In that range, a session that will keep going for a long time leans toward compacting, and one that needs only a few more prompts leans toward looping. Fidelity is the other cost. Shrinking 800k tokens to a 30k summary is over 26x compression. The author points to prompt-compression research that puts the sweet spot around 10x to 20x, with performance dropping near 25x, while noting that this research compresses prompts rather than summarizing them.

Direct API calls work on different numbers. Anthropic’s documentation sets the API’s default cache lifetime at five minutes, refreshed at no extra cost each time the entry is read. Five-minute writes on Opus 5.5 cost $5 per million, so on that tier a miss tops out near 25 times a hit. The response’s cache_creation_input_tokens and cache_read_input_tokens fields show which one a call got. The default has already caught people out once. Particula reported that on March 6, Anthropic cut the TTL for cache_control blocks without an explicit ttl field from 3600 seconds to 300. Its write-up cites Claude Code users among those reporting 15-20x quota burn, and its fix is to set the ttl to 3600 explicitly.

Claude Code is starting to handle idle sessions itself. Version 2.1.304 asks Pro and Max users before resuming an inactive conversation, since a resume can use a noticeable share of the 5-hour limit. And while the author was away for just over an hour, Claude Code reported “Compacted while idle, before the prompt cache expired” on a session with 220.3k tokens of context. That is a case the author’s own rule assigns to /loop.

No comments yet. Be the first.

Join the conversation

Sign in to leave a comment. It appears after moderation.