GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||
GeezerVison is showing github.com — refactor(core): resolve configured model variants once across config layers by rekram1-node · Pull Request #60425 · anomalyco/opencode Conversation
|
| Setup | Before | After |
|---|---|---|
Custom model in opencode.json + plugin sets [none, low, medium, xhigh] or [] |
Overwritten with [low, medium, high] |
Keeps plugin's variants |
Layer 1 sets modelID: "claude-opus-4-8", layer 2 sets package: "aisdk:@ai-sdk/anthropic" |
Spelled for layer 1 package | Spelled once for Anthropic (low..max) |
Provider package overridden (zai to anthropic) |
Keeps stale zai/chat variants |
Respells for Anthropic |
Layer 1 sets model variants, layer 2 overrides provider package |
Loses layer 1 or keeps stale fields | Respells base for new package, then overlays layer 1 variants |
bun run --cwd packages/core script/test.ts test/config/provider.test.ts --rerun-each 10 --randomize: 430 pass, 0 failbun run --cwd packages/core script/test.ts test/models.test.ts test/plugin/models-dev.test.ts test/plugin/provider-opencode.test.ts test/variant.test.ts: 104 pass, 0 failbun run --cwd packages/core typecheck:tsc: cleanbun run check: 35/35 tasks pass, 0 errors<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" font-family="ui-monospace, monospace" font-size="8"> <style> .flow { animation: settle 4s ease-in-out infinite; } @keyframes settle { 0%, 20% { opacity: 0.45; transform: translateX(-4px); } 45%, 85% { opacity: 1; transform: translateX(0); } 100% { opacity: 0.45; transform: translateX(-4px); } } @media (prefers-reduced-motion: reduce) { .flow { animation: none; opacity: 1; } } </style> <rect x="10" y="12" width="90" height="48" rx="5" stroke="currentColor" stroke-opacity="0.3"/> <text x="18" y="27" fill="currentColor" fill-opacity="0.6">config layers</text> <text x="18" y="41" fill="currentColor" fill-opacity="0.9">+ plugins</text> <text x="18" y="53" fill="currentColor" fill-opacity="0.55">final package</text> <path d="M106 36h18m-4-4 4 4-4 4" stroke="currentColor" stroke-opacity="0.5" stroke-linecap="round" stroke-linejoin="round"/> <g class="flow"> <rect x="130" y="12" width="100" height="48" rx="5" stroke="currentColor" stroke-opacity="0.45"/> <text x="138" y="27" fill="currentColor" fill-opacity="0.6">variants</text> <rect x="138" y="34" width="26" height="16" rx="3" fill="currentColor" fill-opacity="0.14"/> <text x="151" y="45" text-anchor="middle" fill="currentColor" fill-opacity="0.9">low</text> <rect x="168" y="34" width="26" height="16" rx="3" fill="currentColor" fill-opacity="0.14"/> <text x="181" y="45" text-anchor="middle" fill="currentColor" fill-opacity="0.9">high</text> <rect x="198" y="34" width="24" height="16" rx="3" fill="currentColor" fill-opacity="0.22" stroke="currentColor" stroke-opacity="0.5"/> <text x="210" y="45" text-anchor="middle" fill="currentColor" fill-opacity="0.95">max</text> </g> </svg>
Added by the opencode bot (AI-generated).
Related: #50257
Public API: adds optional capabilities.reasoning (Model.Reasoning) to models in the HTTP API, OpenAPI and client types; Config.Model.Reasoning now aliases it (backwards compatible)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I reproduced #59836 with the issue's script, running from source: on the base the plugin's none/low/medium/xhigh variants were replaced by low/medium/high; with this PR they are kept. All four new provider-config tests fail on the base and pass here. The related core and schema tests pass, check:generated is clean for protocol and client, and tsc --noEmit on core passes.
Public API changes, all additive and backwards compatible:
Model.Capabilities gets an optional reasoning field (Model.Reasoning: { supported: false } | { supported: true, toggle?, effort?, budget? }) in the HTTP API, OpenAPI spec and generated client types.Model.Reasoning is newly exported from @opencode/schema and core.Config.Model.Reasoning keeps its shape and identifier; it is now an alias of Model.Reasoning.Existing configs, plugins and callers keep working. Clients that branch on capabilities.reasoning being truthy should note that it can now be the object { supported: false }. The desktop app currently builds its own capabilities object, so it is not affected.
No blocking concerns.
Related: #50257
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new commit removes the API addition from my last review: Model.Capabilities, OpenAPI and the client types are back to the base, so the public API is unchanged. I re-ran the #59836 script from source and the plugin's none/low/medium/xhigh variants are kept. The core provider/model/variant tests pass (126/0), tsc on core passes, and protocol and client check:generated pass.
One trade-off to keep in mind (not blocking): a catalog model whose package is changed in config now gets every tier the new package supports. For example, a GLM model the catalog lists with only low/max that is pointed at Anthropic will also be offered medium/high.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
97b9008 to
bfd8fc6
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new commit keeps the fix. I re-ran the #59836 script from source: the base still replaces the plugin's variants with low/medium/high, while this head keeps none/low/medium/xhigh. The four new provider-config tests fail on the rebased base and pass here. The core provider, model, variant and catalog tests pass (224/0), and tsc on core passes. The public API is unchanged.
Moving model building into provider.transform and having the late pass re-apply only explicit config looks sound. Re-applying variant overlays a second time gives the same result, and restoring a removed model uses the model as it was before plugins ran. One behaviour change to be aware of: plugin edits to fields a config file doesn't set on a catalog model are now kept, because the late pass no longer resets those models to the catalog copy. That seems to be the intent. No blocking concerns.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…apply explicit overrides
bfd8fc6 to
fe9ef80
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
#59836 is still fixed: the issue's script, run from source, keeps the plugin's none/low/medium/xhigh variants. The core provider/model/variant/catalog/config tests pass (225/0) and tsc on core passes. The public API is unchanged.
The new canonical-switch commit adds one regression (inline). A custom model declared only in an earlier file is dropped from config tracking when a later file switches canonical, but it stays on the provider. It keeps the earlier file's fields and ends up with no variants ([]), where the base gives it the default tiers.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const current = providers.get(providerID) | ||
| const sourceOrigin = snapshot(item.canonical ?? current?.provider.canonical ?? providerID) | ||
| const { changed } = overlayProvider(providers, providerID, item) | ||
| if (changed) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This drops every configured entry for the provider, but models created by earlier files stay on the provider. A custom model declared only in an earlier file therefore survives with that file's fields and gets no default variants. The late pass also stops re-applying its config.
Repro, from a temporary test:
custom: { canonical: "openai", models: { extra: { name: "Extra" } } }.custom: { canonical: "anthropic" }.custom/extra has low..max.name: "Extra" and variants: [].Either remove those models along with their entries, or keep tracking the ones the later file doesn't list, so they still get default variants.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Catalog variants are not package-aware: overriding a provider'spackage breaks built-in variants
Model variants supplied by plugins are clobbered by late config transform
There was an error while loading. Please reload this page.