mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
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).
This commit is contained in:
committed by
kiloconnect[bot]
parent
094bf74269
commit
439cba7879
@@ -193,25 +193,23 @@ 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,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// kilocode_change start - cherry-picked from anomalyco/opencode#24146;
|
||||
// will be reverted on the next wholesale upstream merge.
|
||||
// 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,
|
||||
},
|
||||
},
|
||||
}
|
||||
// kilocode_change end
|
||||
}
|
||||
|
||||
return msg
|
||||
|
||||
Reference in New Issue
Block a user