Repository navigation
Description
Summary
Two robustness gaps in the Haiku subprocess invocation cause the memory pipeline to stall and silently stop writing memory on busy machines (many concurrent Claude Code sessions and/or several MCP servers configured). Both were diagnosed from a single incident where now.md stopped updating for ~9 hours while the logs filled with FAILED at line 179 (exit 1) and claude timed out after 180s.
Confirmed on main @ a4ff96f (shipped as marketplace remember@claude-plugins-official v0.7.3).
Bug 1 — save-session.sh: main Haiku call has no timeout and its error handler is dead code under set -e
scripts/save-session.sh runs with set -e (line 53) and an ERR trap (line 55). The Step-4 Haiku call:
HAIKU_JSON=$(cd /tmp && env -u CLAUDECODE claude -p \
--model haiku --allowedTools "" --max-turns 1 \
--output-format json \
--mcp-config '{"mcpServers":{}}' --strict-mcp-config \
2>"$HAIKU_STDERR" < "$TMP_PROMPT")
HAIKU_EXIT=$?
if [ "$HAIKU_EXIT" -ne 0 ]; then
log "haiku" "ERROR: exit $HAIKU_EXIT — $(head -1 "$HAIKU_STDERR")"; exit 1
fiTwo problems:
- No
timeout. When the machine is under load (e.g. many concurrentclaudeprocesses), the nestedclaude -pcan block for tens of minutes. Observed a single such call alive 14.5 minutes (STAT Snl, ~29s CPU) while a byte-identical manual invocation returned in 3s. While it hangs it holds the save lock, blocking all subsequent saves. - The error handler is unreachable. Because the assignment's command substitution fails under
set -e, theERRtrap fires and the script exits before reachingHAIKU_EXIT=$?. So the gracefulif [ "$HAIKU_EXIT" -ne 0 ]block (lines 182-184) can never run — instead you gettrap 'log "error" "FAILED at line $LINENO ..."'→ the recurringFAILED at line 179 (exit 1)log lines with no diagnostic detail.
Notably, the NDC call further down already does this correctly (lines ~238-248):
(set +e # don't inherit set -e — claude -p non-zero exit must not kill the subshell
NDC_JSON=$(cd /tmp && env -u CLAUDECODE claude -p ... )
if [ $? -ne 0 ]; then log "ndc" "ERROR: haiku exit $? ..."; fiThe main Step-4 call just never got the same treatment.
Suggested fix
Wrap the call so a non-zero/timeout exit is captured instead of tripping set -e, and bound it with timeout:
HAIKU_EXIT=0
HAIKU_JSON=$(cd /tmp && env -u CLAUDECODE timeout 120 claude -p \
--model haiku --allowedTools "" --max-turns 1 \
--output-format json \
--mcp-config '{"mcpServers":{}}' --strict-mcp-config \
2>"$HAIKU_STDERR" < "$TMP_PROMPT") || HAIKU_EXIT=$?
if [ "$HAIKU_EXIT" -ne 0 ]; then
log "haiku" "ERROR: exit $HAIKU_EXIT — $(head -1 "$HAIKU_STDERR")"; exit 1
fi(timeout 124 for 124 = 120 + slack if you want it strictly above the intended ceiling; exit 124 then distinguishes a timeout in the log.)
Bug 2 — pipeline/haiku.py: call_haiku omits --strict-mcp-config, so consolidation loads all user MCP servers and times out
pipeline/haiku.py builds the subprocess command as:
cmd = [
"claude",
"-p", prompt,
"--output-format", "json",
"--model", "haiku",
"--max-turns", "1",
"--allowedTools", ",".join(tools) if tools else "",
]This is missing --mcp-config '{"mcpServers":{}}' and --strict-mcp-config, which both shell call-sites include (save-session.sh Step-4 and NDC). Without them, every Python-path Haiku call (notably consolidate.py:49 → call_haiku(prompt, timeout=180)) inherits the user's full MCP server set. On a machine with several MCP servers configured, MCP startup alone blows past the 180s timeout:
[consolidation] ERROR: pipeline failed — claude timed out after 180s
... subprocess.TimeoutExpired: Command '['claude', '-p', ... '--allowedTools', '']' timed out after 180 seconds
(The logged command array confirms the absence of the --mcp-config/--strict-mcp-config flags.)
Suggested fix
Make the Python wrapper match the shell wrappers — it never needs MCP since it runs --max-turns 1 with no tools:
cmd = [
"claude",
"-p", prompt,
"--output-format", "json",
"--model", "haiku",
"--max-turns", "1",
"--allowedTools", ",".join(tools) if tools else "",
"--mcp-config", '{"mcpServers":{}}',
"--strict-mcp-config",
]Impact
Together these make the pipeline fragile precisely in the environment the plugin targets (long-running, busy dev machines): one stuck/slow Haiku call hangs indefinitely, holds the lock, and — because the main call's error path is dead code — surfaces only as opaque FAILED at line 179 lines while memory silently stops being written. The consolidation path fails independently via MCP-startup timeout.
Environment
rememberv0.7.3 (main@a4ff96f), marketplaceremember@claude-plugins-official- Claude Code 2.1.157
- Linux; external/slug
data_dirmode; ~20+ concurrent Claude Code sessions; several MCP servers configured
Activity
refactor: single claude call site — bash delegates to pipeline call-h…
refactor: single claude call site — bash delegates to pipeline call-h…
refactor: one claude call site (fixes CC 2.x max-turns #98/#100 + mcp…
release: 0.8.0 (#106)
fix: cap extract size so long sessions can't stall saves (#96) (#109)