fix: collapse qmd startup memory log

This commit is contained in:
Peter Steinberger
2026-04-23 22:10:28 +01:00
parent f3aaafbd70
commit 58bde71908
2 changed files with 18 additions and 10 deletions

View File

@@ -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();
});

View File

@@ -11,6 +11,7 @@ export async function startGatewayMemoryBackend(params: {
log: { info?: (msg: string) => void; warn: (msg: string) => void };
}): Promise<void> {
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`;
}