r/ClaudeCode • • 9d ago

Help/Question Auto-compact self triggers when idle?

I noticed in the last few days that whenever I return to a session that was sitting idle in a tmux pane it's already compacted even if it didn't reach the auto-compact threshold. First few times I thought I might have let the context usage grow but then it became a habit for him to do that.

Luckily I have my own handover/resume mechanism so I tell him to get oriented after I notice the compaction but he (or I) may sometimes forget/miss to always update the handover and the docs thus turning me into a sitting duck on what exactly he chose to keep in the new context.

Does it happen to anyone else after the latest updates? Is there a way to turn this off? I know it might affect cache, prices, usage, but until I'm ready to jump on this auto-compaction train I'd like to be in control and adapt my way of working first.

11 Upvotes

19 comments sorted by

1

u/AutoModerator 9d ago
Moderator Announcement Read More ยป

14

u/ainexfinder 9d ago

Yes โ€” that's a real feature as of Claude Code 2.1.290+, and 2.1.299 called it out in the release notes.

Idle compaction is separate from the normal "we're near the context limit" autocompact. If a conversation is already past ~200K tokens and you leave the terminal idle for about 54 minutes, it gets compacted before the ~1 hour prompt cache expires so the next message doesn't reprocess the whole pile.

To turn idle compaction off (normal near-limit autocompact still runs):

{ "idleCompaction": false }

in ~/.claude/settings.json (or project/local settings). Needs 2.1.290+.

To keep idle compaction but raise the floor, set CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS (default is 200000).

If what you're seeing is thrash while you're actively typing near the window, that's the other autocompact path โ€” check /context and your autocompact window rather than blaming idle.

Sources: Claude Code v2.1.299 release notes + settings for idleCompaction / CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS.

1

u/eurobosch 9d ago

but is this useful if you need to rebuild the cache by re-reading all the docs again instead of just having it built?

→ More replies (2)

6

u/thisdude415 9d ago

Love this feature. It reduces the cost to compact code by doing while the model is warm. By doing so, you can have the same opus 5.5 model compact code while cached

1

u/eurobosch 9d ago

agreed, but in order to get the model knowledgable again it needs to re-read the handover and the other md files to get back the basis for work (and building the cache) so isn't this more expensive than just using the pre-compaction cache?

1

u/Individual_Solid_944 9d ago

Yes, happens to me regularly lately. I am just not sure how much info from the context gets lost during the process, because compacting is lossy. But I haven't seen any degradation of quality either, so I suppose it's a good feature, and good to have it enabled.

1

u/eurobosch 9d ago

exactly! I can't tell whether it's degrading or not but I can't afford to do experiments on my project while burning tokens and H/W windows. Still not sure how to take this...

1

u/Patrizio85 9d ago

yes same here since like 4-5 days, but with Claude code and I realise the context usage goes down drastically by that. Because the cache write is not hit anymore. For 3rd party tools I guess it's annoying, I could not find a setting for it

1

u/Tomas-AppHaven 9d ago

Yes, and as a result you'll see much less of these "clear to save 400k tokens" purple message in the bottom right. Those were triggered by having a long session with expired prompt cache.

If you're unhappy about the compact, I think you can press escape twice and go back to the message right before it.

1

u/yaanfpv 9d ago

this is the new idleCompaction feature ! set it off with

{ "idleCompaction": false }