summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author黑墨水鱼 <[email protected]>2026-04-24 20:42:57 +0800
committerGitHub <[email protected]>2026-04-24 08:42:57 -0400
commit923af96d26bd7777ae335ddade89854ac5fc8841 (patch)
tree823575dd852450bfbc33f1e2b52f67b280084425
parenta882e958b3d9bf736d9e16d65989265999674150 (diff)
downloadopencode-923af96d26bd7777ae335ddade89854ac5fc8841.tar.gz
opencode-923af96d26bd7777ae335ddade89854ac5fc8841.zip
fix: preserve empty reasoning_content for DeepSeek V4 thinking mode (#24146)
Co-authored-by: Simon Klee <[email protected]>
-rw-r--r--packages/opencode/src/provider/transform.ts25
1 files changed, 10 insertions, 15 deletions
diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts
index 6f24370ab..0a2fc7fc2 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,
+ },
+ },
}
}