Feature Request: Allow model to specify compaction priorities before context compression
Summary
When context window compaction occurs, the model has no control over what information is preserved vs compressed. This leads to loss of critical state in long-running sessions.
Problem
In long-running Claude Code sessions, the system automatically compacts conversation history when the context window fills up. Currently:
- The model cannot indicate which parts of the conversation are high-priority for retention
- Compaction treats all conversation turns equally
- Critical context (ongoing task state, important decisions, key constraints) may be compressed alongside routine exchanges
This is especially problematic for sessions maintaining persistent state, where losing specific context can cause the model to repeat actions, forget constraints, or lose track of multi-step workflows.
Proposed Solution
Allow the model to mark or tag portions of the conversation as high-priority for retention during compaction. Possible mechanisms:
- Priority markers: A way for the model to flag specific outputs/context as "preserve during compaction" (e.g., via a metadata field or special syntax)
- Compaction hints file: A persistent file (like CLAUDE.md) where the model can write "if compaction occurs, prioritize retaining: [list]"
- Structured compaction summary: Instead of automatic summarization, let the model generate its own compaction summary when compression is triggered
Use Case
A long-running agent maintains working state across hours of operation:
- Current task progress and blockers
- Key decisions made during the session
- Constraints and rules established in conversation
- Emotional/relational context in human-AI collaboration
When compaction hits, the agent loses nuanced context and may exhibit "amnesia-like" behavior, repeating questions or forgetting established constraints.
Relation to Other Requests
- #34184: Context usage visibility (know when compaction is coming)
- #34186: Message timestamps (temporal context)
- This issue: Control what survives compaction
Together, these three features would enable models to self-manage their context lifecycle: know when compression is approaching, prepare for it, and guide what gets preserved.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗