Skip to content

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

test(memory): builtin clean-up verifies the run's threads and tag list empty

M3gA-Mind07dbc06c49b5
diff --git a/scripts/memory-scenarios/README.md b/scripts/memory-scenarios/README.md
index fd6ef0285a..6a3b46d1d5 100644
--- a/scripts/memory-scenarios/README.md
+++ b/scripts/memory-scenarios/README.md
@@ -110,7 +110,8 @@ running it.
- **Everything the run writes is removed.** Each item carries a run marker
(`thread-<uuid>` threads, a `memscen:<run>` tag); every id it stores is
recorded; teardown forgets exactly those, plus every item in the run's
- threads and every item with its tag, then checks each is gone. Survivors are
+ threads and every item with its tag, then checks each id is gone and that
+ the tag and every thread list empty. Survivors are
reported as a finding. Beliefs the engine derives on its own from the run's
items cannot be traced back to the run and are not cleaned up.
- **The clean-up fails closed.** The ids, threads and marker are written to
diff --git a/scripts/memory-scenarios/run.mjs b/scripts/memory-scenarios/run.mjs
index 71c37e1678..f43261dca8 100644
--- a/scripts/memory-scenarios/run.mjs
+++ b/scripts/memory-scenarios/run.mjs
@@ -739,6 +739,19 @@ async function runEngine(engine, { opts, runDir, runId, findings, results }) {
throw new Error(
`could not list ${unlisted.join(", ")}; items there may survive`,
);
+ // And nothing the run's threads or tag hold is left either.
+ const filters = [
+ ...threads.map((t) => ({ thread_id: t })),
+ { tags_any: [marker] },
+ ];
+ for (const filter of filters) {
+ const left = await core.rpc("openhuman.memory_items_list", {
+ filter,
+ limit: 100,
+ });
+ for (const h of left?.items ?? []) survivors.push(h.id);
+ }
+ engineResults.cleanupListsEmpty = filters.length;
const untouched = guardPlaced
? await verifyBuiltinUntouched(core)
: {
@@ -784,7 +797,7 @@ async function runEngine(engine, { opts, runDir, runId, findings, results }) {
basis: "READ",
});
console.log(
- `builtin : cleanup forgot ${ledger.list().length} ids, ${survivors.length} survived; migration/import untouched: ${untouched.ok}`,
+ `builtin : cleanup forgot ${ledger.list().length} ids, ${survivors.length} survived (${engineResults.cleanupListsEmpty} thread/tag lists re-read); migration/import untouched: ${untouched.ok}`,
);
} catch (e) {
findings.add({