claude-code - 💡(How to fix) Fix /compact -n <lines>: partial compaction retaining recent conversation [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#58749Fetched 2026-05-14 03:40:29
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1
RAW_BUFFERClick to expand / collapse

Problem

When context approaches limits mid-session, the only option is full compaction which summarizes ALL prior messages. This loses:

  • Recent system state (tool outputs, file changes, running processes)
  • Active debugging context that was just established
  • Multi-step workflow progress that hasn't been committed yet

Users often notice context pressure while actively working, but can't compact without losing the last few exchanges that contain critical state.

Proposed Solution

/compact -n 5000 — compact messages BEFORE the last N lines, retain the last N lines verbatim.

Behavior:

  1. Lines 1 to (total - N): summarized into compaction summary
  2. Lines (total - N + 1) to end: kept as-is
  3. Result: summary + recent conversation, within context budget

Use Cases

  • Long debugging session: keep recent errors/fixes, compact old exploration
  • Multi-agent orchestration: keep recent agent results, compact earlier rounds
  • Extended pair programming: keep current task context, compact yesterday's work

Prior Art

The existing /compact already produces a summary and truncates. This extends it with a retention window, similar to how log rotation keeps recent entries while archiving old ones.

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