From 34b52eead8faeb64995f61b9e7ab102711acd37b Mon Sep 17 00:00:00 2001 From: Hongwei Ma Date: Mon, 16 Feb 2026 21:04:45 +0800 Subject: [PATCH] Revert "fix(reasoning-stream): call onReasoningEnd for extended thinking (API blocks)" This reverts commit 3f8fc4d0c38ccca1fab836d55390073e475d9023. --- src/agents/pi-embedded-subscribe.handlers.messages.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/agents/pi-embedded-subscribe.handlers.messages.ts b/src/agents/pi-embedded-subscribe.handlers.messages.ts index 597c608e2a6..0812e5956bf 100644 --- a/src/agents/pi-embedded-subscribe.handlers.messages.ts +++ b/src/agents/pi-embedded-subscribe.handlers.messages.ts @@ -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 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 tags. - if (apiThinking) { - void ctx.params.onReasoningEnd?.(); - } } if (ctx.state.blockReplyBreak === "text_end" && onBlockReply) {