[FEATURE]

Open 💬 0 comments Opened Jul 13, 2026 by eatsranker

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Summary
Compaction currently has exactly two triggers: a user typing /compact interactively, or the automatic threshold near the context limit. There is no way for the agent, a hook, a schedule, or an idle timer to initiate it. At least six open feature requests ask for some version of this, each with near-zero votes, while the symptom of the missing feature; usage limits evaporating after any break longer than the cache TTL, sits in bug reports with hundreds of reactions. This issue consolidates them and argues they are one feature.

The discovery path hides the demand
Subscription users do not see a bill. What they see is a huge chunk of their session limit disappearing on the first message after lunch, with nothing in the UI indicating why. The actual cause: the prompt cache TTL (1 hour on subscription) expired, and that first message re-wrote the entire transcript to cache at 2x base input, versus 0.1x for warm reads - roughly a 20x cost for that turn on up to 1 million tokens context, recurring every break, every usage-limit lockout, every day.

Almost nobody traces that chain. The ones who stop at the symptom file (or upvote) issues like:

#16157 "Instantly hitting usage limits with Max subscription" (700+ reactions)
#38335 "Max plan session limits exhausted abnormally fast" (500+ reactions)
#46829 "Cache TTL silently regressed from 1h to 5m, causing quota and cost inflation" (340+ reactions, closed as regression-fix, but note the vote count for a cache-TTL issue)
The few who research all the way to the TTL each file a separate, differently-worded feature request that never accumulates votes:

#66246 Programmatic/agent-initiated compaction (refile after #52002 was auto-closed as stale)
#71803 Let the agent trigger /compact itself
#19877 Claude-invocable conditional /compact for automated workflows
#63807 Claude-initiated compaction: Compact-tool proposal, plus a ghost-text workaround
#66115 Auto-compact on idle timeout, explicitly to prevent cache expiry cost
#76523 Execute queued built-in slash commands at end of turn (queue /compact mid-run, fire at the natural break)
#75837 Scheduled "/compact" silently no-ops (a regression, scheduled prompts used to parse slash commands, so this feature briefly existed by accident)
Adjacent evidence of appetite for compaction control: #6689 (disable auto-compact), #14258 (compaction content control), #17428 (file-backed compact summaries, 100+ reactions).

Why no current mechanism covers it
Skills cannot invoke /compact: the docs list /init, /review, /security-review as Skill-tool-accessible built-ins; /compact is explicitly not among them.
/compact does not run in -p (print) mode, so no external process, cron, or Stop-hook side channel can compact a session.
Hooks can only react to compaction (PreCompact/PostCompact); hook output cannot trigger slash commands or tool calls.
The VS Code extension, desktop app, and CLI maintain separate session stores, so even a hypothetical CLI-side compaction cannot reach an extension session.
Critically: compaction is itself an API call. During a usage-limit lockout it cannot be run at all, and by the time the window resets the cache is long dead. Whatever fires compaction has to fire while the session is still active which is precisely when only the agent, not the user, is present.

Proposed Solution

The ask
Any one of these resolves the whole cluster:

A cache that lives as long as the session ... or
A model-invocable Compact tool (optionally accepting focus instructions), so an agent can compact at a natural break point - end of a todo list, end of a phase - exactly like a user would.
Queued /compact executes at end of turn (#76523): the user types it while the agent works; it fires at the boundary.
A configurable idle-timeout auto-compact (#66115): compact after N minutes of inactivity, before the cache TTL expires.
A hook JSON directive (e.g. triggerCompact: true from a Stop hook), mirroring the existing additionalContext pattern.
Even a documented statement of which of these is the intended direction would let the community stop filing fragments of the same request.

Alternative Solutions

_No response_

Priority

High - Significant impact on productivity

Feature Category

API and model interactions

Use Case Example

Ideally, I would grant Claude a skill to activate the compact skill after reaching a significant break point or completing a significant task where that context might have significant value in forming the way follow on tasks might be performed.

Additional Context

_No response_

View original on GitHub ↗