Feature request: auto-compact on idle timeout to prevent cache expiry cost

Open 💬 3 comments Opened Jun 7, 2026 by ssobolev

Problem

When running a long operation (e.g. a test suite), users often step away from their Claude Code session. If they return after more than ~5 minutes, the prompt cache has expired. The full conversation context then has to be re-processed on the next turn, which is slower and more expensive than if the cache were still warm.

Requested feature

A configurable idle timeout that automatically triggers /compact before the prompt cache expires (i.e. before the ~5 minute TTL is up). This would reduce the context size proactively, so that when the user returns, re-processing the compacted summary is cheap — rather than re-processing the full conversation history cold.

Example configuration (sketch)

{
  "autoCompactOnIdleSeconds": 240
}

When the session has been idle for the configured duration, Claude Code would trigger compaction automatically — similar to how auto-compaction works when approaching context limits, but time-triggered instead of token-triggered.

Why this matters

  • Long CI/test runs are a common workflow where users step away
  • Cache expiry during these pauses silently increases cost and latency on return
  • Manual /compact before stepping away works but requires the user to remember to do it

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗