Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

Keep memory timeout scenario above the default

Steven Enamakel35af9d4a363b
diff --git a/scripts/__tests__/memory-scenarios-timeout.test.mjs b/scripts/__tests__/memory-scenarios-timeout.test.mjs
new file mode 100644
index 0000000000..26770c5ee8
--- /dev/null
+++ b/scripts/__tests__/memory-scenarios-timeout.test.mjs
@@ -0,0 +1,10 @@
+import assert from "node:assert/strict";
+import { test } from "node:test";
+
+import { extendedPreTurnWait } from "../memory-scenarios/scenarios.mjs";
+
+test("the comparison wait stays above the configured pre-turn deadline", () => {
+ assert.equal(extendedPreTurnWait(10_000), 15_000);
+ assert.equal(extendedPreTurnWait(20_000), 25_000);
+ assert.throws(() => extendedPreTurnWait(undefined), /positive safe integer/);
+});
diff --git a/scripts/memory-scenarios/README.md b/scripts/memory-scenarios/README.md
index d45f1c0e38..f71c11c074 100644
--- a/scripts/memory-scenarios/README.md
+++ b/scripts/memory-scenarios/README.md
@@ -132,17 +132,17 @@ running it.
The definitions live in [`scenarios.mjs`](./scenarios.mjs); the memory domain they exercise is documented in the [`memory` README](../../crates/openhuman-core/src/memory/README.md).
-| id | engines | what it checks |
-| ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| A-storing | both | chats with two agents logged under each agent; learnings of every kind, kind visible on read-back; brain text; a file from a path holding a username (only the basename may reach the engine); dated facts |
-| B-recall | both | cross-thread recall; a negative control (no invention); a planted learning changes a reply; brain retrieval with citations; pre-turn pack timeouts at the default wait vs 6000 ms (`[memory:hooks] pre_turn timed out` in core.log) |
-| C-dates | both | the user time zone; "yesterday" and a named date find the right fact; a Spanish question gets a Spanish reply |
-| E-migration | local | legacy items plus a v1 store: import with consent; a shared (self-hosted) tree waits for the takeover consent, then moves; a core restart mid-move; layout v3; nothing lost; v1 documents present; chats pooled at `ws:main`; the same recall answer |
-| F-labels | local | thread and agent on every logged turn; phone numbers in plain text; on the wire, `observed_actor`/`subject` on assistant turns only with `[memory] observed_actor = true`, none with it off |
-| G-source-cap | both | more than four brain sources: at most four in the pack, the named one included, no Team section |
-| H-forget | both | a forget removes from list and recall; forgetting nothing reports `forgotten: 0` |
-| I-qa | both | belief build (`memory_jobs_run`, local only), backfill state, a new learning listed at once; local: the engine stopped mid-session, is the failure surfaced or swallowed |
-| J-store-speed | builtin | a synthetic batch stored on the hosted path, timed, with `UNAVAILABLE`/429 counted (no real import) |
+| id | engines | what it checks |
+| ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| A-storing | both | chats with two agents logged under each agent; learnings of every kind, kind visible on read-back; brain text; a file from a path holding a username (only the basename may reach the engine); dated facts |
+| B-recall | both | cross-thread recall; a negative control (no invention); a planted learning changes a reply; brain retrieval with citations; pre-turn pack timeouts at the default wait vs five seconds more (`[memory:hooks] pre_turn timed out` in core.log) |
+| C-dates | both | the user time zone; "yesterday" and a named date find the right fact; a Spanish question gets a Spanish reply |
+| E-migration | local | legacy items plus a v1 store: import with consent; a shared (self-hosted) tree waits for the takeover consent, then moves; a core restart mid-move; layout v3; nothing lost; v1 documents present; chats pooled at `ws:main`; the same recall answer |
+| F-labels | local | thread and agent on every logged turn; phone numbers in plain text; on the wire, `observed_actor`/`subject` on assistant turns only with `[memory] observed_actor = true`, none with it off |
+| G-source-cap | both | more than four brain sources: at most four in the pack, the named one included, no Team section |
+| H-forget | both | a forget removes from list and recall; forgetting nothing reports `forgotten: 0` |
+| I-qa | both | belief build (`memory_jobs_run`, local only), backfill state, a new learning listed at once; local: the engine stopped mid-session, is the failure surfaced or swallowed |
+| J-store-speed | builtin | a synthetic batch stored on the hosted path, timed, with `UNAVAILABLE`/429 counted (no real import) |
Not driven here (said so in the report): a workflow writing memory, workflow
memory kept out of chat, and the unconfirmed-import no-erase guard (unit-tested
diff --git a/scripts/memory-scenarios/scenarios.mjs b/scripts/memory-scenarios/scenarios.mjs
index 6317fe8804..94ba4903ce 100644
--- a/scripts/memory-scenarios/scenarios.mjs
+++ b/scripts/memory-scenarios/scenarios.mjs
@@ -24,6 +24,18 @@ const lc = (s) => String(s ?? "").toLowerCase();
const containsAny = (text, words) =>
words.some((w) => lc(text).includes(lc(w)));
+/** Give the timeout comparison five seconds more than the active default. */
+export const extendedPreTurnWait = (defaultWait) => {
+ if (
+ !Number.isSafeInteger(defaultWait) ||
+ defaultWait < 1 ||
+ defaultWait > Number.MAX_SAFE_INTEGER - 5_000
+ ) {
+ throw new TypeError("pre-turn timeout must be a positive safe integer");
+ }
+ return defaultWait + 5_000;
+};
+
// ---------------------------------------------------------------------------
// A. Storing
// ---------------------------------------------------------------------------
@@ -245,6 +257,7 @@ const recall = {
// B5: the pre-turn pack at the default wait, then a larger one.
const policy = await ctx.rpc("openhuman.memory_policy_get", {});
const defaultWait = pick(policy, "recall.pre_turn_timeout_ms");
+ const extendedWait = extendedPreTurnWait(defaultWait);
const probes = [
"What do I usually want in meeting summaries?",
"Who is my manager?",
@@ -255,27 +268,30 @@ const recall = {
for (const p of probes) await ctx.turn(tDef, p);
const atDefault =
(await countLogLines(ctx.logFile, /pre_turn timed out/)) - before;
- await ctx.rpc("openhuman.memory_policy_set", { pre_turn_timeout_ms: 6000 });
- const tBig = ctx.newThread("B5-6000ms");
+ await ctx.rpc("openhuman.memory_policy_set", {
+ pre_turn_timeout_ms: extendedWait,
+ });
+ const tBig = ctx.newThread(`B5-${extendedWait}ms`);
for (const p of probes) await ctx.turn(tBig, p);
const atLarge =
(await countLogLines(ctx.logFile, /pre_turn timed out/)) -
before -
atDefault;
await ctx.rpc("openhuman.memory_policy_set", {
- pre_turn_timeout_ms: defaultWait ?? 1500,
+ pre_turn_timeout_ms: defaultWait,
});
ctx.results.pre_turn = {
default_ms: defaultWait,
+ extended_ms: extendedWait,
timed_out_at_default: atDefault,
- timed_out_at_6000: atLarge,
+ timed_out_at_extended: atLarge,
turns_each: probes.length,
};
check(
"B5-pre-turn-default",
atDefault === 0,
`no pre-turn pack times out at the default wait (${defaultWait} ms)`,
- `${atDefault}/${probes.length} timed out at the default, ${atLarge}/${probes.length} at 6000 ms`,
+ `${atDefault}/${probes.length} timed out at the default, ${atLarge}/${probes.length} at ${extendedWait} ms`,
atDefault ? "high" : "low",
);
},