PreCompact hooks not triggered during session-memory-aware compaction
Description
When auto-compaction uses the session-memory-aware path (which builds compacted messages from the session memory summary file), the PreCompact hooks are not executed. This means any PreCompact hooks configured by users are silently skipped.
Expected Behavior
PreCompact hooks should run before any compaction occurs, regardless of whether the compaction uses the session memory path or the regular compaction path.
Current Behavior
-
Regular compaction (manual
/compactor fallback): PreCompact hooks run ✓ - Session-memory-aware auto-compaction: PreCompact hooks are skipped ✗
Impact
Users who rely on PreCompact hooks for tasks like:
- Logging compaction events
- Saving context before compaction
- Custom pre-compaction processing
...will have their hooks unexpectedly skipped when session memory compaction is used.
Suggested Fix
Call the PreCompact hook execution function before the session-memory-aware compaction path, similar to how it's called in the regular compaction function.
Thanks for the great work on Claude Code!
Found 1 possible duplicate issue:
- https://github.com/anthropics/claude-code/issues/13572
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
This issue has been automatically closed as a duplicate of #13572.
If this is incorrect, please re-open this issue or create a new one.
🤖 Generated with Claude Code
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.