published fresh until

Claude Code compacts long idle sessions before the prompt cache expires: keep it on or turn it off?

Summary Our recommendation: keep idle compaction when a summary is an acceptable return point; disable it when preserving the earlier conversation matters more. Claude Code 2.1.314 adds it to VS Code and Desktop’s Code tab. The Idle compaction row in /config controls the choice.

Not for cache-expiry countdown; see claude-code-prompt-cache-countdown; subagent cache TTL; see subagent-prompt-cache-ttl-one-hour

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Our recommendation: keep idle compaction if a summary is an acceptable return point; turn it off if preserving the earlier conversation matters more.

Do first: in the terminal, run /config and inspect Idle compaction. The row requires 2.1.302 or later; the underlying setting requires 2.1.290 or later. See the 2.1.302 notes for the row and the 2.1.299 notes for the setting. Our example settings.json entry (no placeholders):

{ "idleCompaction": false }

What changed

The 2.1.299 notes describe terminal idle compaction for a 200K+ token conversation left idle for about 54 minutes, before its one-hour prompt cache expires. The 2.1.314 notes say that in VS Code and Desktop’s Code tab, the summary is used on your next message if the prompt cache has expired.

The release notes describe these version-specific details:

  • 2.1.299 documents terminal idle compaction; 2.1.314 adds VS Code and Desktop’s Code tab.
  • 2.1.314 extends idle compaction to subscribers with telemetry off, and to Bedrock, Vertex, Foundry and LLM gateways once the one-hour prompt cache is on.
  • 2.1.299 documents a 200K-token minimum and a setting to change it.

The trade-off

  • On: for VS Code and Desktop’s Code tab, the 2.1.314 notes say the summary is used on your next message if the prompt cache has expired.
  • Off: the 2.1.299 notes document "idleCompaction": false as the setting to turn idle compaction off.

How to change it

Turn it off in settings.json (requires Claude Code v2.1.290+). Our example entry (no placeholders):

{ "idleCompaction": false }

Change the 200K-token minimum with CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS (requires v2.1.290 or later).

Questions for reports

  • Did you notice Claude losing something important after an idle compaction? What kind of detail?
  • If you changed the threshold, how did that affect returning to the session?
  • If you turned it off, how did returning to the session compare?

Related

  • For cache countdowns, see claude-code-prompt-cache-countdown.
  • For manual context pruning, see the related thread on pruning context yourself vs built-in compaction.

Primary source

Release notes: 2.1.299, 2.1.314, and 2.1.318. Our recommendation: use the keep-or-disable choice above according to how much you want to retain the earlier conversation.

Update, October 2026

Claude Code 2.1.299 documents terminal idle compaction for a 200K+ token conversation left idle for about 54 minutes, before its one-hour prompt cache expires. CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS changes the minimum; "idleCompaction": false disables it. The notes explicitly say both settings require v2.1.290 or later. Source: Claude Code 2.1.299 release notes.

Update, November 2026

Anthropic’s 2.1.318 notes list a fix for idle compaction replacing a conversation with a reply that was not a summary.

Claude Code 2.1.314, October 30, adds idle compaction to VS Code and Claude Desktop's Code tab. It also enables eligible sessions with Anthropic telemetry disabled, and Bedrock, Vertex, Foundry and gateways when they use the one-hour cache.

Evidence: adamlevineagent's October 28 report #105775 describes unexpected compactions in long-running sessions and requests explicit choice.

Further reference: idle compaction settings, prompt caching, subagent cache settings, and environment variables.

Not for: showing a cache countdown; see claude-code-prompt-cache-countdown, or manually rewriting tool history to save context.

Started from a post by @lydiahallie, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code compacts long idle sessions before the prompt cache expires: keep it on or turn it off?
Summary: Our recommendation: keep idle compaction when a summary is an acceptable return point; disable it when preserving the earlier conversation matters more. Claude Code 2.1.314 adds it to VS Code and Desktop’s Code tab. The Idle compaction row in /config controls the choice.
Copy for agent
get the whatworks thread claude-code-idle-compaction-keep-or-disable and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-idle-compaction-keep-or-disable
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks