From 97a41a6509947f4dd6705c57cb7de4f5d230d897 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 16 Jan 2026 21:41:55 +0000 Subject: [PATCH] fix: suppress zero sub-agent stop note --- ...dling.filters-usage-summary-current-model-provider.test.ts | 4 ++-- ...rigger-handling.targets-active-session-native-stop.test.ts | 2 +- src/auto-reply/reply/abort.ts | 2 +- src/auto-reply/reply/dispatch-from-config.test.ts | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.test.ts b/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.test.ts index 6403627d5..fd43f3a0c 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.test.ts @@ -222,7 +222,7 @@ describe("trigger handling", () => { makeCfg(home), ); const text = Array.isArray(res) ? res[0]?.text : res?.text; - expect(text).toBe("⚙️ Agent was aborted. Stopped 0 sub-agents."); + expect(text).toBe("⚙️ Agent was aborted."); expect(runEmbeddedPiAgent).not.toHaveBeenCalled(); }); }); @@ -238,7 +238,7 @@ describe("trigger handling", () => { makeCfg(home), ); const text = Array.isArray(res) ? res[0]?.text : res?.text; - expect(text).toBe("⚙️ Agent was aborted. Stopped 0 sub-agents."); + expect(text).toBe("⚙️ Agent was aborted."); expect(runEmbeddedPiAgent).not.toHaveBeenCalled(); }); }); diff --git a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.test.ts b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.test.ts index 5768fad42..be6393c25 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.test.ts @@ -159,7 +159,7 @@ describe("trigger handling", () => { ); const text = Array.isArray(res) ? res[0]?.text : res?.text; - expect(text).toBe("⚙️ Agent was aborted. Stopped 0 sub-agents."); + expect(text).toBe("⚙️ Agent was aborted."); expect(vi.mocked(abortEmbeddedPiRun)).toHaveBeenCalledWith(targetSessionId); const store = loadSessionStore(cfg.session.store); expect(store[targetSessionKey]?.abortedLastRun).toBe(true); diff --git a/src/auto-reply/reply/abort.ts b/src/auto-reply/reply/abort.ts index 65f221ba9..0d9f7b028 100644 --- a/src/auto-reply/reply/abort.ts +++ b/src/auto-reply/reply/abort.ts @@ -35,7 +35,7 @@ export function setAbortMemory(key: string, value: boolean): void { } export function formatAbortReplyText(stoppedSubagents?: number): string { - if (typeof stoppedSubagents !== "number") { + if (typeof stoppedSubagents !== "number" || stoppedSubagents <= 0) { return "⚙️ Agent was aborted."; } const label = stoppedSubagents === 1 ? "sub-agent" : "sub-agents"; diff --git a/src/auto-reply/reply/dispatch-from-config.test.ts b/src/auto-reply/reply/dispatch-from-config.test.ts index bc8d048e5..2dac96ca1 100644 --- a/src/auto-reply/reply/dispatch-from-config.test.ts +++ b/src/auto-reply/reply/dispatch-from-config.test.ts @@ -25,7 +25,9 @@ vi.mock("./route-reply.js", () => ({ vi.mock("./abort.js", () => ({ tryFastAbortFromMessage: mocks.tryFastAbortFromMessage, formatAbortReplyText: (stoppedSubagents?: number) => { - if (typeof stoppedSubagents !== "number") return "⚙️ Agent was aborted."; + if (typeof stoppedSubagents !== "number" || stoppedSubagents <= 0) { + return "⚙️ Agent was aborted."; + } const label = stoppedSubagents === 1 ? "sub-agent" : "sub-agents"; return `⚙️ Agent was aborted. Stopped ${stoppedSubagents} ${label}.`; },