PreCompact hooks not triggered during session-memory-aware compaction

Resolved 💬 3 comments Opened Dec 22, 2025 by sfc-gh-mochen Closed Dec 26, 2025

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 /compact or 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!

View original on GitHub ↗

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