mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix: use object-based reasoning format for Codex models with Kilo provider (#206)
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
This commit is contained in:
@@ -482,6 +482,12 @@ export namespace ProviderTransform {
|
||||
}
|
||||
// GPT models via Kilo need encrypted reasoning content to avoid org_id mismatch
|
||||
if (!model.id.includes("gpt") && !model.id.includes("gemini-3")) return {}
|
||||
// kilocode_change - Codex models use object-based reasoning format for OpenRouter
|
||||
// OpenRouter expects { reasoning: { effort: "high" } } format
|
||||
// See: https://openrouter.ai/docs/api/api-reference/chat/send-chat-completion-request#request.body.reasoning
|
||||
if (model.id.includes("codex")) {
|
||||
return Object.fromEntries(OPENAI_EFFORTS.map((effort) => [effort, { reasoning: { effort } }]))
|
||||
}
|
||||
return Object.fromEntries(
|
||||
OPENAI_EFFORTS.map((effort) => [
|
||||
effort,
|
||||
|
||||
@@ -1669,6 +1669,23 @@ describe("ProviderTransform.variants", () => {
|
||||
expect(result.low).toEqual({ reasoning: { effort: "low" } })
|
||||
expect(result.high).toEqual({ reasoning: { effort: "high" } })
|
||||
})
|
||||
|
||||
test("codex models return OPENAI_EFFORTS with object-based reasoning format", () => {
|
||||
const model = createMockModel({
|
||||
id: "kilo/openai/gpt-5.2-codex",
|
||||
providerID: "kilo",
|
||||
api: {
|
||||
id: "openai/gpt-5.2-codex",
|
||||
url: "https://gateway.kilo.ai",
|
||||
npm: "@kilocode/kilo-gateway",
|
||||
},
|
||||
})
|
||||
const result = ProviderTransform.variants(model)
|
||||
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
|
||||
expect(result.low).toEqual({ reasoning: { effort: "low" } })
|
||||
expect(result.high).toEqual({ reasoning: { effort: "high" } })
|
||||
expect(result.xhigh).toEqual({ reasoning: { effort: "xhigh" } })
|
||||
})
|
||||
})
|
||||
// kilocode_change end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user