agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Viewer/status show 0 memories because /memories and /export full-list endpoints fail on larger real corpus

Open dadwadw233 opened this issue 6 months ago • 2 comments

Summary

On a real migrated corpus, the dashboard and Memories tab report 0 memories even though search works and the state store contains thousands of long-term memories. The immediate failure is that the viewer/status paths depend on unbounded full-list endpoints:

  • GET /agentmemory/memories?latest=true
  • GET /agentmemory/export (used by agentmemory status)

Both can fail with 500 {"error":"Invocation stopped"} on a larger real-memory corpus. The viewer then treats the failed memories?latest=true call as an empty list, so the UI shows “No memories yet” / 0 instead of surfacing the backend error.

Environment

  • agentmemory: 0.9.20
  • OS: macOS
  • Native/local server, viewer at http://127.0.0.1:3113
  • No AGENTMEMORY_SECRET
  • Corpus was created by importing Claude Code JSONL transcripts plus seeding migrated claude-mem observations/summaries as long-term memories.

Current corpus shape, from local state-store inspection and successful search responses:

sessions:      40
observations:  ~34,927
memories:      8,637
latest memories: ~8,627
memories store file: ~17 MB

Repro

With the above corpus loaded:

curl -sS -D - -o /tmp/memories.body \
  'http://127.0.0.1:3111/agentmemory/memories?latest=true'
cat /tmp/memories.body

Actual:

HTTP/1.1 500 Internal Server Error
{"error":"Invocation stopped","error_id":"..."}

/agentmemory/export also fails the same way:

curl -sS -D - -o /tmp/export.body \
  'http://127.0.0.1:3111/agentmemory/export'
cat /tmp/export.body

Actual:

HTTP/1.1 500 Internal Server Error
{"error":"Invocation stopped","error_id":"..."}

But search still works against the same running server:

curl -sS -X POST http://127.0.0.1:3111/agentmemory/search \
  -H 'Content-Type: application/json' \
  -d '{"query":"PromptDA","limit":2,"format":"compact"}'

Actual: returns matching results from the migrated long-term memories.

Why the viewer shows 0 instead of an error

src/viewer/index.html calls the unbounded memories endpoint:

var result = await apiGet('memories?latest=true');
state.memories.items = (result && result.memories) || [];

api() returns null for non-2xx responses, so a backend failure is converted into an empty memory list.

The dashboard has the same dependency:

apiGet('memories?latest=true')

Why agentmemory status also reports 0

src/cli.ts calls /agentmemory/export and then uses:

const obsCount = memoriesRes?.observations?.length || 0;
const memCount = memoriesRes?.memories?.length || 0;

Since /export fails, apiFetch() returns null and the CLI prints 0 memories/observations even though search and local state show data exists.

Relevant implementation details

src/triggers/api.ts currently lists and returns every matching memory in one response:

const memories = await kv.list<Memory>(KV.memories);
const latest = req.query_params?.["latest"] === "true";
const filtered = latest ? memories.filter((m) => m.isLatest) : memories;
return { status_code: 200, body: { memories: filtered } };

There is no limit, offset, or cursor support for /agentmemory/memories.

mem::export has session pagination (maxSessions / offset), but it still always includes the full memories array, and the REST wrapper does not pass pagination query params through.

Related issues checked

  • #346 / PR #363 added benchmark/load-100k.ts and lists GET /agentmemory/memories?latest=true as a benchmark endpoint, but the committed verification run is only BENCH_N=1000 BENCH_C=10; the PR notes that the full 100k matrix was deferred to CI/release time.
  • #512 is about CJK viewer search behavior; this is different because the backend list endpoint fails and the viewer shows an empty state.
  • #303 is related to data-store location and “memories appear missing” from different cwd-local stores; this is different because the server is reading the correct store and search returns migrated memories.

I did not find an existing issue for /agentmemory/memories?latest=true or /agentmemory/export failing on a larger real corpus due to unbounded full-list responses.

Expected behavior

  • The viewer should not need to load all memories at once to render the dashboard or Memories tab.
  • Backend list/export endpoints should support bounded pagination and counts.
  • Viewer should show an error state when a backend request fails, not silently display 0.
  • agentmemory status should use a bounded stats/count endpoint, not a full export.

Suggested fix

  1. Add pagination to GET /agentmemory/memories:
GET /agentmemory/memories?latest=true&limit=50&cursor=...

Response shape:

{
  "memories": [],
  "total": 8637,
  "latestTotal": 8627,
  "limit": 50,
  "nextCursor": "...",
  "hasMore": true
}
  1. Add or reuse a bounded stats endpoint for dashboard/status counts, e.g.:
GET /agentmemory/stats

or include counts in /health without materializing all memory records.

  1. Extend export pagination to memories/observations, not only sessions; also pass REST query params through to mem::export.

  2. Update the viewer:

    • Dashboard uses counts/stats, not full memories.
    • Memories tab loads first page and paginates/infinite-scrolls.
    • Non-2xx API responses are rendered as visible errors instead of empty state.
  3. Add regression coverage:

    • /agentmemory/memories?latest=true&limit=... with thousands of memories.
    • Viewer handles failed memories API with an error state.
    • agentmemory status reports counts without requiring /export to serialize the entire corpus.

dadwadw233 avatar May 19 '26 16:05 dadwadw233

+1 — hit this exact symptom on a substantially larger corpus and ended up abandoning the tool over it.

Environment

  • agentmemory 0.9.21 (Homebrew Node 26 on macOS arm64)
  • OpenRouter: gemini-2.5-flash-lite (LLM), openai/text-embedding-3-small (embeddings, 1536-dim)
  • No AGENTMEMORY_SECRET

Corpus shape (~10× larger than the original report)

  • sessions: 676
  • observations: ~370,000
  • memories: 108 (explicit, via memory_remember)
  • graph: ~75,000 nodes / ~6,000 edges (after full extraction backfill)

Affected endpoints in our setup

  • GET /agentmemory/memories?latest=true → 500 Invocation stopped
  • GET /agentmemory/graph/stats → 500 Invocation stopped
  • GET /agentmemory/export → presumed same (didn't test)
  • Workers go into a reconnect loop within seconds, with [iii] Worker registered with ID: xxx re-firing every ~1 sec

What still works at this scale

  • GET /agentmemory/sessions (lists all 676 cleanly)
  • GET /agentmemory/health
  • Live capture via hooks (POST /agentmemory/observe)
  • SessionStart context injection (returns recall context fine)

So the unbounded full-list endpoints are the clear bottleneck. Pagination or streaming on /memories, /export, /graph/stats would unblock real-world corpus sizes.

Happy to provide more diagnostics if useful.

allandelmare avatar May 24 '26 18:05 allandelmare

Fixed in v0.9.22 — https://github.com/rohitg00/agentmemory/releases/tag/v0.9.22. Thanks for the report.

rohitg00 avatar May 26 '26 09:05 rohitg00