Memory/QMD: harden multi-collection search and embed scheduling

This commit is contained in:
Vignesh Natarajan
2026-02-20 19:41:13 -08:00
parent 282a545130
commit a305dfe626
6 changed files with 369 additions and 79 deletions

View File

@@ -73,4 +73,28 @@ describe("startGatewayMemoryBackend", () => {
'qmd memory startup initialization armed for agent "ops"',
);
});
it("skips agents with memory search disabled", async () => {
const cfg = {
agents: {
defaults: { memorySearch: { enabled: true } },
list: [
{ id: "main", default: true },
{ id: "ops", memorySearch: { enabled: false } },
],
},
memory: { backend: "qmd", qmd: {} },
} as OpenClawConfig;
const log = { info: vi.fn(), warn: vi.fn() };
getMemorySearchManagerMock.mockResolvedValue({ manager: { search: vi.fn() } });
await startGatewayMemoryBackend({ cfg, log });
expect(getMemorySearchManagerMock).toHaveBeenCalledTimes(1);
expect(getMemorySearchManagerMock).toHaveBeenCalledWith({ cfg, agentId: "main" });
expect(log.info).toHaveBeenCalledWith(
'qmd memory startup initialization armed for agent "main"',
);
expect(log.warn).not.toHaveBeenCalled();
});
});

View File

@@ -1,4 +1,5 @@
import { listAgentIds } from "../agents/agent-scope.js";
import { resolveMemorySearchConfig } from "../agents/memory-search.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveMemoryBackendConfig } from "../memory/backend-config.js";
import { getMemorySearchManager } from "../memory/index.js";
@@ -9,6 +10,9 @@ export async function startGatewayMemoryBackend(params: {
}): Promise<void> {
const agentIds = listAgentIds(params.cfg);
for (const agentId of agentIds) {
if (!resolveMemorySearchConfig(params.cfg, agentId)) {
continue;
}
const resolved = resolveMemoryBackendConfig({ cfg: params.cfg, agentId });
if (resolved.backend !== "qmd" || !resolved.qmd) {
continue;