Repository navigation
[AISAGE-706] fix(ai-gateway): drop legacy reasoning fields for reasoning-details mapped providers - #7751
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe reasoning-field fixes in the OpenCode Go BYOK path and the shared reasoning-details transforms are logically sound and covered by new tests; no bugs, security issues, or regressions were found in the changed lines. Files Reviewed (5 files)
Notes
Reviewed by deepseek-v4.1-flash · Input: 73.7K · Output: 15.7K · Cached: 571.9K Review guidance: REVIEW.md from base branch |
E2E verification with an OpenCode Go BYOK keySetup: I ran ai-gateway locally from this branch. A seeded test user had a real OpenCode Go key stored as their
For the baseline, I restored the three source files to the branch parent commit and restarted the gateway. Each model had 7 cases (3 raw, 4 SDK):
The "before" column reproduces the reported error exactly. In the SDK runs, follow-up turns that carry the previous step's reasoning now succeed, and reasoning still reaches the client as Effort mapping: upstream honors Some SDK tool-call steps with |
Summary
Some OpenCode Go BYOK requests fail with:
Since #7586 moved direct BYOK providers to the OpenRouter client default, clients send OpenRouter-style
reasoningfields that strict upstreams reject. There are two separatereasoningfields:reasoning(legacy string next toreasoning_detailson assistant messages). The reasoning-details request transforms (ReasoningContentandGeminiThought) now drop it. When a message has noreasoning_details,ReasoningContentfolds the legacy string intoreasoning_contentinstead of losing it, unlessreasoning_contentis already set.reasoningconfig ({ effort, enabled, ... }). This is the field behind the exact error above. OpenCode Go now mapsreasoning.efforttoreasoning_effort(an explicitreasoning_efforttakes precedence) and removesreasoning. This follows the existing EdenAI and NVIDIA providers.Upstream probe
These are direct requests to
opencode.ai/zen/go/v1/chat/completionswith the same three-message history. Only the noted field changes:reasoningreasoning[unknown_parameter] ... unknown field "reasoning"[unknown_parameter] ... unknown field "reasoning"[unsupported_parameter]messages[1].reasoning[unsupported_parameter]reasoningreasoning_effort: "high"is accepted (for example omen-alpha returns 200 withreasoning_content).Verification
pnpm --filter @kilocode/web-shared typecheck: passesapply-provider-specific-logic,direct-byok/opencode-go,providers/openrouter/*,build-direct-providerandrewriteModelResponsesuites: 11 suites, 339 tests passoxlinton the changed files: clean;oxfmtandgit diff --check: clean