Skip to content

Commit 923af96

Browse files
fix: preserve empty reasoning_content for DeepSeek V4 thinking mode (#24146)
Co-authored-by: Simon Klee <hello@simonklee.dk>
1 parent a882e95 commit 923af96

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

packages/opencode/src/provider/transform.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,19 @@ function normalizeMessages(
185185
// Filter out reasoning parts from content
186186
const filteredContent = msg.content.filter((part: any) => part.type !== "reasoning")
187187

188-
// Include reasoning_content | reasoning_details directly on the message for all assistant messages
189-
if (reasoningText) {
190-
return {
191-
...msg,
192-
content: filteredContent,
193-
providerOptions: {
194-
...msg.providerOptions,
195-
openaiCompatible: {
196-
...msg.providerOptions?.openaiCompatible,
197-
[field]: reasoningText,
198-
},
199-
},
200-
}
201-
}
202-
188+
// Include reasoning_content | reasoning_details directly on the message for all assistant messages.
189+
// Always set the field even when empty — some providers (e.g. DeepSeek) may return empty
190+
// reasoning_content which still needs to be sent back in subsequent requests.
203191
return {
204192
...msg,
205193
content: filteredContent,
194+
providerOptions: {
195+
...msg.providerOptions,
196+
openaiCompatible: {
197+
...msg.providerOptions?.openaiCompatible,
198+
[field]: reasoningText,
199+
},
200+
},
206201
}
207202
}
208203

0 commit comments

Comments
 (0)