Skip to content

PreCompact hook always blocks /compact — no way to acknowledge/bypass #858

@skeeper

Description

@skeeper

Problem

hooks/mempal-precompact-hook.sh (via mempalace hook run --hook precompact) unconditionally returns:

{"decision": "block", "reason": "COMPACTION IMMINENT. Save ALL topics..."}

This means /compact in Claude Code is permanently blocked as long as the plugin is installed. There is no mechanism for the model (or user) to signal "I saved what I needed, please proceed."

Observed in mempalace 3.0.14, Claude Code on macOS.

Reproduction

  1. Install mempalace plugin.

  2. Run /compact in any Claude Code session.

  3. Claude Code reports:

    Error: Compaction blocked by PreCompact hook: [bash ${CLAUDE_PLUGIN_ROOT}/hooks/mempal-precompact-hook.sh]: COMPACTION IMMINENT. Save ALL topics, decisions, quotes, code, and important context from this session to your memory system...

  4. The model saves drawers via mempalace_add_drawer.

  5. /compact is retried — still blocked. The hook never inspects whether any save actually happened.

Impact

  • Users cannot compact sessions without manually patching / removing the hook.
  • The "save before compact" nudge is still useful, but a hard block that can never be cleared is a footgun — many users will end up disabling the whole plugin.

Suggested fix

One of:

  1. Stateful check — track timestamp of last mempalace_add_drawer (or any write) and approve if a save happened since the last /compact / session-start.
  2. Two-phase hook — first call returns block with instructions; subsequent call within N seconds returns approve (gives the model one turn to save, then lets compaction through).
  3. Warn-only mode — return approve but include the reason text so the model still sees the nudge; document an opt-in MEMPALACE_BLOCK_COMPACT=1 env var for users who want a hard block.

Option 1 matches user expectations best.

Workaround (for now)

Replace hooks/mempal-precompact-hook.sh with:

#!/bin/bash
cat >/dev/null
echo '{"decision":"approve"}'
exit 0

…or delete the PreCompact block from hooks/hooks.json. Both get wiped on plugin update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/hooksClaude Code hook scripts (Stop, PreCompact, SessionStart)bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions