mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 15:32:11 +08:00
Merge pull request #8895 from Kilo-Org/remove-fix-duplicate-reasoning
fix(cli): remove fixDuplicateReasoning workaround
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Source Code Links
|
||||
|
||||
<!-- Auto-generated by script/extract-source-links.ts — DO NOT EDIT -->
|
||||
<!-- 78 unique URLs extracted from extension and CLI source -->
|
||||
<!-- 77 unique URLs extracted from extension and CLI source -->
|
||||
|
||||
- <https://api.apertis.ai/v1>
|
||||
<!-- packages/opencode/src/provider/model-cache.ts -->
|
||||
@@ -59,8 +59,6 @@
|
||||
<!-- packages/kilo-vscode/webview-ui/src/components/chat/FeedbackDialog.tsx -->
|
||||
- <https://github.com/microsoft/vscode-eslint/archive/refs/heads/main.zip>
|
||||
<!-- packages/opencode/src/lsp/server.ts -->
|
||||
- <https://github.com/OpenRouterTeam/ai-sdk-provider/pull/344/>
|
||||
<!-- packages/opencode/src/provider/transform.ts -->
|
||||
- <https://github.com/oven-sh/bun/issues/16682>
|
||||
<!-- packages/opencode/src/provider/provider.ts -->
|
||||
- <https://github.com/vercel/ai/blob/2dc67e0ef538307f21368db32d5a12345d98831b/packages/ai/src/logger/log-warnings.ts#L85>
|
||||
|
||||
@@ -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" ||
|
||||
|
||||
Reference in New Issue
Block a user