diff --git a/src/resources/extensions/sf/preferences-models.ts b/src/resources/extensions/sf/preferences-models.ts index 2cb031a1c..57a9faadd 100644 --- a/src/resources/extensions/sf/preferences-models.ts +++ b/src/resources/extensions/sf/preferences-models.ts @@ -429,7 +429,17 @@ export function resolveModelWithFallbacksForUnit( // Normalize: string -> { model, fallbacks: [] } if (typeof phaseConfig === "string") { - return { primary: phaseConfig, fallbacks: [] }; + const auto = autoBenchmark + ? resolveAutoBenchmarkPickForUnit(unitType, prefs?.preferences) + : undefined; + const autoFallbacks = (auto?.fallbacks ?? []).filter( + (id) => id !== phaseConfig, + ); + // Don't double-include the user's primary if benchmarks picked it as #1. + if (auto && auto.primary !== phaseConfig) { + autoFallbacks.unshift(auto.primary); + } + return { primary: phaseConfig, fallbacks: autoFallbacks }; } // When provider is explicitly set, prepend it to the model ID so the @@ -439,10 +449,24 @@ export function resolveModelWithFallbacksForUnit( ? `${phaseConfig.provider}/${phaseConfig.model}` : phaseConfig.model; - return { - primary, - fallbacks: phaseConfig.fallbacks ?? [], - }; + const userFallbacks = phaseConfig.fallbacks ?? []; + if (userFallbacks.length > 0) { + // Explicit fallbacks: respect them as-is, no auto-fill. + return { primary, fallbacks: userFallbacks }; + } + + // Auto-fill empty/missing fallbacks from the benchmark picker so a user + // who only pinned a primary still gets rate-limit auto-switch behavior + // out of the box. The auto-pick may include the user's primary as its #1 + // — drop it to avoid `primary == fallbacks[0]` no-op switches. + const auto = autoBenchmark + ? resolveAutoBenchmarkPickForUnit(unitType, prefs?.preferences) + : undefined; + const autoFallbacks = (auto?.fallbacks ?? []).filter((id) => id !== primary); + if (auto && auto.primary !== primary) { + autoFallbacks.unshift(auto.primary); + } + return { primary, fallbacks: autoFallbacks }; } /**