Feature request: Pre-compaction hook and warning before automatic context compression
Summary
When the context window fills up, automatic compaction kicks in with no warning and no opportunity to preserve important information beforehand. A pre-compaction hook or warning would let users (or automation) save critical context before it gets compressed.
Problem
- Auto-compaction happens silently — no heads-up, no chance to act
- Users lose detailed inputs, decisions, and specifics they may need later
- The only workaround is manually running
/compactbefore it happens, which requires guessing when context is getting full
Proposed Solution
One or more of:
pre-compacthook — fires before auto-compaction, allowing users to run custom scripts (e.g., save user inputs to a file, dump key context to memory)- Context usage warning — notify at ~80% capacity: "Context getting full — want to save anything before compaction?"
- Preserve user inputs by default — during compaction, prioritize keeping user messages (inputs) verbatim over assistant outputs, since outputs are reproducible given the same inputs but user intent is irreplaceable
Rationale
Inputs have higher information entropy than outputs — a user's message is unique and unpredictable, while the model's response is largely derivable from the input. Compressing outputs more aggressively while preserving inputs would improve post-compaction quality with minimal cost. And if something is lost, re-running from preserved inputs is cheap and getting cheaper as models improve.
🤖 Generated with Claude Code
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗