fix: /stop aborts subagents

This commit is contained in:
Peter Steinberger
2026-01-16 21:37:11 +00:00
parent 390bd11f33
commit a0be85c34c
11 changed files with 198 additions and 12 deletions
@@ -24,6 +24,11 @@ vi.mock("./route-reply.js", () => ({
vi.mock("./abort.js", () => ({
tryFastAbortFromMessage: mocks.tryFastAbortFromMessage,
formatAbortReplyText: (stoppedSubagents?: number) => {
if (typeof stoppedSubagents !== "number") return "⚙️ Agent was aborted.";
const label = stoppedSubagents === 1 ? "sub-agent" : "sub-agents";
return `⚙️ Agent was aborted. Stopped ${stoppedSubagents} ${label}.`;
},
}));
const { dispatchReplyFromConfig } = await import("./dispatch-from-config.js");
@@ -123,6 +128,31 @@ describe("dispatchReplyFromConfig", () => {
});
});
it("fast-abort reply includes stopped subagent count when provided", async () => {
mocks.tryFastAbortFromMessage.mockResolvedValue({
handled: true,
aborted: true,
stoppedSubagents: 2,
});
const cfg = {} as ClawdbotConfig;
const dispatcher = createDispatcher();
const ctx: MsgContext = {
Provider: "telegram",
Body: "/stop",
};
await dispatchReplyFromConfig({
ctx,
cfg,
dispatcher,
replyResolver: vi.fn(async () => ({ text: "hi" }) as ReplyPayload),
});
expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({
text: "⚙️ Agent was aborted. Stopped 2 sub-agents.",
});
});
it("deduplicates inbound messages by MessageSid and origin", async () => {
mocks.tryFastAbortFromMessage.mockResolvedValue({
handled: false,