fix: stop hooks from making agents write in chat — save tokens#786
Merged
fix: stop hooks from making agents write in chat — save tokens#786
Conversation
Collaborator
|
Great to see this addressed officially. Our #673 takes a complementary approach — instead of removing the save directive from the hook response, it switches the hook to call |
The save hook and precompact hook were telling the agent to write diary entries, add drawers, and add KG triples IN THE CHAT WINDOW. Every line written stays in conversation history and retransmits on every subsequent turn — ~$1/session in wasted tokens. Fix: hooks now say "saved in background, no action needed" and use decision: allow instead of block. The agent continues working without interruption. All filing happens via the background pipeline. Also updated hooks README with: - Known limitation: hooks require session restart after install - Updated cost section: zero tokens, background-only Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
10cf62e to
a3b7988
Compare
This was referenced Apr 14, 2026
Closed
igorls
added a commit
that referenced
this pull request
Apr 14, 2026
Main had 9 commits that never back-merged into develop after the v3.2.0 release cycle. Resolving conflicts as follows: - mempalace/version.py: keep develop (3.3.0 release target) - README.md: keep develop (Milla's #835 audit is authoritative — main had stale 19 tools / 170 tokens / "30x lossless" / v3.0.0 label) - hooks/mempal_{save,precompact}_hook.sh: keep develop (#786 reversed the #666 "decision=block" behavior intentionally to stop hooks from making agents write in chat) - pyproject.toml: auto-merged — keeps develop's 3.3.0 and picks up main's chromadb upper-bound removal (#690) - CONTRIBUTING.md, mempalace/hooks_cli.py: auto-merged cleanly — picks up main's improvements (fork-first clone, more detailed block reason strings that name MemPalace and specific tools) - integrations/openclaw/SKILL.md: bumped 3.2.0 → 3.3.0 (version tracks the package per #761 convention) - CHANGELOG.md: manual merge — kept develop's preamble + Unreleased v3.3.0 section + footer links; folded main's richer v3.2.0 entries (Packaging section for #690/#761; Bug Fixes #685/#677/#716/#707/ #755/#757; Documentation #734/#733) into the v3.2.0 section; deduped the split Documentation sections that auto-merge produced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hooks stop interrupting the agent with save directives. All filing continues to happen in the background via
python3 -m mempalace mineinvoked inside the hooks. Authored by Milla (MSL).What changes
Behavior change on both hooks:
mempal_save_hook.shdecision: block+ "Save key topics, decisions, quotes..."decision: allow+ "saved in background, no action needed"mempal_precompact_hook.shdecision: block+ "COMPACTION IMMINENT. Save ALL..."decision: allow+ "saved verbatim in background, compaction can proceed"Plus a small
hooks/README.mdupdate noting that hooks require a session restart after install.Why
Every character in a
block-hook reason becomes a system message in the conversation that retransmits on every subsequent turn. On long sessions that cost ~$1/session in wasted tokens and cluttered the chat. The core design principle in CLAUDE.md already commits to "Background everything — Nothing interrupts the user's conversation. Zero tokens spent on bookkeeping in the chat window." — this PR brings the hooks in line with that.The background mining (
python3 -m mempalace mine) is already running before the JSON emit in both hooks, so verbatim content is captured without agent participation.Test plan
pyproject=3.2.0vsversion.py=3.1.0)bash -nsyntax check on both hook scriptsCallouts for reviewers
mempalace_kg_addetc. no longer happens at hook time. If KG enrichment depends on agent participation, it needs to move to a background step.reasontext drifted slightly since the commit's base. Resolved by taking the newallow-decision bodies. Original authorship preserved.