From ccb126290fcfbff1aefb323b0a1d40c2feb22fbb Mon Sep 17 00:00:00 2001 From: MOLW <85048713+MatrixAdventurer@users.noreply.github.com> Date: Wed, 21 Oct 2026 14:18:58 +0800 Subject: [PATCH] fix(openclaw): forward retrieval memory type filters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass configured memory types through the OpenClaw client and HTTP adapter, with regression coverage for supplied and omitted filters. 由 LW 授权的 ChatGPT Business 智能体提交。 --- .../openclaw/openclaw/__tests__/client.test.ts | 18 ++++++++++++++++++ plugins/openclaw/openclaw/client.ts | 1 + plugins/openclaw/openclaw/http-client.ts | 1 + 3 files changed, 20 insertions(+) diff --git a/plugins/openclaw/openclaw/__tests__/client.test.ts b/plugins/openclaw/openclaw/__tests__/client.test.ts index cfe94089..9f90c045 100644 --- a/plugins/openclaw/openclaw/__tests__/client.test.ts +++ b/plugins/openclaw/openclaw/__tests__/client.test.ts @@ -14,6 +14,24 @@ afterEach(() => { }); describe("Group 5: Session & Backend Routing", () => { + it("passes configured retrieval memory types to the API without changing omitted filters", async () => { + const fetchMock = mockFetch(); + fetchMock.respondWith(200, { results: [] }); + const client = new MemoriaClient(buildApiConfig()); + try { + await client.retrieve({ userId: "u1", query: "type-filter", topK: 3, memoryTypes: ["episodic", "profile"] }); + expect(fetchMock.lastCall()!.body).toMatchObject({ + query: "type-filter", + top_k: 3, + memory_types: ["episodic", "profile"], + }); + await client.retrieve({ userId: "u1", query: "no-filter", topK: 2 }); + expect(fetchMock.lastCall()!.body).toEqual({ query: "no-filter", top_k: 2 }); + } finally { + client.close(); + } + }); + it("5.1 getSession with backend=api returns MemoriaHttpTransport", async () => { const fetchMock = mockFetch(); fetchMock.respondWith(200, { results: [] }); diff --git a/plugins/openclaw/openclaw/client.ts b/plugins/openclaw/openclaw/client.ts index 9240b2b9..a79d4893 100644 --- a/plugins/openclaw/openclaw/client.ts +++ b/plugins/openclaw/openclaw/client.ts @@ -387,6 +387,7 @@ export class MemoriaClient { const text = await this.callToolText(params.userId, "memory_retrieve", { query: params.query, top_k: params.topK, + memory_types: params.memoryTypes, session_id: params.sessionId, }); const memories = parseMemoryTextList(text); diff --git a/plugins/openclaw/openclaw/http-client.ts b/plugins/openclaw/openclaw/http-client.ts index 80c3f106..330eedba 100644 --- a/plugins/openclaw/openclaw/http-client.ts +++ b/plugins/openclaw/openclaw/http-client.ts @@ -133,6 +133,7 @@ export class MemoriaHttpTransport { top_k: args.top_k ?? 5, }; if (args.session_id) body.session_id = args.session_id; + if (args.memory_types !== undefined) body.memory_types = args.memory_types; const data = await this.post("/v1/memories/retrieve", body); return this.formatMemoryList(data); }