From 3dacc9fdddcaee7c10fb8d4aa043ff411cf2f4d0 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Fri, 18 Jul 2025 17:33:41 +0000 Subject: [PATCH] feat: update Gemini and Vertex AI models from preview to GA version - Remove outdated preview models (gemini-2.5-pro-preview-03-25, gemini-2.5-pro-preview-05-06, gemini-2.5-pro-preview-06-05) from gemini.ts and vertex.ts - Add backward compatibility logic in Gemini and Vertex providers to automatically map legacy preview models to gemini-2.5-pro GA version - Update OpenRouter provider to handle legacy preview model mapping - Update OpenRouter tests to reflect removal of preview model references Fixes #5444 --- packages/types/src/providers/gemini.ts | 74 ------------------- packages/types/src/providers/vertex.ts | 26 ------- .../fetchers/__tests__/openrouter.spec.ts | 3 +- src/api/providers/gemini.ts | 17 +++++ src/api/providers/openrouter.ts | 9 ++- src/api/providers/vertex.ts | 7 ++ 6 files changed, 33 insertions(+), 103 deletions(-) diff --git a/packages/types/src/providers/gemini.ts b/packages/types/src/providers/gemini.ts index a7225c7330..d13f2f9a93 100644 --- a/packages/types/src/providers/gemini.ts +++ b/packages/types/src/providers/gemini.ts @@ -68,80 +68,6 @@ export const geminiModels = { inputPrice: 0, outputPrice: 0, }, - "gemini-2.5-pro-preview-03-25": { - maxTokens: 65_535, - contextWindow: 1_048_576, - supportsImages: true, - supportsPromptCache: true, - inputPrice: 2.5, // This is the pricing for prompts above 200k tokens. - outputPrice: 15, - cacheReadsPrice: 0.625, - cacheWritesPrice: 4.5, - tiers: [ - { - contextWindow: 200_000, - inputPrice: 1.25, - outputPrice: 10, - cacheReadsPrice: 0.31, - }, - { - contextWindow: Infinity, - inputPrice: 2.5, - outputPrice: 15, - cacheReadsPrice: 0.625, - }, - ], - }, - "gemini-2.5-pro-preview-05-06": { - maxTokens: 65_535, - contextWindow: 1_048_576, - supportsImages: true, - supportsPromptCache: true, - inputPrice: 2.5, // This is the pricing for prompts above 200k tokens. - outputPrice: 15, - cacheReadsPrice: 0.625, - cacheWritesPrice: 4.5, - tiers: [ - { - contextWindow: 200_000, - inputPrice: 1.25, - outputPrice: 10, - cacheReadsPrice: 0.31, - }, - { - contextWindow: Infinity, - inputPrice: 2.5, - outputPrice: 15, - cacheReadsPrice: 0.625, - }, - ], - }, - "gemini-2.5-pro-preview-06-05": { - maxTokens: 65_535, - contextWindow: 1_048_576, - supportsImages: true, - supportsPromptCache: true, - inputPrice: 2.5, // This is the pricing for prompts above 200k tokens. - outputPrice: 15, - cacheReadsPrice: 0.625, - cacheWritesPrice: 4.5, - maxThinkingTokens: 32_768, - supportsReasoningBudget: true, - tiers: [ - { - contextWindow: 200_000, - inputPrice: 1.25, - outputPrice: 10, - cacheReadsPrice: 0.31, - }, - { - contextWindow: Infinity, - inputPrice: 2.5, - outputPrice: 15, - cacheReadsPrice: 0.625, - }, - ], - }, "gemini-2.5-pro": { maxTokens: 64_000, contextWindow: 1_048_576, diff --git a/packages/types/src/providers/vertex.ts b/packages/types/src/providers/vertex.ts index c405621f82..6b31726da0 100644 --- a/packages/types/src/providers/vertex.ts +++ b/packages/types/src/providers/vertex.ts @@ -56,32 +56,6 @@ export const vertexModels = { inputPrice: 0.15, outputPrice: 0.6, }, - "gemini-2.5-pro-preview-03-25": { - maxTokens: 65_535, - contextWindow: 1_048_576, - supportsImages: true, - supportsPromptCache: true, - inputPrice: 2.5, - outputPrice: 15, - }, - "gemini-2.5-pro-preview-05-06": { - maxTokens: 65_535, - contextWindow: 1_048_576, - supportsImages: true, - supportsPromptCache: true, - inputPrice: 2.5, - outputPrice: 15, - }, - "gemini-2.5-pro-preview-06-05": { - maxTokens: 65_535, - contextWindow: 1_048_576, - supportsImages: true, - supportsPromptCache: true, - inputPrice: 2.5, - outputPrice: 15, - maxThinkingTokens: 32_768, - supportsReasoningBudget: true, - }, "gemini-2.5-pro": { maxTokens: 64_000, contextWindow: 1_048_576, diff --git a/src/api/providers/fetchers/__tests__/openrouter.spec.ts b/src/api/providers/fetchers/__tests__/openrouter.spec.ts index f0ebead30f..7b780a941c 100644 --- a/src/api/providers/fetchers/__tests__/openrouter.spec.ts +++ b/src/api/providers/fetchers/__tests__/openrouter.spec.ts @@ -29,7 +29,6 @@ describe("OpenRouter API", () => { // Define models that are intentionally excluded const excludedModels = new Set([ - "google/gemini-2.5-pro-preview", // Excluded due to lag issue (#4487) "google/gemini-2.5-flash", // OpenRouter doesn't report this as supporting prompt caching "google/gemini-2.5-flash-lite-preview-06-17", // OpenRouter doesn't report this as supporting prompt caching ]) @@ -215,7 +214,7 @@ describe("OpenRouter API", () => { describe("getOpenRouterModelEndpoints", () => { it("fetches model endpoints and validates schema", async () => { const { nockDone } = await nockBack("openrouter-model-endpoints.json") - const endpoints = await getOpenRouterModelEndpoints("google/gemini-2.5-pro-preview") + const endpoints = await getOpenRouterModelEndpoints("google/gemini-2.5-pro") expect(endpoints).toEqual({ Google: { diff --git a/src/api/providers/gemini.ts b/src/api/providers/gemini.ts index 6765c8676d..b280d2131b 100644 --- a/src/api/providers/gemini.ts +++ b/src/api/providers/gemini.ts @@ -129,9 +129,26 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl } } + /** + * Check if the model ID is a legacy preview model that should be mapped to the GA version + */ + protected isLegacyPreviewModel(modelId: string): boolean { + return [ + "gemini-2.5-pro-preview-03-25", + "gemini-2.5-pro-preview-05-06", + "gemini-2.5-pro-preview-06-05" + ].includes(modelId) + } + override getModel() { const modelId = this.options.apiModelId let id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId + + // Handle backward compatibility for legacy preview models + if (modelId && this.isLegacyPreviewModel(modelId)) { + id = "gemini-2.5-pro" as GeminiModelId + } + const info: ModelInfo = geminiModels[id] const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options }) diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 6565daa238..6228709125 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -69,6 +69,13 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH this.client = new OpenAI({ baseURL, apiKey, defaultHeaders: DEFAULT_HEADERS }) } + /** + * Check if the model ID is a legacy Gemini preview model that should be mapped to the GA version + */ + private isLegacyGeminiPreviewModel(modelId: string): boolean { + return modelId === "google/gemini-2.5-pro-preview" + } + override async *createMessage( systemPrompt: string, messages: Anthropic.Messages.MessageParam[], @@ -83,7 +90,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH // i We should generalize this using the logic in `getModelParams`, but // this is easier for now. if ( - (modelId === "google/gemini-2.5-pro-preview" || modelId === "google/gemini-2.5-pro") && + (this.isLegacyGeminiPreviewModel(modelId) || modelId === "google/gemini-2.5-pro") && typeof reasoning === "undefined" ) { reasoning = { exclude: true } diff --git a/src/api/providers/vertex.ts b/src/api/providers/vertex.ts index 2c077d97b7..959ef3b6bf 100644 --- a/src/api/providers/vertex.ts +++ b/src/api/providers/vertex.ts @@ -15,6 +15,13 @@ export class VertexHandler extends GeminiHandler implements SingleCompletionHand override getModel() { const modelId = this.options.apiModelId let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId + + // Handle backward compatibility for legacy preview models + // Use the same logic as GeminiHandler + if (modelId && this.isLegacyPreviewModel(modelId)) { + id = "gemini-2.5-pro" as VertexModelId + } + const info: ModelInfo = vertexModels[id] const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options })