fix(mem0-agent): detached hooks lost their payload, so nothing was ever written

Observed live: real sessions flagged durable candidates (a preference, two
insights, a convention) but every session showed 'flush events: 0'. The manifest
backgrounded flush and assist-error with '( cmd &)', so the parent exited and
closed stdin before the child could read it -- the child then had no session_id,
fell back to 'no-session', and drained an empty buffer.

Now the CLI reads the payload itself and re-execs a detached worker with
start_new_session, so the hook still returns in ~0.27s. Verified end to end:
sent=1, session_state=created.

Also records a surface hint per event and shows it in 'sessions', since the
manifest pins MEM0_EDITOR to the same value on every client.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Deshraj Yadav
2026-07-29 20:22:43 -07:00
co-authored by Claude Fable 5
parent 10b8fc4bed
commit 1ea8c2e5fe
6 changed files with 97 additions and 18 deletions
+4 -4
View File
@@ -30,7 +30,7 @@
"hooks": [
{
"type": "command",
"command": "(MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent assist-error >/dev/null 2>&1 &)",
"command": "MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent assist-error",
"timeout": 5
}
]
@@ -41,7 +41,7 @@
"hooks": [
{
"type": "command",
"command": "(MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush >/dev/null 2>&1 &)",
"command": "MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush",
"timeout": 5
}
]
@@ -52,7 +52,7 @@
"hooks": [
{
"type": "command",
"command": "(MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush --reason precompact >/dev/null 2>&1 &)",
"command": "MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush --reason precompact",
"timeout": 5
}
]
@@ -63,7 +63,7 @@
"hooks": [
{
"type": "command",
"command": "(MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush --reason end >/dev/null 2>&1 &)",
"command": "MEM0_EDITOR=claude-code ${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush --reason end",
"timeout": 5
}
]
@@ -95,7 +95,7 @@ hooks:
matcher: "Bash"
command: "${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent assist-error"
timeout: 5
background: true
background: false
blocking: false
local_only: false
status_message: null
@@ -106,7 +106,7 @@ hooks:
matcher: null
command: "${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush"
timeout: 5
background: true
background: false
blocking: false
local_only: false
status_message: null
@@ -117,7 +117,7 @@ hooks:
matcher: null
command: "${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush --reason precompact"
timeout: 5
background: true
background: false
blocking: false
local_only: false
status_message: null
@@ -128,7 +128,7 @@ hooks:
matcher: null
command: "${CLAUDE_PLUGIN_ROOT}/bin/mem0-agent flush --reason end"
timeout: 5
background: true
background: false
blocking: false
local_only: false
status_message: null