TypeScript
fix(web): text generation no longer falls back to the expensive flagship model (#19722)
Theo Browne45b5993a527f
diff --git a/apps/web/src/modelSelection.test.ts b/apps/web/src/modelSelection.test.tsindex cf1bf389dd1..ca00cd9b542 100644--- a/apps/web/src/modelSelection.test.ts+++ b/apps/web/src/modelSelection.test.ts@@ -1,5 +1,6 @@import {ANTIGRAVITY_DEFAULT_MODEL,+ DEFAULT_TEXT_GENERATION_MODEL,ProviderDriverKind,ProviderInstanceId,type ServerProvider,@@ -835,6 +836,24 @@ describe("instance-scoped model selection", () => {ProviderInstanceId.make("codex"),);});+ it("falls back to the text generation default, not the chat default, for a removed model", () => {+ const codex = provider({ instanceId: "codex", models: ["gpt-6-astra", "gpt-6-luna"] });+ const providers = [+ { ...codex, models: codex.models.map((m, i) => (i === 0 ? { ...m, isDefault: true } : m)) },+ ];+ const settings: UnifiedSettings = {+ ...settingsWithProviderInstances(),+ textGenerationModelSelection: createModelSelection(+ ProviderInstanceId.make("codex"),+ "gpt-5.6-luna",+ ),+ };++ expect(resolveAppModelSelectionState(settings, providers).model).toBe(+ DEFAULT_TEXT_GENERATION_MODEL,+ );+ });+it("does not select a provider that cannot generate system text", () => {const instanceId = ProviderInstanceId.make("antigravity");const unsupported = {diff --git a/apps/web/src/modelSelection.ts b/apps/web/src/modelSelection.tsindex 1ffd3b4be92..167f45c4c19 100644--- a/apps/web/src/modelSelection.ts+++ b/apps/web/src/modelSelection.ts@@ -366,9 +366,19 @@ export function resolveAppModelSelectionState(selectedEntry ?? entries.find((candidate) => candidate.enabled && candidate.isAvailable);if (entry) {// When the instance changed due to fallback (e.g. selected instance was disabled),- // don't carry over the old instance's model — use the fallback instance's default.+ // don't carry over the old instance's model.const selectedModel = selectedEntry ? selection.model : null;+ // A saved model the catalog no longer lists, or a new fallback instance,+ // gets the driver's cheap text generation default. The catalog's own+ // default is the flagship chat model, which is too expensive here.+ const options = getAppModelOptionsForInstance(settings, entry);const model =+ resolveSelectableModel(entry.driverKind, selectedModel, options) ??+ resolveSelectableModel(+ entry.driverKind,+ DEFAULT_TEXT_GENERATION_MODEL_BY_PROVIDER[entry.driverKind],+ options,+ ) ??resolveAppModelSelectionForInstance(entry.instanceId,settings,