Repository navigation
[AISAGE-734] fix(ai-gateway): use the Responses API for OpenCode Go Muse models - #7782
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe net change at HEAD is a one-line broadening of Files Reviewed (2 files)
Review Notes
Not run: Jest suite could not be executed in this read-only session; the tests were assessed statically. Fix these issues in Kilo Cloud Previous Review SummaryCurrent summary above is authoritative. Previous snapshots are kept for context only. Previous reviewStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed the targeted fix in Reviewed by deepseek-v4.1-flash · Input: 62K · Output: 10.5K · Cached: 562.3K Review guidance: REVIEW.md from base branch |
Problem
The OpenCode Go direct BYOK models
opencode-go/muse-spark-1.2-contributorandopencode-go/muse-spark-1.3-contributorfail every request with:Production logs show these errors for Muse Spark and for
gemini-4-argon-contributor. Every one was on/api/v1/chat/completionsor the legacy/api/openrouter/chat/completions. This is unrelated to #7586.Cause
convertModelinproviders/direct-byok/index.tscallsgetAiSdkProvider('opencode-go/muse-spark-…', 'opencode-go').isMuseModelonly matchesmeta/muse-, so the model fell through to the default (OpenRouter SDK, Chat Completions). As a result, the catalog told clients to send Chat Completions, which OpenCode Go doesn't accept for Muse.Fix
isMuseModelnow matchesmuse-anywhere in the model ID, soopencode-go/muse-spark-*is recognized. As a result,getAiSdkProviderreturnsopenai, which tells clients to use the Responses API.meta/muse-*IDs still match, so gateway behavior for them doesn't change.The other
isMuseModelcallers now also apply to OpenCode Go Muse models:removeRecursiveToolSchemaRefsstrips recursive tool schema refs, which Meta rejects.getFallbackReasoningOptionsreturns Muse effort options (nonetoxhigh).isPdfSupportingModelreturnstrue.No changes were needed in
opencode-go.ts:supported_chat_apisalready includesresponses.transformRequestonly adds thex-opencode-sessionheader.replaceReasoningObjectWithReasoningEffortdoes nothing for non-Chat-Completions requests, andx-api-keyis only added for Messages. This is the same path OpenCode Gogpt-*andgrok-*already use.Evidence for the Responses API
https://opencode.ai/inference/go/openai/v1/responseswith@ai-sdk/openai. That's the same endpoint as Grok 4.7 and GPT 6/5.6 Luna.https://models.dev/api.json, provideropencode-go):muse-spark-1.2-contributorandmuse-spark-1.3-contributorhaveprovider.npm = "@ai-sdk/openai". The provider default is@ai-sdk/openai-compatible. OpenCode chooses its SDK from this field, and@ai-sdk/openaidefaults to Responses.OPENCODE_GO_API_KEY) getsThis Go model trains on request data. Allow paid endpoints that train on request data…on/chat/completions,/responses, and/messages. That check runs before the protocol check.Not fixed:
gemini-4-argon-contributorThe OpenCode Go docs and models.dev list this model only on Google's native API (
https://opencode.ai/inference/go/google/v1beta/models/gemini-4-argon-contributor,@ai-sdk/google). None of our supported APIs (Chat Completions, Messages, Responses) are documented for it. I couldn't probe it either, because the test key hits the same training-consent check. This PR doesn't touch it, and it will keep failing until we either support that protocol or hide the model.Verification
pnpm exec jest ../../packages/web-shared/src/lib/ai-gateway/(fromapps/web): 102 suites, 1881 tests passed. New tests:getAiSdkProviderreturnsopenaifor both OpenCode Go Muse Spark models.meta/muse-*through the gateway still returnsopenai.x-api-key.pnpm --filter @kilocode/web-shared typecheck: passed.oxlint --config .oxlintrc.jsonon the changed files: 0 warnings, 0 errors.oxfmton the changed files: no changes.git diff --check: clean.Not verified end to end: there was no OpenCode Go key with training-data endpoints enabled.