Claude Code Idle Compaction: Why It Kicks In After 54 Minutes
Claude Code idle compaction is a terminal feature added in version 2.1.299, released on October 14, 2026. If a conversation of 200K tokens or more sits idle for about 54 minutes, Claude Code compacts it before the 1-hour prompt cache expires, so the next message you send doesn't have to reprocess the entire conversation. It is on by default, you can tune the threshold with an environment variable, and you can turn it off in settings. Everything below is accurate as of October 2026 and comes from the official Claude Code changelog; defer to the official docs for details. cdnping is a free network observability site, and the in-site links here are just further reading.
What does idle compaction actually do?
The changelog describes 2.1.299 this way: conversations of 200K+ tokens that have been idle for about 54 minutes are compacted before the one-hour prompt cache expires.
To see why, you need to know what the prompt cache does. Every time you send a message, Claude Code sends the whole conversation to the model as context. On a cache hit, that prefix is billed at the lower "cache read" price and is also faster. Once the cache expires, the next message has to write the whole context back into the cache at the more expensive "cache write" price. The longer the conversation, the more that reprocessing costs.
So the logic is: the cache is about to expire anyway, so rather than make you pay again for 200K+ tokens when you come back, Claude Code compacts the conversation into a summary while the cache is still warm, and the rest of the session continues on a much smaller context. The trade-off is that details get lost in the summary, which I cover below.
How big is the gap between cache reads and writes?
As an example, take the prices on Anthropic's official model release page (per million tokens; check the official pricing page for what it currently shows):
| Item | Price |
|---|---|
| Input | $4 |
| Cache write | $5 |
| Cache read | $0.20 |
This is only an example. That page doesn't split cache writes into 5-minute and 1-hour tiers, so check the official pricing page for the 1-hour cache price.
A rough calculation with these numbers: a 200K-token context costs about $0.04 to read on a cache hit. After the cache expires, writing it back at the listed cache-write price costs about $1 (the 1-hour cache write price may differ). That is roughly a 25x difference. Subscribers see usage limits rather than dollars, and how limits convert is something to confirm in the official documentation, but this is broadly why the first message after a long session's cache expires tends to eat more of your allowance. For how to place cache markers and reconcile your bill, see our guide How to use Claude prompt caching to save money.
How do I adjust or turn it off?
The changelog gives three ways:
- Change the threshold: set the environment variable
CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENSto override the default 200K-token minimum. For example,export CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=150000(the number is just an example). - Turn it off: put
"idleCompaction": falsein settings.json. - Menu toggle: 2.1.302 added an idle compaction switch to
/config. The exact option label may differ on your machine.
The changelog notes that both the threshold variable and the idleCompaction setting require v2.1.290 or later. Idle compaction itself arrived in 2.1.299, so run claude --version to check what you have.
When should I turn it off?
Idle compaction isn't a win in every situation. Use this checklist:
| Situation | Recommendation |
|---|---|
| Long session, resuming the same task after lunch or a meeting | Leave it on; it saves reprocessing the whole conversation |
| The conversation holds a lot that must be preserved verbatim (logs, exact error messages, long blocks of code) | Consider turning it off, or first write the key information into CLAUDE.md or a file yourself |
| Conversation is under 200K tokens | It won't trigger; ignore it |
| You often step away for a few minutes | Little effect; you never reach 54 minutes |
Compaction is lossy, and a summary can't keep every detail. If you come back and the model seems to have "forgotten" a convention, first check whether the conversation was compacted, then restate the convention or put it in a project file.
What other related changes shipped in the same releases?
- 2.1.300: The OpenTelemetry
api_requestevent gainedcache_creation_5m_tokensandcache_creation_1h_tokens, which split cache writes by 5-minute and 1-hour lifetime. Teams running their own usage monitoring can use these to see how much long-lived cache they are writing. - 2.1.301: When you switch to a model with a smaller context window and the conversation is too long for it, the original model summarizes the conversation first.
So switching to a smaller-window model may trigger a summarization, and that summarization is itself a model call.
Will I still run into other problems after compaction?
Compaction only addresses the cost of reprocessing after the cache expires. It doesn't change server-side state. If you hit overload or rate limits when you return, see Claude Code 529 Overloaded and idle compaction settings. If you suspect the service itself, /en/status/anthropic shows probe results for the Anthropic API endpoint. If responses feel slow, What to do when Claude Code is slow has a method for diagnosing it, and for how usage is counted, read Claude Max 5x vs 20x.
Model prices and caching rules change. Our /en/changes page tracks additions and removals on the official changelog and pricing pages, and there is an RSS feed you can subscribe to.