mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(discord): preserve non-reasoning replies with reasoning prefix text
This commit is contained in:
@@ -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 () => {
|
it("delivers non-reasoning block payloads to Discord", async () => {
|
||||||
mockDispatchSingleBlockReply({ text: "hello from block stream" });
|
mockDispatchSingleBlockReply({ text: "hello from block stream" });
|
||||||
await processStreamOffDiscordMessage();
|
await processStreamOffDiscordMessage();
|
||||||
|
|||||||
@@ -596,11 +596,7 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
|
|||||||
if (typeof text !== "string") {
|
if (typeof text !== "string") {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
const cleaned = stripReasoningTagsFromText(text, { mode: "strict", trim: "both" });
|
return stripReasoningTagsFromText(text, { mode: "strict", trim: "both" });
|
||||||
if (cleaned.startsWith("Reasoning:\n")) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return cleaned;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// When draft streaming is active, suppress block streaming to avoid double-streaming.
|
// When draft streaming is active, suppress block streaming to avoid double-streaming.
|
||||||
|
|||||||
Reference in New Issue
Block a user