Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/discord/monitor/message-handler.process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/discord/monitor/message-handler.process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading