Quellcode durchsuchen

fix: preserve empty reasoning_content for DeepSeek V4 thinking mode (#24146)

Co-authored-by: Simon Klee <hello@simonklee.dk>
黑墨水鱼 vor 4 Monaten
Ursprung
Commit
923af96d26
1 geänderte Dateien mit 10 neuen und 15 gelöschten Zeilen
  1. 10 15
      packages/opencode/src/provider/transform.ts

+ 10 - 15
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,
+            },
+          },
         }
       }