[FEATURE] Interactive Context Compaction with Preview and User Approval

Resolved 💬 9 comments Opened Oct 31, 2025 by BenNewman100 Closed Jan 25, 2026

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

Currently, context compaction in Claude Code happens either automatically (with unpredictable results and potential loss of important context) or manually via /compact <instructions> (which requires extensive typing with no preview). Users have reported in multiple issues (#3274, #5385, #6004, #7961) that auto-compaction often loses critical context, gets stuck in infinite loops, or disrupts workflows with poorly chosen compaction strategies.
The current options each have significant drawbacks: auto-compaction can unexpectedly remove important context, while /compact <instructions> requires writing detailed instructions blindly without seeing what the compacted context will look like.

Proposed Solution

I propose an interactive, collaborative compaction workflow that triggers at a user-configurable threshold (e.g., 80% or 90% context capacity):

Proactive Trigger: When context reaches the configured threshold, Claude pauses and initiates an interactive compaction session
Claude Proposes Compaction Strategy: Claude analyzes the current context and proposes:

What would be preserved (critical ongoing work, recent decisions, active files)
What would be summarized (completed tasks, resolved issues, older discussion)
What would be removed (redundant information, outdated attempts)

User Review & Iteration: The user can:

Accept the proposal and proceed with compaction
Reject and provide feedback (e.g., "Keep the discussion about error handling", "The database migration context is still relevant")
Modify by requesting alternative strategies

Iterative Refinement: Claude adjusts the proposal based on user feedback and presents a revised strategy until approval
Configuration: Users can set their preferred threshold in settings:

json   {
     "context": {
       "interactiveCompactionThreshold": 85,
       "enableInteractiveCompaction": true
     }
   }

Alternative Solutions

Current auto-compact: Unpredictable, can lose important context, prone to infinite loops and corruption (#3274, #5385, #6004)
Manual /compact <instructions>: Works but requires extensive typing, no preview, no iteration
Better auto-compact prompts (#7961): Improves automatic compaction but still lacks user visibility and control

Priority

Medium - Would be very helpful

Feature Category

Interactive mode (TUI)

Use Case Example

Example Interaction:

⚠️ Context at 85% (170k/200k tokens)
⎿ I recommend compacting now. Here's my proposal:

📦 PRESERVE (65k tokens):
• Current task: Implementing OAuth flow
• Recent architectural decisions (last 15 messages)
• Active files: auth.service.ts, oauth.controller.ts
• Unsaved changes and working tree state

📝 SUMMARIZE (45k tokens → 8k):
• Completed: Database schema updates (compress to summary)
• Resolved: Import path refactoring discussion
• Tool outputs: Earlier test runs and lint results

🗑️ REMOVE (60k tokens):
• Failed attempt: Redis caching approach (abandoned)
• Outdated: Initial project structure discussion
• Redundant: Repeated file readings

Would you like to:

  1. Accept and compact
  2. Reject and modify (explain what to keep)
  3. Show detailed view

Additional Context

This proposal bridges the gap between fully automatic (no visibility) and fully manual (no preview) compaction. It leverages Claude's intelligence to propose good strategies while giving users final control. This would particularly benefit:

Long debugging sessions where context accumulates
Multi-step refactoring tasks
Complex feature implementations requiring extended context

Related issues: #92, #3274, #5329, #5385, #6004, #6066, #7961

View original on GitHub ↗

This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗