Skip to content

Commit 439cba7

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 439cba7

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

packages/opencode/src/provider/transform.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,23 @@ 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+
// kilocode_change start - cherry-picked from anomalyco/opencode#24146;
197+
// will be reverted on the next wholesale upstream merge.
198+
// Include reasoning_content | reasoning_details directly on the message for all assistant messages.
199+
// Always set the field even when empty — some providers (e.g. DeepSeek) may return empty
200+
// reasoning_content which still needs to be sent back in subsequent requests.
211201
return {
212202
...msg,
213203
content: filteredContent,
204+
providerOptions: {
205+
...msg.providerOptions,
206+
openaiCompatible: {
207+
...msg.providerOptions?.openaiCompatible,
208+
[field]: reasoningText,
209+
},
210+
},
214211
}
212+
// kilocode_change end
215213
}
216214

217215
return msg

0 commit comments

Comments
 (0)