Skip to content

/sessions endpoint still hangs indefinitely in v0.9.29 (fix #1136 installed) — kv.list(KV.sessions) never resolves, breaks viewer dashboard + MCP memory_sessions #1326

Open

Description

@jensenxu3

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

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:

  1. Moved mem%3Asummaries.bin aside (so kv.get(KV.summaries, …) has nothing to read) → restarted → /sessions still hangs. This rules out the per-session kv.get loop (the thing fix: env hydration, indexing, consolidation lifecycle, connector activation, hardening #1136's bounded fan-out was supposed to fix).
  2. Deleted mem%3Asessions.bin entirely (so kv.list(KV.sessions) has no scope/file to read) → restarted → /sessions still 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() fires Promise.all of 10 endpoints including /sessions; viewer is HTTP/1.1+keep-alive (browser limit 6 conns), the hung /sessions fetch (no AbortController/timeout in viewer's api()) starves the connection pool, so every tab (memories, lessons) sticks on "Loading…".
  • MCP memory_sessions tool unusable — agents call it, wait ~16s, get []. Cross-agent handoff via session-list is broken. /handoff skill unusable.
  • agentmemory doctor --all also hangs — it internally hits /sessions.

Still works (workaround)

  • memory_smart_search / smart-search — 0.12s, cross-agent recall intact
  • memory_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)

  1. Wrap kv.list(KV.sessions) (and the kv.get loop) in a timeout so the function returns what it has instead of hanging forever.
  2. Investigate why iii-state file_based KV returns a never-resolving Promise for kv.list(KV.sessions) at this scale — the scope's .bin is only 27 KB.
  3. Replace the per-session kv.get(KV.summaries, s.id) loop with a single kv.list(KV.summaries) lookup (batch read proven fast on other scopes).
  4. Add AbortController + timeout to viewer's api() 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

  1. fatesealed commented on Sep 7, 2026

    @fatesealed

    Additional v0.9.29 data 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 than kv.list(KV.sessions) itself.

    • /sessions?agentId=__none__: HTTP 200 in 4.6 ms
    • /sessions?agentId=*: no bytes, timed out after 8.006 s

    Both paths execute kv.list(KV.sessions); only the wildcard path enters the per-session kv.get(KV.summaries, id) batches. Replacing those batches with one kv.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.

  2. rohitg00 commented on Oct 8, 2026

    @rohitg00
    Owner

    @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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions