fix(core): rename legacy provider in top-level model (#51901)

This commit is contained in:
Kit Langton
2026-10-02 16:02:13 -07:00
committed by GitHub
Unverified
parent 54956aac22
commit d113a40f55
4 changed files with 23 additions and 4 deletions
+6 -1
View File
@@ -10,6 +10,7 @@ import { ConfigCompaction } from "@opencode/schema/config/compaction"
import { ConfigFormatter } from "@opencode/schema/config/formatter"
import { ConfigLSP } from "@opencode/schema/config/lsp"
import { ConfigMedia } from "@opencode/schema/config/media"
import { ConfigModel } from "@opencode/schema/config/model"
import { ConfigMCP } from "@opencode/schema/config/mcp"
import { ConfigPlugin } from "@opencode/schema/config/plugin"
import { ConfigPolicy } from "@opencode/schema/config/policy"
@@ -196,10 +197,14 @@ export function normalize(input: unknown): Result {
normalizeFormatter(input, encoded, diagnostics)
normalizeLsp(input, encoded, diagnostics)
const model = own(input, "model")
? decodeValue(ConfigModel.Selection, input.model, ["model"], diagnostics)
: undefined
if (model) encoded.model = { ...model, providerID: ConfigMigrateV1.providerID(model.providerID) }
const nativeAtomic = {
$schema: Info.fields.$schema,
shell: Info.fields.shell,
model: Info.fields.model,
default_agent: Info.fields.default_agent,
share: Info.fields.share,
enterprise: Info.fields.enterprise,
+1 -1
View File
@@ -160,7 +160,7 @@ function migrateGoogleVertexAnthropicProvider(info: ConfigProviderV1.Info) {
}
}
// Rename these only while migrating unambiguous V1 fields.
// Renames retired provider IDs in V1 fields and the shared top-level model.
export function providerID(input: string) {
if (input === "azure-cognitive-services") return "azure"
if (input === "google-vertex-anthropic") return "google-vertex"
+1 -2
View File
@@ -737,8 +737,7 @@ describe("Config", () => {
},
})
// The top-level model decodes as a native V2 field, so it does not receive the legacy provider rename.
expect(migrated.model).toEqual({ providerID: "azure-cognitive-services", model: "deployment" })
expect(migrated.model).toEqual({ providerID: "azure", model: "deployment" })
expect(migrated.agents?.reviewer?.model).toEqual({ providerID: "google-vertex", model: "claude-sonnet" })
expect(migrated.commands?.review?.model).toEqual({ providerID: "azure", model: "deployment" })
expect(migrated.experimental?.policies).toEqual([
@@ -149,6 +149,21 @@ describe("ConfigNormalize", () => {
expect(() => Schema.decodeUnknownSync(Info)(result.encoded)).not.toThrow()
})
test("renames legacy provider IDs in the top-level model", () => {
expect(normalized({ model: "google-vertex-anthropic/claude#high" }).encoded.model).toEqual({
providerID: "google-vertex",
model: "claude",
variant: "high",
})
expect(
normalized({ model: { providerID: "azure-cognitive-services", model: "deployment" } }).encoded.model,
).toEqual({ providerID: "azure", model: "deployment" })
expect(normalized({ model: "anthropic/claude" }).encoded.model).toEqual({
providerID: "anthropic",
model: "claude",
})
})
test("migrates the legacy small model to the title agent", () => {
const result = normalized({ small_model: "anthropic/claude-haiku-4-5" })
expect(result.encoded.agents).toEqual({