Repository navigation
[AISAGE-734] fix(gateway): exclude OpenCode Go models served only over the Gemini API - #7787
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental change replaces the SDK allowlist in OverviewIncremental review at commit Notes (non-blocking, not inline findings):
Files Reviewed (2 files)
Previous Review Summary (commit e270c5f)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit e270c5f)Status: No Issues Found | Recommendation: Merge Executive SummaryThe change adds a Files Reviewed (2 files)
Notes (non-blocking, not inline findings):
Reviewed by deepseek-v4.1-flash · Input: 36.8K · Output: 5.4K · Cached: 276.5K Review guidance: REVIEW.md from base branch |
Summary
OpenCode Go serves its Gemini models only over Google's native Gemini API. The gateway can only proxy
chat_completions,messagesandresponses(GatewayChatApiKind), so we listedopencode-go/gemini-4-argon-contributorin the catalog even though every request to it failed.The models.dev sync for direct BYOK providers now drops any model whose per-model
provider.npmis a native Gemini API SDK (@ai-sdk/googleor@ai-sdk/google-vertex). All other models are kept.Evidence
models.dev (
https://models.dev/api.json, provideropencode-go, fetched 2026-10-16):npm: "@ai-sdk/openai-compatible",api: "https://opencode.ai/inference/go/openai/v1".gemini-4-argon-contributor:provider: { npm: "@ai-sdk/google", api: "https://opencode.ai/inference/go/google/v1beta" }.@ai-sdk/anthropic(minimax, qwen) or@ai-sdk/openai(gpt, grok, muse), or overrides onlyapi.https://opencode.ai/zen/go/v1/modelslistsgemini-4-argon-contributor, so the available-models check doesn't filter it out. The SDK field is the only thing in the data that marks it as unusable.Production: the Axiom
verceldataset showsModelProtocolUnsupported("Model does not support this protocol.") errors from OpenCode Go foropencode-go/gemini-4-argon-contributoron/api/v1/chat/completions.Why a Gemini SDK denylist, not a model-ID filter or an SDK allowlist
@ai-sdk/openai-compatible,@ai-sdk/openaiand@ai-sdk/anthropic. That would wrongly hide working models, because several SDK names still speak Chat Completions. Per-model overrides found across all of models.dev:opencode(OpenCode Zen) has a model withnpm: "@ai-sdk/mistral"onhttps://opencode.ai/inference/openai/v1, its OpenAI-compatible endpoint.standardcomputehas a model withnpm: "@openrouter/ai-sdk-provider".@ai-sdk/xai,@ai-sdk/groq,@ai-sdk/deepinfra,@ai-sdk/togetheraiand@ai-sdk/cerebras.nvidia,alibaba-token-plan,edenai,zai-coding-plan,ollama-cloud,xiaomi-token-plan-amsorxiaomi-token-plan-sgphas per-modelprovideroverrides. In the current catalog the filter removes exactly one model:opencode-go/gemini-4-argon-contributor..catch(undefined). If the field is malformed, the model is kept.Already-synced data
No schema change is needed.
syncDirectByokModelsruns from/api/cron/sync-providersevery 5 minutes, and each successful sync fully replaces the provider'sdirect_byok_model_listsrow withonConflictDoUpdate. The first sync after deploy removes the stale Gemini entry. After that, gateway instances stop serving it once their 10-minutecachedEnhancedDirectByokModelListcache expires. A new DB test seeds a staleopencode-gorow that contains the Gemini model and checks that a re-sync removes it.Request behaviour after the change
getDirectByokModelno longer resolvesopencode-go/gemini-4-argon-contributor, so the gateway doesn't send it to OpenCode Go. A user with credits gets the gateway's own 404model_not_found("The requested model '…' does not exist…") with no upstream call. A personal account or organization with a zero balance hits the credits check before that 404. This is existing behaviour for any model that drops out of a direct BYOK list, and this PR doesn't change it.Verification
jest src/lib/providers/direct-byok/sync-direct-byok.test.ts ../../packages/web-shared/src/lib/ai-gateway/providers/direct-byok(fromapps/web,NODE_ENV=test): 8 suites, 87 tests passed.main'ssync-direct-byok.ts, the 2 new tests fail. Against the earlier allowlist version, the parse test fails because the@ai-sdk/mistraland@openrouter/ai-sdk-providermodels are dropped. With this change, both tests pass.pnpm --filter web typecheck: passed.pnpm --filter @kilocode/web-shared typecheck: passed. The package isn't changed; this was run as a sanity check.pnpm exec oxlint --config .oxlintrc.jsonon both changed files: 0 warnings, 0 errors.pnpm exec oxfmton both changed files, thengit diff --check: clean.