Summary
The agent-memory.mjs archive-raw-session Claude Code Stop-hook client (from the aegis-daemon project) fails when calling MindSpring's notebooks endpoint, with a D1 out-of-memory error returned as HTTP 501:
HTTP 501 from https://mindspring.blue-pine-edf6.workers.dev/api/v2/workspaces/aegis-daemon/notebooks:
{"error":"Error: D1_ERROR: out of memory: SQLITE_NOMEM"}
Observed in .agent-memory/logs/2026-07-03.jsonl in a client repo, timestamp 2026-07-03T11:00:59.281Z.
Impact
- The Stop hook (
mindspring-session-push.sh → agent-memory.mjs archive-raw-session) that archives session transcripts into the session_history notebook fails on this call.
- Because the failure is a D1 out-of-memory condition rather than a fast validation error, the request appears to take a long time to fail (consistent with a query scanning/spilling before erroring out) — this made every Claude Code session's Stop hook take several minutes to complete on the client side before giving up.
- On failure the client enqueues a local retry file (
.agent-memory/retry/*.json) but does not otherwise recover.
Suspected cause
GET/POST /api/v2/workspaces/{workspace}/notebooks (list-or-create-by-title flow) is likely running an unbounded or inefficient D1 query — possibly scanning a large/unindexed table (e.g. all notebooks across workspaces, or a large session_history table growing unbounded from repeated archive pushes) that exhausts available memory in the Workers/D1 execution context.
Suggested next steps
- Reproduce against the
aegis-daemon workspace (workspace=aegis-daemon, notebookTitle=session_history).
- Check the query behind the notebooks list endpoint for missing indexes / unbounded scans.
- Consider paginating or scoping the notebooks list query, and/or capping session_history growth (archive/prune old entries).
- Return a fast, clear error instead of letting the query run to an OOM condition, so callers don't hang.
Workaround applied client-side
Disabled the global Stop hook in ~/.claude/settings.json for now, since it was blocking session shutdown for minutes on every session. Will need to be re-enabled once this is fixed.
Summary
The
agent-memory.mjs archive-raw-sessionClaude Code Stop-hook client (from theaegis-daemonproject) fails when calling MindSpring's notebooks endpoint, with a D1 out-of-memory error returned as HTTP 501:Observed in
.agent-memory/logs/2026-07-03.jsonlin a client repo, timestamp2026-07-03T11:00:59.281Z.Impact
mindspring-session-push.sh→agent-memory.mjs archive-raw-session) that archives session transcripts into thesession_historynotebook fails on this call..agent-memory/retry/*.json) but does not otherwise recover.Suspected cause
GET/POST /api/v2/workspaces/{workspace}/notebooks(list-or-create-by-title flow) is likely running an unbounded or inefficient D1 query — possibly scanning a large/unindexed table (e.g. all notebooks across workspaces, or a large session_history table growing unbounded from repeated archive pushes) that exhausts available memory in the Workers/D1 execution context.Suggested next steps
aegis-daemonworkspace (workspace=aegis-daemon,notebookTitle=session_history).Workaround applied client-side
Disabled the global Stop hook in
~/.claude/settings.jsonfor now, since it was blocking session shutdown for minutes on every session. Will need to be re-enabled once this is fixed.