mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
test(memory): pin disabled lifecycle hook wiring
This commit is contained in:
@@ -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] }],
|
||||
|
||||
Reference in New Issue
Block a user