mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:47:39 +00:00
Memory: make QMD cache eviction callback idempotent
This commit is contained in:
committed by
Vignesh
parent
c741d008dd
commit
6f1ba986b3
@@ -114,4 +114,35 @@ describe("getMemorySearchManager caching", () => {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
expect(QmdMemoryManager.create).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("does not evict a newer cached wrapper when closing an older failed wrapper", async () => {
|
||||
const retryAgentId = "retry-agent-close";
|
||||
const cfg = {
|
||||
memory: { backend: "qmd", qmd: {} },
|
||||
agents: { list: [{ id: retryAgentId, default: true, workspace: "/tmp/workspace" }] },
|
||||
} as const;
|
||||
|
||||
mockPrimary.search.mockRejectedValueOnce(new Error("qmd query failed"));
|
||||
|
||||
const first = await getMemorySearchManager({ cfg, agentId: retryAgentId });
|
||||
expect(first.manager).toBeTruthy();
|
||||
if (!first.manager) {
|
||||
throw new Error("manager missing");
|
||||
}
|
||||
await first.manager.search("hello");
|
||||
|
||||
const second = await getMemorySearchManager({ cfg, agentId: retryAgentId });
|
||||
expect(second.manager).toBeTruthy();
|
||||
if (!second.manager) {
|
||||
throw new Error("manager missing");
|
||||
}
|
||||
expect(second.manager).not.toBe(first.manager);
|
||||
|
||||
await first.manager.close?.();
|
||||
|
||||
const third = await getMemorySearchManager({ cfg, agentId: retryAgentId });
|
||||
expect(third.manager).toBe(second.manager);
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
expect(QmdMemoryManager.create).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user