fix: suppress zero sub-agent stop note
This commit is contained in:
@@ -222,7 +222,7 @@ describe("trigger handling", () => {
|
|||||||
makeCfg(home),
|
makeCfg(home),
|
||||||
);
|
);
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
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();
|
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -238,7 +238,7 @@ describe("trigger handling", () => {
|
|||||||
makeCfg(home),
|
makeCfg(home),
|
||||||
);
|
);
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
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();
|
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ describe("trigger handling", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
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);
|
expect(vi.mocked(abortEmbeddedPiRun)).toHaveBeenCalledWith(targetSessionId);
|
||||||
const store = loadSessionStore(cfg.session.store);
|
const store = loadSessionStore(cfg.session.store);
|
||||||
expect(store[targetSessionKey]?.abortedLastRun).toBe(true);
|
expect(store[targetSessionKey]?.abortedLastRun).toBe(true);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function setAbortMemory(key: string, value: boolean): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatAbortReplyText(stoppedSubagents?: number): string {
|
export function formatAbortReplyText(stoppedSubagents?: number): string {
|
||||||
if (typeof stoppedSubagents !== "number") {
|
if (typeof stoppedSubagents !== "number" || stoppedSubagents <= 0) {
|
||||||
return "⚙️ Agent was aborted.";
|
return "⚙️ Agent was aborted.";
|
||||||
}
|
}
|
||||||
const label = stoppedSubagents === 1 ? "sub-agent" : "sub-agents";
|
const label = stoppedSubagents === 1 ? "sub-agent" : "sub-agents";
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ vi.mock("./route-reply.js", () => ({
|
|||||||
vi.mock("./abort.js", () => ({
|
vi.mock("./abort.js", () => ({
|
||||||
tryFastAbortFromMessage: mocks.tryFastAbortFromMessage,
|
tryFastAbortFromMessage: mocks.tryFastAbortFromMessage,
|
||||||
formatAbortReplyText: (stoppedSubagents?: number) => {
|
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";
|
const label = stoppedSubagents === 1 ? "sub-agent" : "sub-agents";
|
||||||
return `⚙️ Agent was aborted. Stopped ${stoppedSubagents} ${label}.`;
|
return `⚙️ Agent was aborted. Stopped ${stoppedSubagents} ${label}.`;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user