fix: suppress reasoning payloads from generic channel dispatch path

When reasoningLevel is 'on', reasoning content was being sent as a
visible message to WhatsApp and other non-Telegram channels via two
paths:
1. Block reply: emitted via onBlockReply in handleMessageEnd
2. Final payloads: added to replyItems in buildEmbeddedRunPayloads

Telegram has its own dispatch path (bot-message-dispatch.ts) that
splits reasoning into a dedicated lane and handles suppression.
The generic dispatch-from-config.ts path used by WhatsApp, web, etc.
had no such filtering.

Fix:
- Add isReasoning?: boolean flag to ReplyPayload
- Tag reasoning payloads at both emission points
- Filter isReasoning payloads in dispatch-from-config.ts for both
  block reply and final reply paths

Telegram is unaffected: it uses its own deliver callback that detects
reasoning via the 'Reasoning:\n' prefix and routes to a separate lane.

Fixes #24954
This commit is contained in:
User
2026-02-24 11:11:41 +08:00
committed by Peter Steinberger
parent b9e587fb63
commit 7d76c241f8
5 changed files with 59 additions and 2 deletions

View File

@@ -187,7 +187,7 @@ export function buildEmbeddedRunPayloads(params: {
? formatReasoningMessage(extractAssistantThinking(params.lastAssistant))
: "";
if (reasoningText) {
replyItems.push({ text: reasoningText });
replyItems.push({ text: reasoningText, isReasoning: true });
}
const fallbackAnswerText = params.lastAssistant ? extractAssistantText(params.lastAssistant) : "";

View File

@@ -339,7 +339,7 @@ export function handleMessageEnd(
return;
}
ctx.state.lastReasoningSent = formattedReasoning;
void onBlockReply?.({ text: formattedReasoning });
void onBlockReply?.({ text: formattedReasoning, isReasoning: true });
};
if (shouldEmitReasoningBeforeAnswer) {