Skip to content

Commit c9bee00

Browse files
author
hclsys
committed
fix(message): return dry-run handledBy from executeSendAction
`executeSendAction` always returned `handledBy: "core"` even when `dryRun` was true, so the dry-run branch in `formatMessageCliText` (which checks for `handledBy === "dry-run"`) was unreachable for `send` actions, causing the CLI to print the success message instead of the expected `[dry-run] would run send via <channel>` indicator. Return early with `handledBy: "dry-run"` when the context has `dryRun: true`, skipping both plugin dispatch and the actual send. Add `"dry-run"` to the `MessageActionRunResult` send-kind union so the type reflects the runtime behaviour. Fixes #80507
1 parent 8d14c95 commit c9bee00

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/infra/outbound/message-action-runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export type MessageActionRunResult =
126126
channel: ChannelId;
127127
action: "send";
128128
to: string;
129-
handledBy: "plugin" | "core";
129+
handledBy: "plugin" | "core" | "dry-run";
130130
payload: unknown;
131131
toolResult?: AgentToolResult<unknown>;
132132
sendResult?: MessageSendResult;

src/infra/outbound/outbound-send-service.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,15 +572,16 @@ describe("executeSendAction", () => {
572572
});
573573
});
574574

575-
it("skips plugin dispatch during dry-run sends and forwards gateway + silent to sendMessage", async () => {
575+
it("skips plugin dispatch during dry-run sends and returns dry-run handledBy", async () => {
576576
mocks.sendMessage.mockResolvedValue({
577577
channel: "demo-outbound",
578578
to: "channel:123",
579579
via: "gateway",
580580
mediaUrl: null,
581+
dryRun: true,
581582
});
582583

583-
await executeSendAction({
584+
const result = await executeSendAction({
584585
ctx: {
585586
cfg: {},
586587
channel: "demo-outbound",
@@ -611,6 +612,7 @@ describe("executeSendAction", () => {
611612
token: "tok",
612613
timeoutMs: 5000,
613614
});
615+
expect(result.handledBy).toBe("dry-run");
614616
});
615617

616618
it("routes prepared plugin send payloads through core best-effort delivery by default", async () => {

src/infra/outbound/outbound-send-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export async function executeSendAction(params: {
244244
replyToId?: string;
245245
threadId?: string | number;
246246
}): Promise<{
247-
handledBy: "plugin" | "core";
247+
handledBy: "plugin" | "core" | "dry-run";
248248
payload: unknown;
249249
toolResult?: AgentToolResult<unknown>;
250250
sendResult?: MessageSendResult;
@@ -273,7 +273,7 @@ export async function executeSendAction(params: {
273273
});
274274

275275
return {
276-
handledBy: "core",
276+
handledBy: result.dryRun ? "dry-run" : "core",
277277
payload: result,
278278
sendResult: result,
279279
};
@@ -312,7 +312,7 @@ export async function executeSendAction(params: {
312312
});
313313

314314
return {
315-
handledBy: "core",
315+
handledBy: result.dryRun ? "dry-run" : "core",
316316
payload: result,
317317
sendResult: result,
318318
};

0 commit comments

Comments
 (0)