From 566bbeb01867d306a1a12a5a487b08297cf1286b Mon Sep 17 00:00:00 2001 From: kartik-mem0 Date: Mon, 6 Apr 2026 16:24:37 +0530 Subject: [PATCH] refactor: rename memory tool set and update CLI alias handling --- openclaw/index.ts | 8 ++++---- openclaw/tests/cli-commands.test.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openclaw/index.ts b/openclaw/index.ts index 41b7beab7..32e3648cb 100644 --- a/openclaw/index.ts +++ b/openclaw/index.ts @@ -775,14 +775,14 @@ function registerHooks( // Update shared state for tools (best-effort — tools don't have ctx) if (sessionId) session.setCurrentSessionId(sessionId); - const MEMORY_WRITE_TOOLS = new Set(["memory_add", "memory_update"]); - const agentUsedWriteTool = event.messages.some((msg: any) => { + const MEMORY_MUTATE_TOOLS = new Set(["memory_add", "memory_update", "memory_delete"]); + const agentUsedMemoryTool = event.messages.some((msg: any) => { if (msg?.role !== "assistant" || !Array.isArray(msg?.content)) return false; return msg.content.some( - (block: any) => block?.type === "tool_use" && MEMORY_WRITE_TOOLS.has(block.name), + (block: any) => block?.type === "tool_use" && MEMORY_MUTATE_TOOLS.has(block.name), ); }); - if (agentUsedWriteTool) { + if (agentUsedMemoryTool) { api.logger.info( "openclaw-mem0: skipping auto-capture — agent already used memory tools this turn", ); diff --git a/openclaw/tests/cli-commands.test.ts b/openclaw/tests/cli-commands.test.ts index ae9f06d44..9233f54d2 100644 --- a/openclaw/tests/cli-commands.test.ts +++ b/openclaw/tests/cli-commands.test.ts @@ -940,9 +940,9 @@ describe("registerCliCommands", () => { const allOutput = consoleSpy.log.mock.calls.map((c) => c[0]).join("\n"); expect(allOutput).toContain("Key"); expect(allOutput).toContain("Value"); - expect(allOutput).toContain("platform.api_key"); - expect(allOutput).toContain("platform.email"); - expect(allOutput).toContain("defaults.user_id"); + expect(allOutput).toContain("api_key"); + expect(allOutput).toContain("email"); + expect(allOutput).toContain("user_id"); expect(allOutput).toContain("Config file:"); }); }); @@ -1002,12 +1002,12 @@ describe("registerCliCommands", () => { expect(logged).not.toContain("supersecret"); }); - it("supports dot-notation keys like platform.api_key", () => { + it("supports short alias keys like email", () => { const { mem0 } = setup(); const configCmd = findCommand(mem0, "config")!; const getCmd = findCommand(configCmd, "get")!; - getCmd._action!("platform.email"); + getCmd._action!("email"); expect(consoleSpy.log).toHaveBeenCalledWith("(not set)"); }); @@ -1119,12 +1119,12 @@ describe("registerCliCommands", () => { expect(writePluginAuth).not.toHaveBeenCalled(); }); - it("supports dot-notation keys for set", () => { + it("supports short alias keys for set", () => { const { mem0 } = setup(); const configCmd = findCommand(mem0, "config")!; const setCmd = findCommand(configCmd, "set")!; - setCmd._action!("defaults.user_id", "bob"); + setCmd._action!("user_id", "bob"); expect(writePluginAuth).toHaveBeenCalledWith( expect.objectContaining({ userId: "bob" }),