From d6708c79ae97f838de14b6872744b59f48a77a7c Mon Sep 17 00:00:00 2001 From: neal Date: Sat, 3 Oct 2026 16:02:08 -0400 Subject: [PATCH 1/2] docs(replay): drop the stale 30s function timeout rationale The in-process Engine has no invocation timeout (ADR 0001); the traversal cap bounds how long a request spends walking a tree, which still holds. Generated-By: Claude Opus 5.5 (1M context) --- src/functions/replay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/replay.ts b/src/functions/replay.ts index 6432799b5f..333c7576e5 100644 --- a/src/functions/replay.ts +++ b/src/functions/replay.ts @@ -249,7 +249,7 @@ async function findJsonlFiles( let walked = 0; // Hard bound on entries visited (regardless of extension) so trees // dominated by non-jsonl files (node_modules, lockfiles, etc.) cannot - // lock the 30s function timeout. `discovered` may underrepresent the + // stall the request walking them. `discovered` may underrepresent the // true count when traversalCapped fires — callers should surface that // distinction to the user. const traversalCap = Math.max(limit * 50, 50_000); From 48053351473cfcd85610b7421ad01a1bdae10c59 Mon Sep 17 00:00:00 2001 From: neal Date: Sat, 3 Oct 2026 16:41:08 -0400 Subject: [PATCH 2/2] docs: drop the remaining stale engine-timeout rationales Seven more comments justified a bound by an iii invocation timeout or the 30s state::set timeout. The in-process Engine has neither (ADR 0001); each bound still holds because the unbounded work is slow, so the comments now say that. Upstream issue references on the touched lines are written as rohitg00/agentmemory#N. Generated-By: Claude Opus 5.5 (1M context) --- src/functions/graph-import.ts | 6 +++--- src/functions/graph.ts | 8 +++----- src/index.ts | 10 ++++------ src/state/schema.ts | 8 ++++---- src/triggers/api.ts | 4 ++-- src/types.ts | 8 ++++---- src/viewer/index.html | 4 ++-- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/functions/graph-import.ts b/src/functions/graph-import.ts index 7a4865aadd..d2ae9c664b 100644 --- a/src/functions/graph-import.ts +++ b/src/functions/graph-import.ts @@ -18,9 +18,9 @@ import { logger } from "../logger.js"; // duplicating. Provenance is kept on properties.source so imported structure // is distinguishable from session-derived entities. -// Bounds protect the KV store and the iii invocation budget from very large -// graphs (graphify caps graph.json at 512MiB; a 100k-node import would blow -// the invocation window). Truncation is reported loudly in the result. +// Bounds protect the KV store and the import request from very large graphs +// (graphify caps graph.json at 512MiB; a 100k-node import would stall the +// request). Truncation is reported loudly in the result. const MAX_FILE_BYTES = 32 * 1024 * 1024; const MAX_NODES = 5000; const MAX_EDGES = 20000; diff --git a/src/functions/graph.ts b/src/functions/graph.ts index 2e763531f8..d9092926ba 100644 --- a/src/functions/graph.ts +++ b/src/functions/graph.ts @@ -53,11 +53,9 @@ const MAX_GRAPH_QUERY_LIMIT = 5000; const SNAPSHOT_TOP_NODES = DEFAULT_GRAPH_QUERY_LIMIT; const SNAPSHOT_KEY = "current"; -// `state::list` over a 75K-node scope can exceed the iii invocation -// timeout. The query handler races the enumeration against this budget -// and falls back to the snapshot (or a warning envelope) when the live -// path is too slow. 6000ms leaves headroom under the default 8s engine -// invocation deadline. +// `state::list` over a 75K-node scope is slow. The query handler races +// the enumeration against this budget and falls back to the snapshot (or +// a warning envelope) when the live path is too slow. const LIVE_ENUMERATION_BUDGET_MS = 6000; function withTimeout(p: Promise, ms: number, label: string): Promise { diff --git a/src/index.ts b/src/index.ts index 7ba9eb2c72..91f69e9035 100644 --- a/src/index.ts +++ b/src/index.ts @@ -145,12 +145,10 @@ function clearWorkerPidfile(): void { } catch {} } -// Top-level safety net for state invocation timeouts (issue #204). -// Under sustained write load (e.g. Claude Code hooks across many -// projects) `state::set` can occasionally exceed its 30s timeout. -// We don't want one such timeout to terminate the long-lived memory -// service — the rejection is surfaced to the relevant call site via -// .catch() where it matters; everything else is logged-and-continued. +// Top-level safety net (rohitg00/agentmemory#204): one stray rejection +// must not terminate the long-lived memory service. The rejection is +// surfaced to the relevant call site via .catch() where it matters; +// everything else is logged-and-continued. // Throttle logs to avoid spamming on bursts. let lastUnhandledLogAt = 0; process.on("unhandledRejection", (reason) => { diff --git a/src/state/schema.ts b/src/state/schema.ts index 286b5e8736..70988d7a9f 100644 --- a/src/state/schema.ts +++ b/src/state/schema.ts @@ -26,10 +26,10 @@ export const KV = { claudeBridge: "mem:claude-bridge", graphNodes: "mem:graph:nodes", graphEdges: "mem:graph:edges", - // #814: precomputed snapshot of the top-degree subgraph and aggregate - // type counts. Saves /graph/query and /graph/stats from a full - // kv.list enumeration over 75K+ node corpora, which exceeds the iii - // invocation timeout and surfaces as "Invocation stopped" 500s. + // rohitg00/agentmemory#814: precomputed snapshot of the top-degree + // subgraph and aggregate type counts. Saves /graph/query and + // /graph/stats from a full kv.list enumeration over 75K+ node corpora, + // too slow to run per request. // Single fixed key ("current") so writes are read-modify-write under // the same keyed mutex as graph-extract. graphSnapshot: "mem:graph:snapshot", diff --git a/src/triggers/api.ts b/src/triggers/api.ts index 8872b12018..16a8717a7b 100644 --- a/src/triggers/api.ts +++ b/src/triggers/api.ts @@ -1565,8 +1565,8 @@ export function registerApiTriggers( if (authErr) return authErr; // mem::export already supports maxSessions/offset internally, // but the HTTP endpoint hardcoded an empty payload — so /export on a - // real corpus (40 sessions × 34K observations × 8K memories) hit the - // iii engine invocation timeout and `agentmemory status` reported 0. + // real corpus (40 sessions × 34K observations × 8K memories) had to + // load the whole store in one request. // Pass through the query-string pagination so callers can chunk. const rawMax = req.query_params?.["maxSessions"]; const rawOffset = req.query_params?.["offset"]; diff --git a/src/types.ts b/src/types.ts index 0f34c2ea7a..90125e87ad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -537,10 +537,10 @@ export interface GraphQueryResult { // detect when the default was applied vs an explicit `limit`. limit?: number; offset?: number; - // #814: indicates the response came from the precomputed top-degree - // snapshot rather than a live kv.list enumeration. Set only on the - // empty-body / nodeType-only branch on large corpora where the - // unbounded enumeration would exceed the iii invocation timeout. + // rohitg00/agentmemory#814: indicates the response came from the + // precomputed top-degree snapshot rather than a live kv.list + // enumeration. Set only on the empty-body / nodeType-only branch on + // large corpora where the unbounded enumeration is too slow. fromSnapshot?: boolean; // #814: when the snapshot is stale or absent and the live fallback // also failed, expose an explanatory note so the viewer can surface diff --git a/src/viewer/index.html b/src/viewer/index.html index 2c1515dd84..d49cb2fbe2 100644 --- a/src/viewer/index.html +++ b/src/viewer/index.html @@ -2651,8 +2651,8 @@

agentmemory

var el = document.getElementById('view-memories'); if (!state.memories.loaded) el.innerHTML = '
Loading memories...
'; // cap at 2000 so the viewer remains responsive on large - // corpora. Older endpoints returned the full unbounded list which - // hit the iii invocation timeout and the UI fell through to 0. + // corpora. Older endpoints returned the full unbounded list, too + // slow to load on a large store. var result = await apiGet('memories?latest=true&limit=2000'); var items = (result && result.memories) || []; // Newest first — server returns KV-insertion order.