From 36572f229306bf3b491657e8cb091505dcf1eea3 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 7 Jul 2025 13:47:03 +0000 Subject: [PATCH] feat: update Gemini and Vertex AI models from preview to GA version (#5444) - Remove outdated preview models (gemini-2.5-pro-preview-*) from type definitions - Update to GA model (gemini-2.5-pro) across all providers - Implement backward compatibility for existing users with preview models - Update OpenRouter integration to remove preview model references - Fix related tests to reflect model changes Fixes #5444 --- packages/types/src/providers/gemini.ts | 74 ------------------- packages/types/src/providers/openrouter.ts | 1 - packages/types/src/providers/vertex.ts | 26 ------- packages/types/src/providers/vscode-llm.ts | 4 +- .../fetchers/__tests__/openrouter.spec.ts | 2 - src/api/providers/gemini.ts | 19 ++++- src/api/providers/openrouter.ts | 15 +++- src/api/providers/vertex.ts | 10 ++- 8 files changed, 40 insertions(+), 111 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/openrouter.ts b/packages/types/src/providers/openrouter.ts index bbdbc7e732..518169721a 100644 --- a/packages/types/src/providers/openrouter.ts +++ b/packages/types/src/providers/openrouter.ts @@ -78,7 +78,6 @@ export const OPEN_ROUTER_REASONING_BUDGET_MODELS = new Set([ "anthropic/claude-3.7-sonnet:beta", "anthropic/claude-opus-4", "anthropic/claude-sonnet-4", - "google/gemini-2.5-pro-preview", "google/gemini-2.5-pro", "google/gemini-2.5-flash-preview-05-20", "google/gemini-2.5-flash", diff --git a/packages/types/src/providers/vertex.ts b/packages/types/src/providers/vertex.ts index b048c19403..d830155932 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/packages/types/src/providers/vscode-llm.ts b/packages/types/src/providers/vscode-llm.ts index bf38cb814b..7e52b27887 100644 --- a/packages/types/src/providers/vscode-llm.ts +++ b/packages/types/src/providers/vscode-llm.ts @@ -120,8 +120,8 @@ export const vscodeLlmModels = { inputPrice: 0, outputPrice: 0, family: "gemini-2.5-pro", - version: "gemini-2.5-pro-preview-03-25", - name: "Gemini 2.5 Pro (Preview)", + version: "gemini-2.5-pro", + name: "Gemini 2.5 Pro", supportsToolCalling: true, maxInputTokens: 63830, }, diff --git a/src/api/providers/fetchers/__tests__/openrouter.spec.ts b/src/api/providers/fetchers/__tests__/openrouter.spec.ts index f0ebead30f..a1c8e2c14c 100644 --- a/src/api/providers/fetchers/__tests__/openrouter.spec.ts +++ b/src/api/providers/fetchers/__tests__/openrouter.spec.ts @@ -223,7 +223,6 @@ describe("OpenRouter API", () => { contextWindow: 1048576, supportsImages: true, supportsPromptCache: true, - supportsReasoningBudget: true, inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 1.625, @@ -237,7 +236,6 @@ describe("OpenRouter API", () => { contextWindow: 1048576, supportsImages: true, supportsPromptCache: true, - supportsReasoningBudget: true, inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 1.625, diff --git a/src/api/providers/gemini.ts b/src/api/providers/gemini.ts index 6765c8676d..81819e204e 100644 --- a/src/api/providers/gemini.ts +++ b/src/api/providers/gemini.ts @@ -131,7 +131,15 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl override getModel() { const modelId = this.options.apiModelId - let id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId + + // Handle backward compatibility for legacy preview model names + let mappedModelId = modelId + if (modelId && this.isLegacyPreviewModel(modelId)) { + mappedModelId = "gemini-2.5-pro" + } + + let id = + mappedModelId && mappedModelId in geminiModels ? (mappedModelId as GeminiModelId) : geminiDefaultModelId const info: ModelInfo = geminiModels[id] const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options }) @@ -142,6 +150,15 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl return { id: id.endsWith(":thinking") ? id.replace(":thinking", "") : id, info, ...params } } + protected isLegacyPreviewModel(modelId: string): boolean { + const legacyPreviewModels = [ + "gemini-2.5-pro-preview-03-25", + "gemini-2.5-pro-preview-05-06", + "gemini-2.5-pro-preview-06-05", + ] + return legacyPreviewModels.includes(modelId) + } + async completePrompt(prompt: string): Promise { try { const { id: model } = this.getModel() diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 6565daa238..2a371e140b 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -82,10 +82,13 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH // other providers (including Gemini), so we need to explicitly disable // 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") && - typeof reasoning === "undefined" - ) { + // Handle backward compatibility for legacy preview model names + let mappedModelId = modelId + if (this.isLegacyGeminiPreviewModel(modelId)) { + mappedModelId = "google/gemini-2.5-pro" + } + + if (mappedModelId === "google/gemini-2.5-pro" && typeof reasoning === "undefined") { reasoning = { exclude: true } } @@ -242,4 +245,8 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH const completion = response as OpenAI.Chat.ChatCompletion return completion.choices[0]?.message?.content || "" } + + private isLegacyGeminiPreviewModel(modelId: string): boolean { + return modelId === "google/gemini-2.5-pro-preview" + } } diff --git a/src/api/providers/vertex.ts b/src/api/providers/vertex.ts index 2c077d97b7..66a6c1fba2 100644 --- a/src/api/providers/vertex.ts +++ b/src/api/providers/vertex.ts @@ -14,7 +14,15 @@ 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 model names + let mappedModelId = modelId + if (modelId && this.isLegacyPreviewModel(modelId)) { + mappedModelId = "gemini-2.5-pro" + } + + let id = + mappedModelId && mappedModelId in vertexModels ? (mappedModelId as VertexModelId) : vertexDefaultModelId const info: ModelInfo = vertexModels[id] const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options })