fix(config): prevent rewriting explicitly pinned flash models - #29222
fix(config): prevent rewriting explicitly pinned flash models#29222HariomJangra wants to merge 1 commit into
Conversation
Do not match broad endsWith('flash') in isFlashModel() and remove the auto-upgrade rule for gemini-2.5-flash in defaultModelConfigs, ensuring explicitly pinned models are not rewritten to gemini-3.5-flash.
Fixes google-gemini#29213
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the Gemini CLI incorrectly auto-upgraded specific model IDs to newer versions, causing failures in environments without access to those newer models. By refining the model resolution logic and removing overly aggressive matching patterns, the system now correctly distinguishes between generic flash aliases and explicitly pinned model versions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request removes the automatic rewriting of explicitly requested gemini-2.5-flash models to gemini-3.5-flash. Specifically, it removes the gemini-2.5-flash configuration block from defaultModelConfigs.ts, refactors isFlashModel in models.ts to no longer match any model ending with 'flash', and adds corresponding unit tests in models.test.ts to verify that gemini-2.5-flash remains untouched. There are no review comments, so I have no feedback to provide.
Summary
When invoking Gemini CLI with
--model gemini-2.5-flash, the model resolution logic silently rewrote the request togemini-3.5-flashon backends where Gemini 3.5 Flash GA access is enabled (such as Vertex AI). For environments without access togemini-3.5-flash, this resulted in aModelNotFoundError.This PR fixes model resolution so that explicitly pinned model IDs (like
gemini-2.5-flash) are preserved and passed through untouched, while ensuring generic aliases (like'flash') continue to resolve togemini-3.5-flashas expected.Details
packages/core/src/config/models.ts):model.endsWith('flash')fromisFlashModel(). This catch-all condition was matching concrete model IDs such asgemini-2.5-flashand incorrectly treating them as generic flash aliases eligible for auto-upgrade.packages/core/src/config/defaultModelConfigs.ts):'gemini-2.5-flash'entry frommodelIdResolutions. In dynamic model configuration, concrete model IDs without explicit resolution rules automatically fall back to the requested model name.packages/core/src/config/models.test.ts):gemini-2.5-flashis not rewritten under both legacy and dynamic routing, while verifying that the generic'flash'alias continues to resolve togemini-3.5-flash.Related Issues
Fixes #29213
How to Validate
Expected output:
Concrete model: gemini-2.5-flashFlash alias: gemini-3.5-flashnpm test -w @google/gemini-cli-core -- src/config/models.test.tsPre-Merge Checklist