claude-code - 💡(How to fix) Fix Feature: Selective context compaction — allow discarding context before a checkpoint

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

The only workaround today is to start a fresh session, which breaks workflow continuity.

RAW_BUFFERClick to expand / collapse

Problem

When running a context-heavy task (e.g., a large PR review) mid-session after a long conversation, the compactor treats all prior context equally. It may summarize away the new, important context (like a PR diff being analyzed) just as readily as the older, irrelevant discussion that preceded it.

The only workaround today is to start a fresh session, which breaks workflow continuity.

Proposed Solution

Allow users (or tools) to set a context checkpoint — a marker that tells the compactor: "everything before this point can be aggressively dropped or heavily summarized; prioritize retaining everything after it."

Possible interfaces:

  • Slash command: /checkpoint — marks the current point in conversation. When compaction triggers, context before the checkpoint is discarded first.
  • Tool API: A mechanism for tools to signal "this is a fresh unit of work — prior context is low priority" when they start.
  • Auto-checkpoint on skill invocation: Automatically treat skill boundaries as soft checkpoints.

Use Case

  1. User has a long session — debugging, exploring code, chatting.
  2. User invokes a context-heavy task that needs significant window for diffs, file reads, and analysis.
  3. Today: compaction fires and may lose the task context. User has to start a new session.
  4. With this feature: the invocation acts as a checkpoint, and the compactor preferentially drops pre-checkpoint conversation.

Additional Context

This would benefit any workflow where users switch tasks mid-session. The ability to say "I’m done with that topic, prioritize the new one" would make long sessions much more usable.

Related but distinct from existing compaction issues (#50888, #51207) which focus on when compaction fires — this is about what gets compacted.

extent analysis

TL;DR

Implementing a context checkpoint feature, allowing users or tools to mark a point in the conversation where context before it can be aggressively dropped or summarized, is the most likely fix.

Guidance

  • Introduce a /checkpoint slash command that users can invoke to mark the current point in conversation, indicating that context before this point is low priority.
  • Develop a Tool API to enable tools to signal the start of a fresh unit of work, allowing them to set a checkpoint programmatically.
  • Consider implementing auto-checkpointing on skill invocation, treating skill boundaries as soft checkpoints to prioritize retaining context after the invocation.
  • Evaluate the impact of this feature on existing compaction issues (#50888, #51207) to ensure it does not introduce new problems.

Example

/checkpoint

This simple command could be used by users to mark a checkpoint in the conversation.

Notes

The proposed solution focuses on what gets compacted, rather than when compaction fires, which is a distinct aspect of the compaction mechanism. The feature's effectiveness will depend on the specific implementation and user behavior.

Recommendation

Apply the workaround by implementing the context checkpoint feature, as it addresses the core issue of prioritizing new context over old, irrelevant discussion, and provides a flexible solution for users and tools to manage context.

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