From d113a40f55a5326fdc4612f21172623e21e70275 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Fri, 2 Oct 2026 16:02:13 -0700 Subject: [PATCH] fix(core): rename legacy provider in top-level model (#51901) --- packages/core/src/config/normalize.ts | 7 ++++++- packages/core/src/v1/config/migrate.ts | 2 +- packages/core/test/config/config.test.ts | 3 +-- packages/core/test/config/normalization.test.ts | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/core/src/config/normalize.ts b/packages/core/src/config/normalize.ts index 4f2e884e019..f400b59ae2d 100644 --- a/packages/core/src/config/normalize.ts +++ b/packages/core/src/config/normalize.ts @@ -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, diff --git a/packages/core/src/v1/config/migrate.ts b/packages/core/src/v1/config/migrate.ts index a42a32c1892..d831e1b1f87 100644 --- a/packages/core/src/v1/config/migrate.ts +++ b/packages/core/src/v1/config/migrate.ts @@ -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" diff --git a/packages/core/test/config/config.test.ts b/packages/core/test/config/config.test.ts index e45b77fd6d3..2acdb5970b5 100644 --- a/packages/core/test/config/config.test.ts +++ b/packages/core/test/config/config.test.ts @@ -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([ diff --git a/packages/core/test/config/normalization.test.ts b/packages/core/test/config/normalization.test.ts index d8ee670b7cb..488156afe64 100644 --- a/packages/core/test/config/normalization.test.ts +++ b/packages/core/test/config/normalization.test.ts @@ -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({