Bug(viewer): #graph tab is blank — POST /graph/query with empty body returns 500 "Invocation stopped" on large graphs (same class as #544, not fixed for the graph endpoint)
Summary
The viewer #graph tab renders nothing (0 nodes / 0 edges, blank canvas) on a large graph. The root cause is the same class as #544 (fixed for /memories and /export), but for the graph endpoint, which was not covered:
On load, the viewer issues POST /agentmemory/graph/query with an empty, unbounded body {} (whole graph). On a large corpus this fails with 500 {"error":"Invocation stopped"}. The viewer's api() returns null on non-2xx, so the failure becomes an empty node set → blank canvas. There is no recovery path: the "Search nodes…" box filters client-side over the (empty) loaded set, and "Rebuild Graph" hits the same failing endpoint.
Environment
- agentmemory:
0.9.24 - iii-engine: pinned default
0.11.2 - OS: macOS, native/local server, viewer at
http://localhost:3113, engine at:3111 - No
AGENTMEMORY_SECRET - Graph shape (from
graph/stats, which works): 11,037 nodes / 28,754 edges- nodes: concept 5528, file 2743, library 865, function 803, error 370, pattern 351, decision 301, …
- edges: related_to 14753, uses 7104, depends_on 2950, modifies 2059, causes 865, imports 730, …
Repro
# Full/unbounded graph query — what the #graph viewer sends on load → 500
curl -sS -X POST http://localhost:3111/agentmemory/graph/query \
-H 'Content-Type: application/json' -d '{}'
# => {"error":"Invocation stopped","error_id":"..."}
# A bare limit (no filter) still attempts the full traversal → 500
curl -sS -X POST http://localhost:3111/agentmemory/graph/query \
-H 'Content-Type: application/json' -d '{"limit":200}'
# => {"error":"Invocation stopped","error_id":"..."}
# Stats works (bounded aggregation)
curl -sS http://localhost:3111/agentmemory/graph/stats # => 200, full counts
# FILTERED queries work fine (scoped subgraph)
curl -sS -X POST http://localhost:3111/agentmemory/graph/query \
-H 'Content-Type: application/json' -d '{"nodeType":"class"}' # => 200
curl -sS -X POST http://localhost:3111/agentmemory/graph/query \
-H 'Content-Type: application/json' -d '{"query":"error","maxDepth":1}' # => 200 (135 nodes / 190 edges)
The 500 returns immediately, not after the 180s default_timeout, so this is an engine-level invocation abort on the oversized full-graph response — not a timeout.
Why the viewer can't recover
- On load it calls
POST graph/query {}(unbounded). Non-2xx →null→state.graphends up empty → blank canvas, GRAPH STATS shows 0/0. - The "Search nodes…" box filters the already-loaded nodes client-side; since 0 were loaded, it does nothing and fires no request.
- "↻ Rebuild Graph" calls the same failing path (
graph/build/graph/query).
Relation to #544
#544 ("Viewer/status show 0 memories … full-list endpoints fail on larger real corpus") is the identical failure mode (Invocation stopped on an unbounded full-list at scale, silently shown as 0). It was fixed for GET /memories and /export via pagination + a bounded counts path + a viewer error state. POST /graph/query was not covered: it still has no limit/offset/cursor, and the viewer still requests the entire graph.
#563 ("Viewer graph does not settle with >1000 nodes") is different — that's client-side layout settling after nodes load; here the request 500s and zero nodes ever load.
Suggested fix
- Viewer should issue a bounded initial graph query (e.g. top-N nodes by weight/degree, or
limit+ cursor) instead of{}. graph/queryshould accept and enforcelimit/offset/cursor, returntotalcounts, and apply a sane default cap so an empty body can't materialize the whole graph in one invocation.- Viewer should render backend errors as a visible error state instead of a silent empty canvas (same as #544's viewer fix).
- Regression coverage for
graph/query/graph/buildat ~10k+ nodes.
+1 — confirming this on a 6x larger corpus on v0.9.24, with a slightly different failure mode worth noting.
Environment
- agentmemory 0.9.24 (Homebrew Node 26 on macOS arm64)
- OpenRouter: gemini-2.5-flash-lite (LLM), openai/text-embedding-3-small (embeddings, 1536-dim)
- Graph shape: ~75,000 nodes / ~5,800 edges (extracted via the chunked graph-extract workaround across 678 imported sessions)
Failure mode variant: state::list timeout
Where the OP sees an immediate 500 Invocation stopped, our larger corpus hits the 180s default_timeout on state::list itself:
[agentmemory] error Graph extraction failed {"error":"Invocation timeout after 180000ms: state::list"}
This happens on ALL graph endpoints that internally call kv.list(KV.graphNodes):
GET /agentmemory/graph/stats— returns null nodes/edges (silently)POST /agentmemory/graph/query {}— 500 (same as OP)POST /agentmemory/graph/query {"query":"..."}— 0 nodes (also silently)POST /agentmemory/graph/build— same 180sstate::listtimeout
So at our scale the graph dimension is fully broken (read AND write paths through kv.list), even after the v0.9.22-24 fix wave that closed #544, #563, #474, #587. The graph data IS on disk (101 MB nodes file + 8.9 MB edges file) — just unreadable via the API.
Related: PR #764 (closes #309) addresses the persistence-side problem (monolithic snapshots oversized) but isn't merged yet. That + the suggested fixes in this issue (bounded query + cursor, error state in viewer) would let real-world corpora work.
We ended up only being able to use sessions/memories/search endpoints — abandoned graph features entirely at this scale.