Skip to content

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

fix(claude): turn off Claude Code's own memory in bot turns

milind-sonibae721bf6fab
diff --git a/server/drivers/claude-own-memory.ts b/server/drivers/claude-own-memory.ts
new file mode 100644
index 0000000000..cadb8cc8d1
--- /dev/null
+++ b/server/drivers/claude-own-memory.ts
@@ -0,0 +1,6 @@
+// Claude Code keeps an auto-memory of its own: a folder per working folder, named in about 4k tokens of system prompt. A bot's
+// memory is OpenMausBot's, and a bot's working folder is per thread, so that second memory split notes by thread (a note saved
+// in one is gone in the next), sent bots searching the wrong folder for their notes, and put a per-thread path in the system
+// prompt, which made every new thread write the rest of the prompt to the provider's cache again. An isolated turn turns it off
+// in its private settings, which beat the project's and the person's own; a bot that inherits this machine's setup keeps it.
+export const CLAUDE_OWN_MEMORY_OFF = { CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" } as const;
diff --git a/server/drivers/claude.test.ts b/server/drivers/claude.test.ts
index d33d86e712..11dac6fc00 100644
--- a/server/drivers/claude.test.ts
+++ b/server/drivers/claude.test.ts
@@ -1678,6 +1678,8 @@ describe("ClaudeDriver turns (fake CLI)", () => {
expect(seen.argv).toContain("--strict-mcp-config");
expect(seen.argv[seen.argv.indexOf("--setting-sources") + 1]).toBe("project");
expect(seen.settings.claudeMdExcludes).toEqual([join(homedir(), ".claude", "CLAUDE.md")]);
+ // A bot's memory is OpenMausBot's: the CLI's per-folder one would split notes by thread and break the cached prompt.
+ expect(seen.settings.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY).toBe("1");
});
it("inherits the machine's configuration again when the escape hatch is set", async () => {
@@ -1691,6 +1693,7 @@ describe("ClaudeDriver turns (fake CLI)", () => {
expect(seen.argv).not.toContain("--strict-mcp-config");
expect(seen.argv).not.toContain("--setting-sources");
expect(seen.settings?.claudeMdExcludes).toBeUndefined();
+ expect(seen.settings?.env?.CLAUDE_CODE_DISABLE_AUTO_MEMORY).toBeUndefined();
});
it("loads the machine's own MCP servers when the turn asks, keeping the rest isolated", async () => {
@@ -1810,7 +1813,7 @@ describe("ClaudeDriver turns (fake CLI)", () => {
await instance.adapter.sendTurn({ threadId: "t-auth-settings", text: "hi" });
await recorder.until((e) => e.type === "turn.completed");
const seen = JSON.parse(readFileSync(dump, "utf8"));
- expect(seen.settings).toEqual({ claudeMdExcludes: [join(homedir(), ".claude", "CLAUDE.md")], apiKeyHelper: settings.apiKeyHelper, env: { ANTHROPIC_BASE_URL: settings.env.ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN: "synthetic-token", ENABLE_TOOL_SEARCH: "true" } });
+ expect(seen.settings).toEqual({ claudeMdExcludes: [join(homedir(), ".claude", "CLAUDE.md")], apiKeyHelper: settings.apiKeyHelper, env: { ANTHROPIC_BASE_URL: settings.env.ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN: "synthetic-token", ENABLE_TOOL_SEARCH: "true", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" } });
expect(seen.argv[seen.argv.indexOf("--setting-sources") + 1]).toBe("project");
expect(JSON.stringify(seen.argv)).not.toContain("synthetic");
const settingsPath = seen.argv[seen.argv.indexOf("--settings") + 1];
@@ -1914,7 +1917,7 @@ describe("ClaudeDriver turns (fake CLI)", () => {
await instance.adapter.sendTurn({ threadId: "t-auth-explicit", text: "hi" });
await recorder.until((e) => e.type === "turn.completed");
const seen = JSON.parse(readFileSync(dump, "utf8"));
- expect(seen.settings).toEqual({ claudeMdExcludes: [join(homedir(), ".claude", "CLAUDE.md")], env: { ENABLE_TOOL_SEARCH: "true" } });
+ expect(seen.settings).toEqual({ claudeMdExcludes: [join(homedir(), ".claude", "CLAUDE.md")], env: { ENABLE_TOOL_SEARCH: "true", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" } });
expect(seen.env.ANTHROPIC_API_KEY).toBe("workspace-key");
expect(seen.env.ANTHROPIC_BASE_URL).toBeUndefined();
expect(readClaudeAuthSettings({ HOME: scratch, CLAUDE_CONFIG_DIR: join(scratch, "other-account") })).toEqual({});
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 8c58a11eb7..02687440b6 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -46,7 +46,7 @@ import { createOrgModelBlocks, modelSwapNotice, withOrgBlocks } from "./claude-m
import { engineHomes } from "../engine-homes/engine-homes.ts";
import { TEAM_TOOLS_FAILED, failedCustomMcp, teamToolsFailed } from "./team-tools.ts";
import { armIdleClose, engineIdleMs, sessionIdlePolicy, stopIdleClose } from "./session-idle.ts";
-import { promptHalves, withVolatileNote } from "./prompt-split.ts";
+import { promptHalves, withVolatileNote } from "./prompt-split.ts"; import { CLAUDE_OWN_MEMORY_OFF } from "./claude-own-memory.ts";
import { parseVersionTriple, versionAtLeast } from "./acp/version-probe.ts";
import {
applyClaudeInject,
@@ -1169,7 +1169,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
const cwd = turn.cwd ?? homedir();
// Every MCP server without alwaysLoad loads on demand behind ToolSearch (claude-tool-search.ts).
const toolSearch = claudeToolSearchSetting(cwd, env);
- const own: Record<string, unknown> = { ...authSettings, env: { ...authSettings.env, ENABLE_TOOL_SEARCH: toolSearch } };
+ const own: Record<string, unknown> = { ...authSettings, env: { ...authSettings.env, ENABLE_TOOL_SEARCH: toolSearch, ...(isolated ? CLAUDE_OWN_MEMORY_OFF : {}) } };
// Project-only settings still find the personal memory via ancestors when the bot lives under HOME.
if (isolated) own.claudeMdExcludes = [join(homedir(), ".claude", "CLAUDE.md")];
if (hooks) own.hooks = claudeHookSettings(HOOK_HELPER_PATH);