Merge pull request #9470 from Kilo-Org/fix/cli-preserve-empty-reasoning-content

fix(cli): preserve empty reasoning_content in interleaved transform
This commit is contained in:
Christiaan Arnoldus
2026-04-24 17:07:13 +02:00
committed by GitHub
2 changed files with 18 additions and 15 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Fix multi-turn tool calls with DeepSeek thinking mode by preserving empty `reasoning_content` in the interleaved transform.
+13 -15
View File
@@ -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