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,5 +1,6 @@
|
||||
import type { FallbackEntry } from "../../shared/model-requirements"
|
||||
import { fuzzyMatchModel } from "../../shared/model-availability"
|
||||
import { transformModelForProvider } from "../../shared/provider-model-id-transform"
|
||||
|
||||
function normalizeModel(model?: string): string | undefined {
|
||||
const trimmed = model?.trim()
|
||||
@@ -38,7 +39,8 @@ export function resolveModelForDelegateTask(input: {
|
||||
const first = fallbackChain[0]
|
||||
const provider = first?.providers?.[0]
|
||||
if (provider) {
|
||||
return { model: `${provider}/${first.model}`, variant: first.variant }
|
||||
const transformedModelId = transformModelForProvider(provider, first.model)
|
||||
return { model: `${provider}/${transformedModelId}`, variant: first.variant }
|
||||
}
|
||||
} else {
|
||||
for (const entry of fallbackChain) {
|
||||
|
||||
Reference in New Issue
Block a user