Memory/QMD: cap qmd command output buffering

This commit is contained in:
Vignesh Natarajan
2026-02-14 14:55:59 -08:00
parent 9b9dc65a22
commit f9f816d139
3 changed files with 55 additions and 2 deletions

View File

@@ -829,6 +829,30 @@ describe("QmdMemoryManager", () => {
await manager.close();
});
it("errors when qmd output exceeds command output safety cap", async () => {
const noisyPayload = "x".repeat(240_000);
spawnMock.mockImplementation((_cmd: string, args: string[]) => {
if (args[0] === "search") {
const child = createMockChild({ autoClose: false });
emitAndClose(child, "stdout", noisyPayload);
return child;
}
return createMockChild();
});
const resolved = resolveMemoryBackendConfig({ cfg, agentId });
const manager = await QmdMemoryManager.create({ cfg, agentId, resolved });
expect(manager).toBeTruthy();
if (!manager) {
throw new Error("manager missing");
}
await expect(
manager.search("noise", { sessionKey: "agent:main:slack:dm:u123" }),
).rejects.toThrow(/too much output/);
await manager.close();
});
it("treats plain-text no-results stdout as an empty result set", async () => {
spawnMock.mockImplementation((_cmd: string, args: string[]) => {
if (args[0] === "search") {