If your AI session holds more than about 70,000 tokens, compact it before any break longer than its cache lifetime. Otherwise your first message back rewrites the whole conversation into the cache, at up to 20 times the price of reading it.

This is for anyone running long sessions in Claude Code or building agents on a model API. The prices are Claude Opus 5 list prices as of October 2026, and the habits come from replaying our own team's Claude Code history.

See it in actionComing back cold costs 20 times more
Return to a 300K-token session while the cache is warm and the next message costs $0.15. Return after it expires and the rewrite costs $3.00. Illustrative example. Use the playback controls or the thin timeline at the top to explore.

In short:

  • Lifetime counts from the start of a request, not its end.
  • Returning cold to 300K tokens costs $3.00 instead of $0.15.
  • In our replay, main sessions cost 12% less on the 1-hour cache.
  • In our replay, subagents cost 11% less on the 5-minute cache.

A cache entry expires when unused

Prompt caching keeps the processed start of your prompt so the next request can reuse it cheaply. The time to live, or TTL, is how long an entry lasts without use. On the Claude API the default is 5 minutes, refreshed for free on every read. A 1-hour option exists, per Anthropic's prompt caching docs.

The clock starts at the start of a request. Anthropic gives an example: if a response streams for 4 minutes, the next request must start within about a minute.

Other providers differ. OpenAI's GPT-5.6 and later keep a prefix at least 30 minutes after its last use, per the OpenAI prompt caching guide. Gemini's implicit caching is managed by Google.

Coming back cold costs 20 times more

A cold return writes the whole context again instead of reading it. On Opus 5, a read is $0.50 per million tokens and a 1-hour write is $10.

Your next message Billed as Price per million Cost at 300K
Cache still warm Cache read $0.50 $0.15
Cache expired 1-hour cache write $10.00 $3.00

It repeats on every return. If you work in bursts with long gaps, each burst starts with that charge.

Compact first when context is above 70K

Compacting means the model summarizes the conversation and continues from the summary. It costs a read of the context, the summary's output and a write of the new short prefix. On your return you write that short prefix once more.

In our study, compacting first was cheaper whenever context C met this test:

C × W > C × R + S × O + 2 × P × W

Here W is the write price, R the read price, O the output price, S the summary length (12,000 tokens) and P the context after compaction (about 18,000). With 1-hour Opus 5 prices, the line falls near 70,000 tokens. With 5-minute write prices, near 90,000.

For the 300K example, compacting first costs about $0.81 in total, against $3.00 for a cold return.

The 1-hour cache suits people, not loops

A 1-hour write costs 60% more than a 5-minute one, 2 times input against 1.25 times. It wins only if you often pause between 5 and 60 minutes.

We replayed every gap between calls in our history to check, in a simulation priced at Opus 5 API list prices. Main sessions are top-level conversations, interactive or background. Subagents are the helpers they spawned.

Session type Gaps of 5 to 60 min Cheaper TTL
Main sessions 2.2% 1 hour, by 12%
Subagents 0.4% 5 minutes, by 11%

Only 2.2% of main-session gaps fell in that range. But they happened on big contexts, so avoiding the rewrite outweighed the dearer writes.

Claude Code already splits TTLs this way

Claude Code uses the 1-hour TTL for the main conversation on a Claude subscription within its included usage. Subagents, workflows and compaction get 5 minutes, per Claude Code's prompt caching docs. On an API key or usage credits, everything defaults to 5 minutes.

You can override both with the promptCacheTtl and subagentPromptCacheTtl settings. On an API key, set promptCacheTtl to 1h if you pause often. The same docs describe idle compaction, which can compact an idle conversation shortly before a 1-hour cache expires.

GrowApps compacts before you come back

In GrowApps, you test the preview between messages, so the cache can expire. Our production agent therefore checks right after each reply, while the cache is warm. If the next turn would start above about 77,000 tokens, the same model writes a summary in the background, reading the conversation at the cached rate.

Try this before your next break

Look at your session's context size before you step away. In Claude Code, the /context command shows it. Above about 70,000 tokens, run /compact first, and say what to keep, like /compact keep the failing test output.

Frequently asked questions

Does an open tab keep the cache warm?

No. The cache lives on the provider's servers and expires when no request arrives. An open terminal or browser tab sends nothing.

Is 70K the right line for every model?

No. It depends on each model's write, read and output prices. Put your model's prices from the Anthropic pricing page into the formula above.

Sources and further reading