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:
kiloconnect[bot]
2026-02-10 10:41:12 +00:00
committed by GitHub
parent beb49aa863
commit 025dbcb4df
2 changed files with 23 additions and 0 deletions
@@ -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