Skip to content

Commit 70d205d

Browse files
heimoshuiyukilo-code-bot[bot]
authored andcommitted
fix(cli): 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. Cherry-picked from anomalyco/opencode#24146 (931e6ed).
1 parent 094bf74 commit 70d205d

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
@@ -193,24 +193,19 @@ function normalizeMessages(
193193
// Filter out reasoning parts from content
194194
const filteredContent = msg.content.filter((part: any) => part.type !== "reasoning")
195195

196-
// Include reasoning_content | reasoning_details directly on the message for all assistant messages
197-
if (reasoningText) {
198-
return {
199-
...msg,
200-
content: filteredContent,
201-
providerOptions: {
202-
...msg.providerOptions,
203-
openaiCompatible: {
204-
...msg.providerOptions?.openaiCompatible,
205-
[field]: reasoningText,
206-
},
207-
},
208-
}
209-
}
210-
196+
// Include reasoning_content | reasoning_details directly on the message for all assistant messages.
197+
// Always set the field even when empty — some providers (e.g. DeepSeek) may return empty
198+
// reasoning_content which still needs to be sent back in subsequent requests.
211199
return {
212200
...msg,
213201
content: filteredContent,
202+
providerOptions: {
203+
...msg.providerOptions,
204+
openaiCompatible: {
205+
...msg.providerOptions?.openaiCompatible,
206+
[field]: reasoningText,
207+
},
208+
},
214209
}
215210
}
216211

0 commit comments

Comments
 (0)