claude-code - 💡(How to fix) Fix [FEATURE] Prompt user for approval before auto-compaction proceeds

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

Workaround (current)

Code Example

Context window near limit. Auto-compaction is about to run.
  [C]ompact now  |  [W]ait / cancel
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

Related Issues

  • #50015 — Auto-compaction fires without pre-compaction warning (regression)
  • #63003 — Add context window usage indicator and warning before auto-compaction

Those issues address notification. This request is specifically about user control — the ability to approve or cancel compaction before it occurs.

Problem Statement

When auto-compaction fires, it is irreversible. The user has no opportunity to decide whether compaction is appropriate at that moment. This is particularly disruptive in long multi-step sessions where compaction has been observed to:

  • Cause the model to misinterpret historical state as pending work (see #50015)
  • Silently discard context that is not faithfully reconstructed in the summary (#57636, #62925)
  • Delete the JSONL session log before the summary is verified (#63187)

A warning alone (as requested in #63003) does not solve the problem — a user who sees "compaction imminent" still cannot prevent it from happening.

Proposed Solution

Before auto-compaction proceeds, pause and present the user with an explicit approve/deny prompt:

Context window near limit. Auto-compaction is about to run.
  [C]ompact now  |  [W]ait / cancel

Expected behavior:

  • If the user approves, compaction runs immediately as it does today
  • If the user cancels, compaction is deferred and the user can choose to /compact manually, save notes, or end the session
  • The prompt should respect a configurable timeout with a safe default (e.g., auto-proceed after 30 seconds if no input, to preserve headless/non-interactive behavior)

Configuration option: A settings.json flag such as "autoCompact": "prompt" (alongside existing true/false) would allow users to opt into this behavior without affecting the default.

Workaround (current)

A PreCompact hook with matcher: "auto" can block automatic compaction entirely (exit 2), forcing the user to run /compact manually. This is functional but blunt — it disables auto-compaction completely rather than giving the user a per-session decision.

Why not just comment on #63003?

#63003 requests a visual indicator and warning. This request is for interactive control — the ability to stop compaction, not just observe it is coming. The two features are complementary but distinct.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING