fix(discord): preserve non-reasoning replies with reasoning prefix text

This commit is contained in:
Tak Hoffman
2026-03-06 18:42:35 -06:00
parent d65d1b166f
commit d992e21a6f
2 changed files with 22 additions and 5 deletions

View File

@@ -545,6 +545,27 @@ describe("processDiscordMessage draft streaming", () => {
);
});
it("does not drop non-reasoning final payloads that start with Reasoning prefix text", async () => {
dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {
await params?.dispatcher.sendFinalReply({
text: "Reasoning:\nThis heading is intentional user-facing content",
});
return { queuedFinal: true, counts: { final: 1, tool: 0, block: 0 } };
});
await processStreamOffDiscordMessage();
expect(deliverDiscordReply).toHaveBeenCalledWith(
expect.objectContaining({
replies: [
expect.objectContaining({
text: "Reasoning:\nThis heading is intentional user-facing content",
}),
],
}),
);
});
it("delivers non-reasoning block payloads to Discord", async () => {
mockDispatchSingleBlockReply({ text: "hello from block stream" });
await processStreamOffDiscordMessage();

View File

@@ -596,11 +596,7 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
if (typeof text !== "string") {
return text;
}
const cleaned = stripReasoningTagsFromText(text, { mode: "strict", trim: "both" });
if (cleaned.startsWith("Reasoning:\n")) {
return "";
}
return cleaned;
return stripReasoningTagsFromText(text, { mode: "strict", trim: "both" });
};
// When draft streaming is active, suppress block streaming to avoid double-streaming.