Merge pull request #6337 from Kilo-Org/session/agent_2b4968a6-6808-4df7-9d6b-e11307fcadbb

Remove fixDuplicateReasoning function
This commit is contained in:
Christiaan Arnoldus
2026-02-25 18:00:47 +01:00
committed by GitHub
@@ -234,40 +234,10 @@ export namespace ProviderTransform {
})
}
// kilocode_change - function added
function fixDuplicateReasoning(msgs: ModelMessage[]) {
for (const msg of msgs) {
if (!Array.isArray(msg.content)) {
continue
}
let isFirstToolCall = true
for (const part of msg.content) {
if (part.type === "reasoning") {
// this entry is corrupt
delete part.providerOptions?.openrouter?.reasoning_details
}
if (part.type === "tool-call" && isFirstToolCall) {
isFirstToolCall = false
continue
}
if (part.type === "tool-call") {
// this is a duplicate entry
delete part.providerOptions?.openrouter?.reasoning_details
}
}
}
}
export function message(msgs: ModelMessage[], model: Provider.Model, options: Record<string, unknown>) {
msgs = unsupportedParts(msgs, model)
msgs = normalizeMessages(msgs, model, options)
// kilocode_change - workaround for @openrouter/ai-sdk-provider v1 duplicating reasoning
// fixed in https://github.com/OpenRouterTeam/ai-sdk-provider/pull/344/
if (model.api.npm === "@kilocode/kilo-gateway") {
fixDuplicateReasoning(msgs)
}
if (
(model.providerID === "anthropic" ||
model.api.id.includes("anthropic") ||