Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Memory: a supersede that fails keeps the forgotten marker

Bugfixer 29a0971b4a70c
diff --git a/server/drivers/agents-call.test.ts b/server/drivers/agents-call.test.ts
index 4499c2c207..f49f3f5dce 100644
--- a/server/drivers/agents-call.test.ts
+++ b/server/drivers/agents-call.test.ts
@@ -372,6 +372,17 @@ describe("memory_update", () => {
expect(isForgotten("The person likes long replies")).toBe(false);
});
+ it("keeps a forgotten fact blocked when a supersede names an entry that is not there", async () => {
+ const bot = "bot-memory-supersede-stale";
+ const ctx = context({ botId: bot, client: harness(bot) });
+ expect((await callTool("memory_update", { action: "append", text: "The person wants replies in English" }, ctx)).isError).toBeFalsy();
+ expect((await callTool("memory_update", { action: "forget", old_text: "long replies" }, ctx)).isError).toBeFalsy();
+
+ const stale = await callTool("memory_update", { action: "supersede", old_text: "The person wants replies in French", text: "The person wants long replies in English" }, ctx);
+ expect(stale.isError).toBe(true);
+ expect(isForgotten("The person likes long replies")).toBe(true);
+ });
+
it("removes a whole dated entry when only its fact is named, never leaving a note with a date and no text", async () => {
const bot = "bot-memory-remove";
writeMemoryFile(bot, '- 2026-10-27 · from chat "Remember" (noticed) · The person prefers short answers\n- Keep this unique fact.\n');
diff --git a/server/memory-forget.ts b/server/memory-forget.ts
index e7bffaae99..09c9a6cf98 100644
--- a/server/memory-forget.ts
+++ b/server/memory-forget.ts
@@ -116,6 +116,9 @@ export function botMemoryUpdate(
rememberForgotten(passage, mentions);
return { ok: true, forgotten, aboutMe };
}
- if ((body.action === "append" || body.action === "supersede") && typeof body.text === "string") clearForgotten(body.text);
- return updateMemory(layer, { action: body.action, text: body.text, oldText: body.oldText, ...(body.until !== undefined ? { until: body.until } : {}) } as MemoryUpdate, { source: opts.source });
+ if (body.action === "append" && typeof body.text === "string") clearForgotten(body.text);
+ const result = updateMemory(layer, { action: body.action, text: body.text, oldText: body.oldText, ...(body.until !== undefined ? { until: body.until } : {}) } as MemoryUpdate, { source: opts.source });
+ // A supersede restores the fact only once the old entry was really replaced; a stale old_text keeps the marker.
+ if (body.action === "supersede" && result.ok && typeof body.text === "string") clearForgotten(body.text);
+ return result;
}