Bug
hook_precompact in hooks_cli.py returns {"decision": "block", "reason": ...} (line 216). This permanently prevents compaction in Claude Code — both manual (/compact) and automatic.
The intent is to remind the AI to save session content before context is lost. But decision: "block" prevents the compaction from ever happening, which defeats the purpose.
Reproduction
- Install mempalace with Claude Code hooks (Stop + PreCompact)
- Run
/compact in Claude Code
- Result: "Compaction blocked by PreCompact hook" — compaction never occurs
- Auto-compaction also never fires — same code path
Fix
In hooks_cli.py, hook_precompact function (~line 216):
# Before (blocks compaction permanently)
_output({"decision": "block", "reason": PRECOMPACT_BLOCK_REASON})
# After (injects save instructions without blocking)
_output({"systemMessage": PRECOMPACT_BLOCK_REASON})
systemMessage injects the save instructions into the AI's context so it can act on them, while allowing compaction to proceed. This is the correct Claude Code hook contract for "do something before this event" vs "prevent this event".
The Stop hook already handles this correctly — it uses decision: "block" intentionally for the two-pass save cycle (block → AI saves → AI stops again → stop_hook_active lets it through). PreCompact has no such two-pass mechanism, so blocking is always permanent.
Versions
- mempalace 3.3.0
- Python 3.14
- Claude Code (current)
Bug
hook_precompactinhooks_cli.pyreturns{"decision": "block", "reason": ...}(line 216). This permanently prevents compaction in Claude Code — both manual (/compact) and automatic.The intent is to remind the AI to save session content before context is lost. But
decision: "block"prevents the compaction from ever happening, which defeats the purpose.Reproduction
/compactin Claude CodeFix
In
hooks_cli.py,hook_precompactfunction (~line 216):systemMessageinjects the save instructions into the AI's context so it can act on them, while allowing compaction to proceed. This is the correct Claude Code hook contract for "do something before this event" vs "prevent this event".The Stop hook already handles this correctly — it uses
decision: "block"intentionally for the two-pass save cycle (block → AI saves → AI stops again →stop_hook_activelets it through). PreCompact has no such two-pass mechanism, so blocking is always permanent.Versions