fix(cli): remove fixDuplicateReasoning workaround now that @openrouter/ai-sdk-provider is updated

This commit is contained in:
kiloconnect[bot]
2026-04-14 09:45:21 +00:00
parent 1b0ccd52f4
commit 32e9c2934d
@@ -282,56 +282,10 @@ export namespace ProviderTransform {
})
}
// kilocode_change - function added
function fixDuplicateReasoning(msgs: ModelMessage[], model: Provider.Model) {
for (const msg of msgs) {
if (!Array.isArray(msg.content)) {
continue
}
const encryptedDataSet = new Set<string>()
const textSet = new Set<string>()
for (const part of msg.content) {
if (!("providerOptions" in part)) continue // kilocode_change - ToolApprovalRequest lacks providerOptions
const openrouterProviderOptions = part.providerOptions?.openrouter as
| {
reasoning_details?: { data?: string; text?: string; signature?: string }[]
}
| undefined
if (!openrouterProviderOptions || !openrouterProviderOptions.reasoning_details) {
continue
}
openrouterProviderOptions.reasoning_details = openrouterProviderOptions.reasoning_details.filter((rd) => {
if (rd.data) {
if (!encryptedDataSet.has(rd.data)) {
encryptedDataSet.add(rd.data)
return true
}
return false
}
if (rd.text) {
if ((model.family === "claude" || model.id.includes("claude")) && !rd.signature) return false
if (!textSet.has(rd.text)) {
textSet.add(rd.text)
return true
}
return false
}
return true
})
}
}
}
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 === "@openrouter/ai-sdk-provider") {
fixDuplicateReasoning(msgs, model)
}
if (
(model.providerID === "anthropic" ||
model.providerID === "google-vertex-anthropic" ||