[FEATURE] Allow agents to auto-trigger /compact before context overflow
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
When working on image-heavy tasks (e.g., building PowerPoint presentations with many screenshots), the context window fills up and Claude becomes completely unresponsive — unable to process any input, including /compact or /clear.
This means all conversation context and work progress is lost. The user must force /clear and start over from scratch. The agent already knows when context is getting full, but has no way to act on it.
Proposed Solution
Allow the agent to programmatically trigger /compact when context usage is high. This could be:
- A tool like
compact()that agents can call directly - An automatic system-level trigger when context exceeds ~80% capacity
- A user setting:
auto_compact: truethat handles this transparently
The ideal experience: the agent detects high context usage, silently saves important context to memory, then auto-compacts — all without user intervention.
Alternative Solutions
Currently the agent reminds the user to manually type /compact, but this fails when:
- The user forgets or is busy focusing on the task
- The context is already full and Claude is unresponsive before the user can act
The agent also saves progress to memory files as a backup, but this is a lossy workaround — full conversation context is still lost.
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
- I ask Claude to help build a 30-slide PowerPoint presentation
- I send screenshots of existing slides for reference (5-10 images)
- After ~20 minutes of work, Claude becomes completely unresponsive
- I cannot type /compact or any command — the session is frozen
- I'm forced to /clear, losing all context and 20-30 minutes of work
- With auto-compact, Claude would detect high context usage at step 2-3, silently compress, and continue working without interruption
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗