Skip to content

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

Description

@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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions