fix: load deferred memory tools at session start in Claude Code#43
Conversation
There was a problem hiding this comment.
This solves the immediate problem — without it, mem_save literally never gets called in Claude Code. Good find and clean fix.
One change needed: add mcp__plugin_engram_engram__mem_session_end to the select list in both session-start.sh and SKILL.md. Right now you're loading 4 tools but missing the one that marks sessions as ended. If the session-stop hook (#47) fails for any reason, the agent has no fallback because it doesn't know the tool exists.
Everything else looks good. I'll approve once mem_session_end is added to the select.
|
Hey @jmeiracorbal — the fix is solid and addresses a real blocker. To unblock the approval, Alan's requested change is a one-liner in both files: Add Apply that in both |
Hello! Added |
Summary
session-start.sh(hook context) andSKILL.md(always-active skill).Motivation
Closes #42
All Claude Code plugin tools are placed in the deferred pool by the platform, regardless of the
defer_loadingMCP annotation. The agent receives the Memory Protocol telling it to callmem_save, but the tool is unknown until ToolSearch discovers it. This results in 0 observations saved across all sessions.Changes
plugin/claude-code/scripts/session-start.sh: addedFIRST ACTIONsection to the injected protocol with the exact ToolSearch query for the four core toolsplugin/claude-code/skills/memory/SKILL.md: addedFIRST ACTIONsection at the top of the protocol so the agent loads tools even when the hook context is not available (e.g. after compaction)Test plan
go test ./...passesmem_savesuccessfully persisted an observation, verified withengram statsthatObservationsis no longer 0