Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit 025dbcb

Browse files
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>
1 parent beb49aa commit 025dbcb

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

packages/opencode/src/provider/transform.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ export namespace ProviderTransform {
482482
}
483483
// GPT models via Kilo need encrypted reasoning content to avoid org_id mismatch
484484
if (!model.id.includes("gpt") && !model.id.includes("gemini-3")) return {}
485+
// kilocode_change - Codex models use object-based reasoning format for OpenRouter
486+
// OpenRouter expects { reasoning: { effort: "high" } } format
487+
// See: https://openrouter.ai/docs/api/api-reference/chat/send-chat-completion-request#request.body.reasoning
488+
if (model.id.includes("codex")) {
489+
return Object.fromEntries(OPENAI_EFFORTS.map((effort) => [effort, { reasoning: { effort } }]))
490+
}
485491
return Object.fromEntries(
486492
OPENAI_EFFORTS.map((effort) => [
487493
effort,

packages/opencode/test/provider/transform.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,23 @@ describe("ProviderTransform.variants", () => {
16691669
expect(result.low).toEqual({ reasoning: { effort: "low" } })
16701670
expect(result.high).toEqual({ reasoning: { effort: "high" } })
16711671
})
1672+
1673+
test("codex models return OPENAI_EFFORTS with object-based reasoning format", () => {
1674+
const model = createMockModel({
1675+
id: "kilo/openai/gpt-5.2-codex",
1676+
providerID: "kilo",
1677+
api: {
1678+
id: "openai/gpt-5.2-codex",
1679+
url: "https://gateway.kilo.ai",
1680+
npm: "@kilocode/kilo-gateway",
1681+
},
1682+
})
1683+
const result = ProviderTransform.variants(model)
1684+
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1685+
expect(result.low).toEqual({ reasoning: { effort: "low" } })
1686+
expect(result.high).toEqual({ reasoning: { effort: "high" } })
1687+
expect(result.xhigh).toEqual({ reasoning: { effort: "xhigh" } })
1688+
})
16721689
})
16731690
// kilocode_change end
16741691

0 commit comments

Comments
 (0)