diff --git a/src/discord/monitor/message-handler.process.test.ts b/src/discord/monitor/message-handler.process.test.ts index 067273351db3..283b95a70644 100644 --- a/src/discord/monitor/message-handler.process.test.ts +++ b/src/discord/monitor/message-handler.process.test.ts @@ -441,6 +441,23 @@ describe("processDiscordMessage draft streaming", () => { expect(deliverDiscordReply).not.toHaveBeenCalled(); }); + it("delivers block payloads when blockStreaming is enabled", async () => { + dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => { + await params?.dispatcher.sendBlockReply({ text: "stream chunk" }); + return { queuedFinal: true, counts: { final: 0, tool: 0, block: 1 } }; + }); + + const ctx = await createBaseContext({ + discordConfig: { streamMode: "off", blockStreaming: true }, + }); + + // oxlint-disable-next-line typescript/no-explicit-any + await processDiscordMessage(ctx as any); + + expect(deliverDiscordReply).toHaveBeenCalledTimes(1); + expect(deliverDiscordReply.mock.calls[0]?.[0]?.replies).toEqual([{ text: "stream chunk" }]); + }); + it("streams block previews using draft chunking", async () => { const draftStream = createMockDraftStream(); createDiscordDraftStream.mockReturnValueOnce(draftStream); diff --git a/src/discord/monitor/message-handler.process.ts b/src/discord/monitor/message-handler.process.ts index 1c41fef76ec0..d0affba7fd88 100644 --- a/src/discord/monitor/message-handler.process.ts +++ b/src/discord/monitor/message-handler.process.ts @@ -557,9 +557,9 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext) humanDelay: resolveHumanDelayConfig(cfg, route.agentId), deliver: async (payload: ReplyPayload, info) => { const isFinal = info.kind === "final"; - if (info.kind === "block") { - // Block payloads carry reasoning/thinking content that should not be - // delivered to external channels. Skip them regardless of streamMode. + if (info.kind === "block" && !accountBlockStreamingEnabled && !payload.isError) { + // In normal mode, suppress non-error block payloads to avoid duplicate + // previews. In blockStreaming mode we must deliver them. return; } if (draftStream && isFinal) {