fix: add google provider model transform across all resolution paths
transformModelForProvider only handled github-copilot provider, leaving google provider models untransformed. This caused ProviderModelNotFoundError when google/gemini-3-flash was sent to the API (correct ID is gemini-3-flash-preview). Changes: - Add google provider to transformModelForProvider with idempotent regex negative lookahead to prevent double -preview suffix - Fix category-default path in model-resolution-pipeline when availableModels is empty but connected provider exists - Fix getFirstFallbackModel first-run path that constructed raw model IDs without transformation - Fix github-copilot provider gemini transforms to also use idempotent regex (was vulnerable to double-transform) - Extract transformModelForProvider to shared module (single source of truth, imported by cli and shared layers) - Add 20 new test cases: unit tests for both providers, runtime integration tests for category-default and fallback-chain paths, double-transform prevention for both providers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { resolveModelPipeline } from "../../shared"
|
||||
import { transformModelForProvider } from "../../shared/provider-model-id-transform"
|
||||
|
||||
export function applyModelResolution(input: {
|
||||
uiSelectedModel?: string
|
||||
@@ -20,8 +21,10 @@ export function getFirstFallbackModel(requirement?: {
|
||||
}) {
|
||||
const entry = requirement?.fallbackChain?.[0]
|
||||
if (!entry || entry.providers.length === 0) return undefined
|
||||
const provider = entry.providers[0]
|
||||
const transformedModel = transformModelForProvider(provider, entry.model)
|
||||
return {
|
||||
model: `${entry.providers[0]}/${entry.model}`,
|
||||
model: `${provider}/${transformedModel}`,
|
||||
provenance: "provider-fallback" as const,
|
||||
variant: entry.variant,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user