← All Main Courses

Why Claude Code started compacting your idle chats

🛠️ Deep dive · Oct 22, 2026 · ~5 min read

The short version

Long Claude Code chats can tidy themselves up. Leave a 200K+ token terminal session idle ~54 minutes and it can compact before the one-hour prompt cache dies — so your next message doesn’t re-chew the whole transcript. Tune with CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS or disable with "idleCompaction": false.

Source: Claude Code v2.1.299 release notes

What shipped

Since Oct 14, 2026, Claude Code compacts long terminal chats you walk away from: after roughly 54 minutes idle on chats above ~200K tokens, the session can compact before the hour-long prompt cache expires (Claude Code v2.1.299 release notes).

Independent weeklies picked it up the same day (e.g. DevAgentRadar brief (Oct 15, 2026)).

The same week brought related context hygiene: CLAUDE_CODE_DISABLE_FILE_MENTIONS (paths without dumping file guts) (Claude Code v2.1.299 release notes) and OTel splitting cache writes into cache_creation_5m_tokens / cache_creation_1h_tokens (Claude Code v2.1.300 release notes).

Idle compaction is the headline; the metrics and mention controls are the side dishes teams will actually wire into dashboards.

Why the one-hour cache matters

Prompt caching discounts repeated prefixes. If the cache expires, the next turn re-processes the transcript — latency and bill go up. Compacting before expiry trades some history fidelity for a warm cache.

Anthropic’s platform docs cover context windows and caching behavior at a product level (context windows); the Claude Code release notes are the authority for the terminal-specific idle timer.

For agentic coding, marathon sessions are normal: a refactor that spans lunch, a debug loop that waits on CI, a long tool-using plan. Without idle compaction, walking away near the cache boundary is how you come back to a cold prefix and a slow first message.

With it, the runtime babysits the boundary for you — on purpose, with knobs.

This week was less “smarter model,” more “you can actually walk away.” Idle compaction is babysitting for marathon sessions.

We are not claiming measured dollar savings on your account. Read the release notes and your own usage dashboard. Cache economics depend on model, plan, and how often you actually cross the TTL.

Mechanics and thresholds

From the release notes (Claude Code v2.1.299 release notes):

  • Idle window: roughly 54 minutes of idle time before compaction can fire.
  • Size gate: sessions around 200K+ tokens are in scope for the default behavior.
  • Goal: compact before the one-hour prompt-cache TTL elapses, so the next user message can reuse a warm prefix instead of re-ingesting the full transcript.

Downstream effect: compacted history is not a bit-perfect transcript. If your workflow depends on scrolling back through every tool call for audit or demo, treat compaction as a fidelity trade. If your workflow depends on snappy resumes after coffee, treat it as a latency/cost trade that usually wins.

Observability: the same train splits cache-write metrics into 5m vs 1h buckets in OTel. That is how you tell whether idle compaction is doing real work versus whether you are still paying cold-prefix taxes (Claude Code v2.1.300 release notes).

Wire those series before you argue about savings in a sprint review.

Blast radius for teams

Surface Why it matters What to check
Solo power users Overnight terminals stop waking up cold Personal default: leave compaction on
Pairing / demos Full transcript may be part of the show Disable for demo profiles
CI / unattended loops Compaction timing vs long jobs Confirm idle thresholds before overnight runs
Observability Cache write buckets change meaning Update dashboards for 5m / 1h split
Compliance / retention Compaction changes what remains in-session Document expectations with security

Idle compaction is a client/runtime behavior for Claude Code terminals, not a silent change to Anthropic’s cloud retention policies. Do not conflate "session compacted locally" with "logs deleted in the vendor console." Your logging stack remains your logging stack.

Migration notes and ops checklist

Rollout tips grounded in the release notes and adjacent tooling the same week:

  1. Inventory long-lived terminals. Who leaves 200K+ sessions open overnight? Those users feel this first (Claude Code v2.1.299 release notes).
  2. Pick a default per profile. Personal marathon coding: on. Customer demos / training recordings: off via "idleCompaction": false.
  3. Tune before you disable. Raise CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS if you want fewer compactions without giving up the babysitter entirely.
  4. Update runbooks. If on-call pastebacks assume a full scrollback, say so. Compaction is not a bug; it is a documented trade.
  5. Align hooks and deny/ask policy. Unattended loops that used to freeze waiting for a human should fail closed — same class of failure as idle sessions waiting on someone who walked away.
  6. Dashboard the new OTel fields. Confirm cache_creation_5m_tokens / cache_creation_1h_tokens land in your collector before you declare victory on cost (Claude Code v2.1.300 release notes).
  7. File mentions. If @ paths are bloating context, try CLAUDE_CODE_DISABLE_FILE_MENTIONS so mentions stay paths, not file bodies (Claude Code v2.1.299 release notes).

Controls and escape hatches

From the release notes and weeklies citing them:

  • CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS — raise the threshold so smaller sessions never compact
  • "idleCompaction": false — turn it off for a profile or machine
  • CLAUDE_CODE_DISABLE_FILE_MENTIONS — @ paths without dumping file bytes into context

Chef’s pick: keep idle compaction on for personal marathon sessions; disable it in demos where you need the full transcript on screen. Tune the token threshold before you kill the feature — most teams want the babysitter, not a colder cache.

Sources

Show all 5 sourcesShow fewer