Revert "fix(reasoning-stream): call onReasoningEnd for extended thinking (API blocks)"

This reverts commit 3f8fc4d0c38ccca1fab836d55390073e475d9023.
This commit is contained in:
Hongwei Ma
2026-02-16 21:04:45 +08:00
committed by Ayaan Zaidi
parent 15ad64141a
commit 34b52eead8

View File

@@ -239,10 +239,9 @@ export function handleMessageEnd(
text: ctx.stripBlockTags(rawText, { thinking: false, final: false }),
messagingToolSentTexts: ctx.state.messagingToolSentTexts,
});
const apiThinking = extractAssistantThinking(assistantMessage);
const rawThinking =
ctx.state.includeReasoning || ctx.state.streamReasoning
? apiThinking || extractThinkingFromTaggedText(rawText)
? extractAssistantThinking(assistantMessage) || extractThinkingFromTaggedText(rawText)
: "";
const formattedReasoning = rawThinking ? formatReasoningMessage(rawThinking) : "";
const trimmedText = text.trim();
@@ -363,12 +362,6 @@ export function handleMessageEnd(
}
if (ctx.state.streamReasoning && rawThinking) {
ctx.emitReasoningStream(rawThinking);
// For extended thinking (API blocks), onReasoningEnd won't be triggered
// by </think> tag processing, so we call it here to signal reasoning is complete.
// Only call if thinking came from API blocks to avoid double-calling when using <think> tags.
if (apiThinking) {
void ctx.params.onReasoningEnd?.();
}
}
if (ctx.state.blockReplyBreak === "text_end" && onBlockReply) {