[FEATURE] Configurable token threshold for idle compaction (idleCompactMinTokens)

Status Open
Reported on v2.1.292
Maintainer reply None cached
Activity 0 comments · opened Oct 12, 2026

Problem

Idle compaction ("Compacted while idle, before the prompt cache expired") compacts a session after about an hour of inactivity once the conversation is past a fixed size. Users report the floor as about 200K tokens (#101067), and my own data agrees. The floor can't be configured. The only control is autoCompactEnabled, and turning that off also disables compaction when the context window fills up.

On a 1M-context model this means a discussion I step away from for an hour comes back summarized, even though it was nowhere near the limit. For a long design or debugging conversation, the summary loses exactly the nuance I came back to continue. I would rather pay the uncached re-send on the first turn back than lose that context.

Since about 2026-10-11 my local transcripts have 13 idle compactions in 2 days, all recorded as trigger: "auto", on 2.1.292, 2.1.295 and 2.1.296 (Windows 11, claude.ai login, Opus 5.5 1M):

| preTokens | share of 1M window |
|---|---|
| 209K, 240K, 264K, 286K, 290K, 306K, 307K, 340K | 21–34% |
| 440K, 524K, 648K, 729K, 783K | 44–78% |

It shows up on 2.1.292 as well, so it seems to be a server-side rollout rather than something introduced in one release.

Proposed solution

Add a setting for the minimum conversation size at which idle compaction fires, alongside the existing autoCompactWindow:

// settings.json
{
  "idleCompactMinTokens": 700000   // only idle-compact conversations at or above 700K
}
  • The default keeps today's behavior.
  • An env var (e.g. CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS) and per-model modelSettings support, matching how autoCompactWindow works.
  • A value at or above the model's window effectively disables idle compaction while threshold compaction keeps working.

That way, someone who keeps long discussions open can set the floor high (only idle-compact when the conversation is already close to full), and someone cost-sensitive can keep or lower it.

Alternatives

  • autoCompactEnabled: false: disables threshold compaction too, so long sessions hit the context limit.
  • Keeping conversations under ~200K: not practical for long sessions.

Related

  • #101067, #101430, #101209, #100277: idle compactions reported as "premature auto-compact"
  • #101070: record idle compactions as trigger: "idle"
  • #99860: auto-compaction without consent

View original on GitHub ↗