From 931e6ed50fffb8dce6d2943ffca822b8b1910eb5 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Fri, 24 Apr 2026 18:45:31 +0800 Subject: [PATCH] fix: preserve empty reasoning_content in interleaved transform DeepSeek thinking mode may return empty reasoning_content on assistant messages in a tool call chain, which must be sent back in subsequent requests. The interleaved transform's truthy check was dropping it. Always set providerOptions.openaiCompatible[field] for assistant messages so the AI SDK's metadata spread carries it through. --- packages/opencode/src/provider/transform.ts | 25 +++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 1d84c7c93127..fb0bc70e78e3 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -185,24 +185,19 @@ function normalizeMessages( // Filter out reasoning parts from content const filteredContent = msg.content.filter((part: any) => part.type !== "reasoning") - // Include reasoning_content | reasoning_details directly on the message for all assistant messages - if (reasoningText) { - return { - ...msg, - content: filteredContent, - providerOptions: { - ...msg.providerOptions, - openaiCompatible: { - ...msg.providerOptions?.openaiCompatible, - [field]: reasoningText, - }, - }, - } - } - + // Include reasoning_content | reasoning_details directly on the message for all assistant messages. + // Always set the field even when empty — some providers (e.g. DeepSeek) may return empty + // reasoning_content which still needs to be sent back in subsequent requests. return { ...msg, content: filteredContent, + providerOptions: { + ...msg.providerOptions, + openaiCompatible: { + ...msg.providerOptions?.openaiCompatible, + [field]: reasoningText, + }, + }, } }