Skip to content

fix: enable reasoning for thinking models via kilo-gateway#504

Open
cbrunnkvist wants to merge 1 commit intoKilo-Org:devfrom
cbrunnkvist:fix/kilo-gateway-thinking-models
Open

fix: enable reasoning for thinking models via kilo-gateway#504
cbrunnkvist wants to merge 1 commit intoKilo-Org:devfrom
cbrunnkvist:fix/kilo-gateway-thinking-models

Conversation

@cbrunnkvist
Copy link

@cbrunnkvist cbrunnkvist commented Feb 20, 2026

Summary

  • Fixes bug where thinking models (e.g. kimi-k2-thinking) fail with "Reasoning is mandatory for this endpoint" when accessed via Kilo Gateway
  • Adds automatic reasoning: { enabled: true } for models using @kilocode/kilo-gateway SDK that have reasoning capability and "thinking" in their model ID
  • Adds tests for the fix

Changes

  • packages/opencode/src/provider/transform.ts: Add logic to enable reasoning for thinking models via Kilo Gateway
  • packages/opencode/test/provider/transform.test.ts: Add tests

Testing

Verified that kimi-k2-thinking now works:

  • Before:
% bun run dev -- run --model kilo/moonshotai/kimi-k2-thinking "Vad heter du?"
$ bun run --cwd packages/opencode --conditions=browser src/index.ts run --model "kilo/moonshotai/kimi-k2-thinking" "Vad heter du?"

> code · moonshotai/kimi-k2-thinking

Error: Reasoning is mandatory for this endpoint and cannot be disabled.
^C
  • After:
% bun run dev -- run --model kilo/moonshotai/kimi-k2-thinking "Vad heter du?"                                                                                                     [130]
$ bun run --cwd packages/opencode --conditions=browser src/index.ts run --model "kilo/moonshotai/kimi-k2-thinking" "Vad heter du?"

> code · moonshotai/kimi-k2-thinking

Kilo

Fixes #503

input.model.capabilities.reasoning &&
input.model.api.id.includes("thinking")
) {
result["reasoning"] = { enabled: true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Potential reasoning overwrite — the block above (line 771) sets result["reasoning"] = { effort: "high" } for kilo-gateway models whose api.id includes "gemini-3". This new block will overwrite that value with { enabled: true } if a model's api.id contains both "gemini-3" and "thinking" (e.g. a hypothetical google/gemini-3-thinking).

This is unlikely with current model names, but the ordering dependency is fragile. Consider adding an early-return guard (e.g. && !input.model.api.id.includes("gemini-3")) or restructuring to make the precedence explicit.

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 20, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/provider/transform.ts 789 Potential reasoning overwrite — the gemini-3 block (line 771) sets { effort: "high" } and this new block could overwrite it with { enabled: true } if a model ID contains both "gemini-3" and "thinking"
Files Reviewed (2 files)
  • packages/opencode/src/provider/transform.ts - 1 issue
  • packages/opencode/test/provider/transform.test.ts - 0 issues

Fix these issues in Kilo Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Thinking models (e.g. kimi-k2-thinking) fail with Reasoning is mandatory via Kilo Gateway

1 participant

Comments