feat(mem0-plugin): add PostToolUseFailure, PostCompact, SessionEnd, SubagentStop hooks
Close 4 lifecycle coverage gaps: - PostToolUseFailure: catch failed mem0 MCP calls, classify errors, inject retry guidance - PostCompact: inject parallel search commands for context recovery after compaction - SessionEnd: last-chance transcript capture with dedup against Stop hook - SubagentStop: remind parent agent to persist subagent learnings Also patch on_stop.sh to write capture marker for SessionEnd dedup.
This commit is contained in:
@@ -63,6 +63,13 @@ Always include `app_id` (the active project_id from SessionStart) as a top-level
|
||||
EOF
|
||||
|
||||
# Capture transcript state in the background via Mem0 REST API
|
||||
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // ""' 2>/dev/null || echo "")
|
||||
echo "$INPUT" | python3 "$SCRIPT_DIR/on_pre_compact.py" --source=session-end 2>/dev/null &
|
||||
|
||||
# Mark session as captured so SessionEnd hook can skip duplicate capture
|
||||
if [ -n "$SESSION_ID" ]; then
|
||||
mkdir -p "$HOME/.mem0" 2>/dev/null || true
|
||||
touch "$HOME/.mem0/.captured_${SESSION_ID}" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user