Claude Code compacts idle conversations before the prompt cache expires
Claude Code v2.1.299 (October 14, 2026) added idle compaction. If you leave a large conversation alone, Claude Code compacts it shortly before the one-hour prompt cache expires. Your next message then sends a summary instead of reprocessing the whole conversation.
When it applies
Idle compaction is on by default. A conversation qualifies when all of these hold:
- You are in an interactive terminal session.
- The conversation is on the one-hour prompt cache TTL.
- Claude Code can fetch feature flags from Anthropic.
- The context has reached the token threshold. The default is 200,000.
- About 54 minutes have passed since the last request, and your computer is awake at that point.
When you come back, the conversation shows Compacted while idle, before the prompt cache expired.
Turn it off
Set idleCompaction to false in any settings file:
{
"idleCompaction": false
}
The key requires v2.1.290 or later. On an earlier version, which ignores it, turn off autoCompactEnabled instead. DISABLE_AUTO_COMPACT turns idle compaction off along with auto-compaction.
Change the threshold
Set CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS to the context size a conversation must reach before idle compaction applies. Use a positive whole number. Values below 100000 are raised to 100000.
{
"env": {
"CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS": "150000"
}
}
A conversation on a 200K window auto-compacts before it reaches 200,000 tokens, so the default threshold can miss it. The docs use 150,000 as the example that lets those conversations qualify.
What this means
If you step away from a big session, expect it to be shorter when you return. If you rely on exact earlier output staying in context, turn the key off. The manual /compact command is unaffected either way.
Sources: Claude Code changelog, 2.1.299 and the idleCompaction settings reference.