Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(memory_update): read a blank old_text on append as left out, and name the field when append gets one
AdityaUmalef340197a998e
diff --git a/server/drivers/agents-blank-arguments.ts b/server/drivers/agents-blank-arguments.tsindex 650ef5741a..b188298e02 100644--- a/server/drivers/agents-blank-arguments.ts+++ b/server/drivers/agents-blank-arguments.ts@@ -11,7 +11,7 @@ const BLANK_MEANS_LEFT_OUT: Readonly<Record<string, readonly string[]>> = {coordinate_bots: ["group_id", "reason", "thread", "title", "reply", "done_when", "answers", "files"],session_search: ["thread_id", "message_id", "query", "since", "until", "scope"],show_html: ["html", "jsx", "path"],- // A blank text or old_text is a mistake the schema names, not "not given".+ // A blank text, or a blank old_text where the action needs one, is a mistake the schema names, not "not given".memory_update: ["until"],};@@ -60,5 +60,7 @@ export function dropBlankArguments(name: string, input: Json): Json {const selectionKey = Object.hasOwn(MODEL_CHOICE_ARGUMENT, name) ? MODEL_CHOICE_ARGUMENT[name] : undefined;if (selectionKey && input[selectionKey] !== undefined) return { ...input, [selectionKey]: withoutBlankModelChoice(input[selectionKey]) };const keys = Object.hasOwn(BLANK_MEANS_LEFT_OUT, name) ? BLANK_MEANS_LEFT_OUT[name] : undefined;- return keys ? withoutBlank(input, keys, blankText) : input;+ const given = keys ? withoutBlank(input, keys, blankText) : input;+ // append and prefer never use old_text, so a blank or null one there is only "not given".+ return name === "memory_update" && (input.action === "append" || input.action === "prefer") ? withoutBlank(given, ["old_text"]) : given;}diff --git a/server/drivers/agents-call.test.ts b/server/drivers/agents-call.test.tsindex cfd4277f28..eef8f03003 100644--- a/server/drivers/agents-call.test.ts+++ b/server/drivers/agents-call.test.ts@@ -427,6 +427,25 @@ describe("memory_update", () => {expect(isForgotten("The person likes long replies")).toBe(true);});+ it("reads a blank old_text on append or prefer as left out, since neither uses it", async () => {+ const bot = "bot-memory-blank-old-text";+ const ctx = context({ botId: bot, client: harness(bot) });+ for (const old_text of ["", " ", null]) {+ const saved = await callTool("memory_update", { action: "append", text: `Exam on Friday ${JSON.stringify(old_text)}`, old_text, until: "2026-12-01" }, ctx);+ expect(saved.isError, saved.text).toBeFalsy();+ }+ expect(readMemoryFile(bot).text).toContain("Exam on Friday \"\"");+ expect(await callTool("memory_update", { action: "replace", old_text: "", text: "x" }, ctx)).toMatchObject({ isError: true, text: expect.stringContaining("old_text must not be empty") });+ });++ it("says old_text is not used with append instead of a generic error, and saves nothing", async () => {+ const bot = "bot-memory-append-old-text";+ const ctx = context({ botId: bot, client: harness(bot) });+ const refused = await callTool("memory_update", { action: "append", old_text: "exam", text: "Exam on Friday" }, ctx);+ expect(refused).toEqual({ isError: true, text: "memory_update was not run: old_text is not used with append. Leave it out to add a new note, or use replace or supersede to change the passage it names." });+ expect(readMemoryFile(bot).text).not.toContain("Exam on Friday");+ });+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/drivers/agents-call.ts b/server/drivers/agents-call.tsindex 3301416fe9..d7be481b3e 100644--- a/server/drivers/agents-call.ts+++ b/server/drivers/agents-call.ts@@ -739,6 +739,7 @@ export async function callTool(called: string, input: Json, context: ToolCallCon|| (args.action !== "append" && args.action !== "prefer" && (typeof args.old_text !== "string" || !args.old_text.trim()))) {return { text: "Use memory_update action=append with text, replace or supersede with text and old_text, remove with old_text, forget with old_text naming what to forget, or prefer with text: one standing preference of the person.", isError: true };}+ if (args.action === "append" && args.old_text !== undefined) return { text: "memory_update was not run: old_text is not used with append. Leave it out to add a new note, or use replace or supersede to change the passage it names.", isError: true };const { body: r } = await apiResponse("/api/internal/memory", {method: "POST",body: JSON.stringify({