agentmemory Graph empty
investigation summary
Setup
- agentmemory: @agentmemory/[email protected], installed at /usr/local/lib/node_modules/@agentmemory/agentmemory
- Runtime: macOS (darwin arm64), launched via LaunchAgent (dev.agentmemory.server.plist)
- LLM provider: MiniMax (MINIMAX_API_KEY set in ~/.agentmemory/.env)
- Embeddings: EMBEDDING_PROVIDER=local (Xenova all-MiniLM-L6-v2)
- Flag: GRAPH_EXTRACTION_ENABLED=true — confirmed enabled: true via GET /agentmemory/config/flags
- Daemon health: status: healthy, no circuit-breaker open, kv connectivity OK
Symptom
Graph tab is permanently empty. GET /agentmemory/graph/stats returns {totalNodes:0, totalEdges:0} indefinitely across sessions. mem::graph-extract is absent from functionMetrics in /agentmemory/health — meaning the function has never been invoked on this daemon.
Root cause — event::session::stopped has no publisher
In dist/src-DPSaLB5-.mjs:
- L13781–13800 — api::session::end (the route registered at POST /agentmemory/session/end) only does kv.update(KV.sessions, sessionId, [{set endedAt}, {set status:"completed"}]) and returns {success:true}. No publish to any topic.
- L16635–16663 — event::session::stopped is registered as a durable:subscriber on topic agentmemory.session.stopped, and that handler contains the sdk.triggerVoid("mem::graph-extract", { observations }) call.
- Greps in dist/src-DPSaLB5-.mjs and dist/index.mjs for agentmemory.session.stopped / .started / .ended return only the three subscriber registrations — zero publishers anywhere.
- iii-config.yaml uses iii-pubsub with adapter: local, which requires explicit publish calls. There is no auto-emit on KV update for these topic names.
Net effect: the Claude-Code plugin's session-end.mjs hook correctly POSTs to /session/end, the route returns {success:true}, but the graph-extract subscriber never fires. /exit does nothing useful.
Hook is wired correctly (ruled out)
- Plugin hooks.json registers SessionStart and SessionEnd hooks → session-start.mjs and session-end.mjs.
- Both scripts fetch() http://localhost:3111/agentmemory/session/{start,end} with the session ID.
- Manual curl POST /session/start and /session/end against the daemon both succeed (200 / {success:true}).
Manual /graph/extract route — partial workaround
POST /agentmemory/graph/extract (registered as api::graph-extract at L14444) works and accepts {observations: [{id, sessionId, title, narrative, type, importance, concepts, files, timestamp}]}. Auth is a no-op when AGENTMEMORY_SECRET isn't set.
Tested four ways. Nodes work. Edges only populate when the narrative explicitly uses relational language. Even system-generated session summaries don't reliably trigger edge extraction.
Prompt + parser observations
- GRAPH_EXTRACTION_SYSTEM (L6504): asks for
and XML. - parseGraphXml (L6527): regex for relationships requires attributes in exact order: type, source, target, weight,
all four present, self-closing tag. Also requires source and target to exactly match a
from the same response — no fuzzy match. - MiniMax with these prompts produces good node extraction on relational narratives but appears to either omit relationships or emit them in a format the strict regex misses on dense/descriptive text. (Couldn't verify the raw LLM response — no debug logging path I could find.)
Questions for maintainer
- Is there a missing call somewhere that should publish to agentmemory.session.stopped when /session/end is hit? Or is this expected to be done by another component (e.g., from KV change events that didn't ship in this build)?
- Has anyone tested graph extraction with MiniMax specifically? The strict regex + exact-name-match seems brittle for non-Anthropic providers.
- Is POST /agentmemory/graph/build (referenced by viewer/index.html line 1567 self-heal path) supposed to be registered? It currently 404s.
- Workaround question: any sanctioned way to trigger graph extraction periodically/on-demand short of the manual /graph/extract POST, ideally over a session's already-compressed observations?
Repro
Confirm no publisher exists:
grep -rn '"agentmemory.session.' /usr/local/lib/node_modules/@agentmemory/agentmemory/dist/
Returns ONLY the three durable:subscriber registrations — no publish/triggerVoid calls.
Confirm metric absence after a clean session end:
curl -s http://127.0.0.1:3111/agentmemory/health | jq '.functionMetrics[].functionId' | grep graph-extract
Empty.
I found one concrete parser-loss path that can make the graph appear empty even when the provider returned graph-shaped XML.
While debugging graph rebuild locally, I captured a raw provider response that current parseGraphXml would parse as 0 nodes / 0 edges. The response was not empty; its entities were self-closing:
<entities>
<entity type="agent" name="Agent"/>
<entity type="system" name="Memory System"/>
<entity type="concept" name="Chinese Input"/>
<entity type="tool" name="Glob"/>
</entities>
<relationships>
<relationship type="uses" source="Agent" target="Glob" weight="0.9"/>
</relationships>
PR #494 is directly relevant because it adds self-closing entity support. There is a second issue after that: real provider output can include out-of-schema types such as agent, system, tool, directory, file_type, and relationship types such as searches_in / searches_for. Those likely need normalization or explicit fallback as a follow-up, otherwise extraction may still be brittle across providers.
Independent third reproduction on @agentmemory/[email protected], macOS arm64. Same root cause as @jonathanzhan1975's writeup: event::session::stopped is registered as a durable:subscriber on topic agentmemory.session.stopped, but grepping the entire dist/ tree turns up zero publishers for that topic. mem::graph-extract never appears in functionMetrics after sessions end normally; manual POST /agentmemory/graph/extract works fine.
One detail worth noting for anyone else patching this locally: the CLI at /opt/homebrew/bin/agentmemory loads dist/src-DPSaLB5-.mjs, not dist/index.mjs. The two files are near-identical compiled bundles, so it's easy to apply a patch to the wrong one and watch nothing happen at runtime. Grepping the CLI for import statements points at the live bundle.
I tried PR #502's two-line patch locally:
- In
api::session::end: wrap the existingkv.updateinwithKeyedLock("session:end:${sessionId}", ...), and callawait sdk.trigger({ function_id: "event::session::stopped", payload: { sessionId } })first whensession.status !== "completed". - In the
event::session::stoppedhandler's graph-extract block: changesdk.triggerVoid("mem::graph-extract", ...)→await sdk.trigger({ function_id: "mem::graph-extract", payload: ... }). ThetriggerVoidvariant was silently dropped; the awaited variant runs in-process and shows up in metrics.
Verification: ending a session with 22 compressed observations, /session/end now blocks ~14s, mem::summarize and mem::graph-extract both increment in functionMetrics, and the graph gains 7 nodes / 3 edges (post-dedup). LLM provider was OpenAI.
@rohitg00 — this issue plus PR #502 plus my repro is three independent users hitting the same symptom (#559 with MiniMax, this report with OpenAI, the PR author's Codex case). The "auto path on event::session::stopped" you mentioned in #502's review really doesn't fire on this build because nothing publishes that topic.