refactor(core): refactor model resolving logic, fix missing variant logic - #48943
Merged
Merged
Conversation
normalize() maps each models.dev npm package onto its @opencode/ai equivalent where one exists; the 13 npm packages without one stay on aisdk:. The generic openai-compatible package receives the provider identity as a per-model setting, which the AI SDK path inferred.
…ages MiniMax uses the native Messages package, Meta the native Responses package, and Baseten, DeepSeek, Fireworks and Cloudflare Workers AI their own packages instead of generic openai-compatible. Alibaba, Z.AI, Moonshot and the coding plans stay generic for now.
Variant.resolve(model, options) builds effort, toggle and budget variants for a catalog model from a per-package spelling table keyed by the package as it appears in the catalog, native or aisdk:. models.dev is the first caller; the variant plugin and config best-guess variants follow.
Reasoning variants are built from three controls: effort, toggle and token budget. Each package entry says how it spells each one; shared spellings are plain functions and shared formats are plain values, so packages that behave alike point at the same format and packages that differ spread and override. Native Bedrock variants now ride in body.additionalModelRequestFields, matching what the AI SDK translator produced.
Each package maps to a protocol: a function that, given a model and one reasoning control it supports (effort, toggle or token budget), returns the variants for it in that protocol's vocabulary. Model checks such as Claude's manual-effort generations are local variables inside the protocol, so they steer both the spelling and the assumed values. Nothing declared means the model is assumed to support effort and the protocol chooses the values, so config models without a variants key get that protocol's defaults through the same code path models.dev records use. models.dev strips its null placeholders before calling in. The GitHub Copilot entry is removed: the Copilot plugin builds variants from Copilot's own model list.
models.dev records have carried native packages since the catalog started registering them, so guards written against AI SDK npm names silently stopped matching. Match the native package instead.
…t fixtures Copilot's Anthropic-protocol models were registered as aisdk:@ai-sdk/anthropic; the native Anthropic package replaces it. Test fixtures standing in for models.dev records now seed the native packages models.dev emits.
Cloudflare Workers AI and Google Vertex drop their AI SDK hooks; the packages they matched no longer reach the catalog, and the resolver already expands endpoint variables on every route. Vertex expands its endpoint templates on model settings too, where MaaS models carry them. Modal registers the native openai-compatible package directly.
The catalog editor is the single place AI SDK packages become native. Every provider and model write runs AISDKNative.rewrite, which picks the native package and translates AI SDK settings into the native spelling based on the package the target will run under, so options written on a model that inherits its provider's package are translated too. The resolver no longer maps at request time, and the config plugin and V1 migration no longer carry their own rewrite calls. Host-specific packages are keyed by the models.dev provider ID, covering every regional and plan sibling for Alibaba, Moonshot, MiniMax, Z.AI and Meta, with the wire format following the source package. Bedrock body options and the Mantle chat/responses choice depend on the model, so they are only translated on model writes; provider-level values stay inert. Native Bedrock credentials pass through unchanged, and the legacy @opencode-ai/ai scope normalizes on write. The VariantPlugin GLM hack and the AI SDK twin protocol entries are removed since AI SDK packages with native twins never reach the variant table anymore.
rekram1-node
force-pushed
the
catalog-native
branch
from
September 14, 2026 18:25
647a57d to
00e277a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.