diff --git a/extensions/memory-lancedb/index.test.ts b/extensions/memory-lancedb/index.test.ts index fff9aad4109..31014a024c9 100644 --- a/extensions/memory-lancedb/index.test.ts +++ b/extensions/memory-lancedb/index.test.ts @@ -201,6 +201,78 @@ describe("memory plugin e2e", () => { expect(on).not.toHaveBeenCalledWith("before_agent_start", expect.any(Function)); }); + test("does not register before_prompt_build when auto-recall is disabled", async () => { + const on = vi.fn(); + const mockApi = { + id: "memory-lancedb", + name: "Memory (LanceDB)", + source: "test", + config: {}, + pluginConfig: { + embedding: { + apiKey: OPENAI_API_KEY, + model: "text-embedding-3-small", + }, + dbPath: getDbPath(), + autoCapture: true, + autoRecall: false, + }, + runtime: {}, + logger: { + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + debug: vi.fn(), + }, + registerTool: vi.fn(), + registerCli: vi.fn(), + registerService: vi.fn(), + on, + resolvePath: (filePath: string) => filePath, + }; + + memoryPlugin.register(mockApi as any); + + expect(on).not.toHaveBeenCalledWith("before_prompt_build", expect.any(Function)); + expect(on).toHaveBeenCalledWith("agent_end", expect.any(Function)); + }); + + test("does not register agent_end when auto-capture is disabled", async () => { + const on = vi.fn(); + const mockApi = { + id: "memory-lancedb", + name: "Memory (LanceDB)", + source: "test", + config: {}, + pluginConfig: { + embedding: { + apiKey: OPENAI_API_KEY, + model: "text-embedding-3-small", + }, + dbPath: getDbPath(), + autoCapture: false, + autoRecall: true, + }, + runtime: {}, + logger: { + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + debug: vi.fn(), + }, + registerTool: vi.fn(), + registerCli: vi.fn(), + registerService: vi.fn(), + on, + resolvePath: (filePath: string) => filePath, + }; + + memoryPlugin.register(mockApi as any); + + expect(on).toHaveBeenCalledWith("before_prompt_build", expect.any(Function)); + expect(on).not.toHaveBeenCalledWith("agent_end", expect.any(Function)); + }); + test("runs auto-recall through the registered before_prompt_build hook", async () => { const embeddingsCreate = vi.fn(async () => ({ data: [{ embedding: [0.1, 0.2, 0.3] }],