How to turn off or retune Claude Code's idle compaction
New in the Claude Code 2.1.299 changelog: if you leave a long conversation open in the terminal and step away, Claude Code compacts it shortly before its one-hour prompt cache expires. Your next message then sends a summary instead of the whole conversation, so you don't pay to reprocess everything after the cache is gone. A compacted conversation shows Compacted while idle, before the prompt cache expired.
It's on by default when all of these hold:
- Interactive terminal session
- The conversation is on the one-hour prompt cache TTL
- Claude Code can fetch feature flags from Anthropic
- Context has reached 200,000 tokens
- About 54 minutes have passed since the last request, and your computer is awake then
Change the token threshold with an environment variable. Values below 100,000 are raised to 100,000.
export CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=150000
To keep the full conversation instead of a summary, turn it off in settings.json:
{
"idleCompaction": false
}
The key and the variable need v2.1.290 or later. DISABLE_AUTO_COMPACT turns idle compaction off along with auto-compaction. After compaction, earlier details survive only as a summary.
Sources
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.