Repository navigation
Description
Summary
GET /agentmemory/sessions still hangs indefinitely in v0.9.29 (the fix from #1136 is installed), even with only 51 sessions / ~22k observations. This is a regression / incomplete fix of #1100 — that issue was closed after #1136 merged the bounded fan-out, but the hang persists on the published latest.
Every other kv.list endpoint returns in <5ms; only api::sessions never resolves. Data is intact (51 sessions verifiable via direct KV file read), the endpoint just never returns.
Environment
- agentmemory v0.9.29 (verified:
dist/index.mjscontains the fix: env hydration, indexing, consolidation lifecycle, connector activation, hardening #1136 bounded-fan-outfor (let batch = 0; batch < sessions.length; batch += 10)) - iii-engine v0.11.2 (pinned binary, macOS arm64)
- Node v22.19.0, macOS 26.5.2 (arm64)
- 51 sessions / 21,997 observations / 38 summaries / 16 MB state_store.db
Reproduction
curl -fsS --max-time 20 http://localhost:3111/agentmemory/sessions # HANGS — no response after 20s
curl http://localhost:3111/agentmemory/memories?limit=1 # 0.003s ✅
curl http://localhost:3111/agentmemory/lessons?limit=1 # 0.004s ✅
curl http://localhost:3111/agentmemory/graph/stats # 0.004s ✅
curl http://localhost:3111/agentmemory/health # 0.002s ✅MCP memory_sessions tool (what agents call) also hangs ~16s then returns [].
Smoking gun — the hang is in the function, not the data
With the daemon stopped I ran two lossless experiments:
- Moved
mem%3Asummaries.binaside (sokv.get(KV.summaries, …)has nothing to read) → restarted →/sessionsstill hangs. This rules out the per-sessionkv.getloop (the thing fix: env hydration, indexing, consolidation lifecycle, connector activation, hardening #1136's bounded fan-out was supposed to fix). - Deleted
mem%3Asessions.binentirely (sokv.list(KV.sessions)has no scope/file to read) → restarted →/sessionsstill hangs. The file did not regenerate; the function hangs regardless of whether the sessions scope exists.
iii engine CPU sits at 0.0% during the hang (verified via ps) — a Promise that never resolves or rejects, not a CPU-bound loop. iii-http default_timeout: 180000 (3 min) is the only thing that eventually drops it.
This points at the kv.list(KV.sessions) call itself (or the iii-state file_based KV worker returning a never-resolving Promise for that scope), not the kv.get fan-out that #1136 addressed.
Root cause (source-located)
dist/index.mjs ~line 3572 (the #1136 version):
const sessions = await kv.list(KV.sessions); // ← suspected never-resolving Promise
for (let batch = 0; batch < sessions.length; batch += 10) {
const chunk = sessions.slice(batch, batch + 10);
const results = await Promise.all(chunk.map((s) => kv.get(KV.summaries, s.id).catch(() => null)));
...
}Every other list endpoint (/memories, /lessons, /audit, /semantic, /relations, /graph/stats, /crystals) does a single kv.list with no per-item kv.get and returns in <20ms. api::sessions is the only one that chains kv.list(KV.sessions) + per-item kv.get(KV.summaries), and experiment #1 above shows removing the kv.get side doesn't help — so the never-resolve is on the kv.list side or deeper in iii-state's file_based KV for the sessions scope.
Impact
- Viewer dashboard unusable —
loadDashboard()firesPromise.allof 10 endpoints including/sessions; viewer is HTTP/1.1+keep-alive (browser limit 6 conns), the hung/sessionsfetch (noAbortController/timeout in viewer'sapi()) starves the connection pool, so every tab (memories, lessons) sticks on "Loading…". - MCP
memory_sessionstool unusable — agents call it, wait ~16s, get[]. Cross-agent handoff via session-list is broken./handoffskill unusable. agentmemory doctor --allalso hangs — it internally hits/sessions.
Still works (workaround)
memory_smart_search/smart-search— 0.12s, cross-agent recall intactmemory_save, hook capture,/memories,/lessons,/observations?sessionId=…,/graph/stats— all <20ms- Viewer tabs via direct hash (
#memories,#lessons,#graph,#crystals,#timeline) — work as long as Dashboard is never clicked
Suggested fixes (any one)
- Wrap
kv.list(KV.sessions)(and thekv.getloop) in a timeout so the function returns what it has instead of hanging forever. - Investigate why iii-state
file_basedKV returns a never-resolving Promise forkv.list(KV.sessions)at this scale — the scope's.binis only 27 KB. - Replace the per-session
kv.get(KV.summaries, s.id)loop with a singlekv.list(KV.summaries)lookup (batch read proven fast on other scopes). - Add
AbortController+ timeout to viewer'sapi()fetch so one hung request can't starve the HTTP/1.1 connection pool.
Relationship to #1100
#1100 reported this exact hang on v0.9.28; #1136 merged a bounded-fan-out fix; the published v0.9.29 contains that fix but the hang persists. My smoking-gun experiments (deleting sessions.bin / summaries.bin) show the never-resolve is upstream of the kv.get loop #1136 fixed — likely kv.list(KV.sessions) itself.
Activity
fatesealed commentedon Sep 7, 2026
Additional
v0.9.29data point: I reproduced the same user-visible hang with 165 sessions, but in this environment the failure is specifically the chunked summary fan-out rather thankv.list(KV.sessions)itself./sessions?agentId=__none__: HTTP 200 in 4.6 ms/sessions?agentId=*: no bytes, timed out after 8.006 sBoth paths execute
kv.list(KV.sessions); only the wildcard path enters the per-sessionkv.get(KV.summaries, id)batches. Replacing those batches with onekv.list(KV.summaries)+ in-memory join made the full endpoint return in 16.8–22.3 ms, and 20 requests at concurrency 5 all completed in 31.3–83.9 ms.Detailed independent measurements are posted on #1324: #1324 (comment)
This suggests there may be two failure modes across installations, but #1324's sessions hunk directly fixes at least the reproducible invocation-pool saturation case left by #1136.
rohitg00 commentedon Oct 8, 2026
@jensenxu3 v0.9.30 adds secondary indexes for session start context and observation lookups and paginates memories, but the sessions listing itself still enumerates the sessions scope, so this stays open. https://github.com/rohitg00/agentmemory/releases/tag/v0.9.30