test(memory): pin disabled lifecycle hook wiring

This commit is contained in:
Vincent Koc
2026-04-22 12:43:01 -07:00
parent f97c6f8a04
commit 1e33d63f64

View File

@@ -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] }],