claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

PreCompact hooks not triggered during session-memory-aware compaction

Open sfc-gh-mochen opened this issue 1 month ago • 1 comments

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!

sfc-gh-mochen avatar Dec 22 '25 22:12 sfc-gh-mochen

Found 1 possible duplicate issue:

  1. 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

github-actions[bot] avatar Dec 22 '25 22:12 github-actions[bot]

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

github-actions[bot] avatar Dec 26 '25 09:12 github-actions[bot]

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.

github-actions[bot] avatar Jan 02 '26 14:01 github-actions[bot]