diff --git a/src/gateway/server-startup-memory.test.ts b/src/gateway/server-startup-memory.test.ts index ca37b027b86..bf1d040e6fb 100644 --- a/src/gateway/server-startup-memory.test.ts +++ b/src/gateway/server-startup-memory.test.ts @@ -61,13 +61,9 @@ describe("startGatewayMemoryBackend", () => { expect(getMemorySearchManagerMock).toHaveBeenCalledTimes(2); expect(getMemorySearchManagerMock).toHaveBeenNthCalledWith(1, { cfg, agentId: "ops" }); expect(getMemorySearchManagerMock).toHaveBeenNthCalledWith(2, { cfg, agentId: "main" }); - expect(log.info).toHaveBeenNthCalledWith( - 1, - 'qmd memory startup initialization armed for agent "ops"', - ); - expect(log.info).toHaveBeenNthCalledWith( - 2, - 'qmd memory startup initialization armed for agent "main"', + expect(log.info).toHaveBeenCalledTimes(1); + expect(log.info).toHaveBeenCalledWith( + 'qmd memory startup initialization armed for 2 agents: "ops", "main"', ); expect(log.warn).not.toHaveBeenCalled(); }); @@ -85,7 +81,7 @@ describe("startGatewayMemoryBackend", () => { 'qmd memory startup initialization failed for agent "main": qmd missing', ); expect(log.info).toHaveBeenCalledWith( - 'qmd memory startup initialization armed for agent "ops"', + 'qmd memory startup initialization armed for 1 agent: "ops"', ); }); @@ -105,7 +101,7 @@ describe("startGatewayMemoryBackend", () => { expect(getMemorySearchManagerMock).toHaveBeenCalledTimes(1); expect(getMemorySearchManagerMock).toHaveBeenCalledWith({ cfg, agentId: "main" }); expect(log.info).toHaveBeenCalledWith( - 'qmd memory startup initialization armed for agent "main"', + 'qmd memory startup initialization armed for 1 agent: "main"', ); expect(log.warn).not.toHaveBeenCalled(); }); diff --git a/src/gateway/server-startup-memory.ts b/src/gateway/server-startup-memory.ts index acc99881918..ace12fe0113 100644 --- a/src/gateway/server-startup-memory.ts +++ b/src/gateway/server-startup-memory.ts @@ -11,6 +11,7 @@ export async function startGatewayMemoryBackend(params: { log: { info?: (msg: string) => void; warn: (msg: string) => void }; }): Promise { const agentIds = listAgentIds(params.cfg); + const armedAgentIds: string[] = []; for (const agentId of agentIds) { if (!resolveMemorySearchConfig(params.cfg, agentId)) { continue; @@ -30,6 +31,17 @@ export async function startGatewayMemoryBackend(params: { ); continue; } - params.log.info?.(`qmd memory startup initialization armed for agent "${agentId}"`); + armedAgentIds.push(agentId); + } + if (armedAgentIds.length > 0) { + params.log.info?.( + `qmd memory startup initialization armed for ${formatAgentCount(armedAgentIds.length)}: ${armedAgentIds + .map((agentId) => `"${agentId}"`) + .join(", ")}`, + ); } } + +function formatAgentCount(count: number): string { + return count === 1 ? "1 agent" : `${count} agents`; +}