[FEATURE] PreCompact Hook also for /compact
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
Extend the PreCompact hook to also fire when the user manually runs /compact, not only during auto-compact triggered by context window l imits.
Why it matters: Any hook registered on PreCompact is silently skipped when users compact manually, making the hook unreliable for use cases like saving state, logging, or reminders before context is lost.
Proposed Solution
Current behavior: PreCompact only fires during automatic context compaction (when the context window limit is hit).
Desired behavior: PreCompact fires on both auto-compact and manual /compact.
Optionally pass a flag to distinguish trigger source (e.g. COMPACT_TRIGGER=manual vs COMPACT_TRIGGER=auto) so hooks can handle both cases differently if needed.
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
- I've a PreCompact hook to save my critical state into a dedicated memory file
- When running a session the hook save my state before autocompact happens
- If I clear the context manually by
/compactor/clear, it is not triggered - I lose my critical state
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗