Skip to content

fix(config): prevent rewriting explicitly pinned flash models - #29222

Open
HariomJangra wants to merge 1 commit into
google-gemini:mainfrom
HariomJangra:fix/flash-model-resolution
Open

fix(config): prevent rewriting explicitly pinned flash models#29222
HariomJangra wants to merge 1 commit into
google-gemini:mainfrom
HariomJangra:fix/flash-model-resolution

Conversation

@HariomJangra

@HariomJangra HariomJangra commented Sep 5, 2026

Copy link
Copy Markdown

Summary

When invoking Gemini CLI with --model gemini-2.5-flash, the model resolution logic silently rewrote the request to gemini-3.5-flash on backends where Gemini 3.5 Flash GA access is enabled (such as Vertex AI). For environments without access to gemini-3.5-flash, this resulted in a ModelNotFoundError.

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 to gemini-3.5-flash as expected.

Details

  • Legacy Model Resolution (packages/core/src/config/models.ts):
    • Removed model.endsWith('flash') from isFlashModel(). This catch-all condition was matching concrete model IDs such as gemini-2.5-flash and incorrectly treating them as generic flash aliases eligible for auto-upgrade.
  • Dynamic Model Config (packages/core/src/config/defaultModelConfigs.ts):
    • Removed the 'gemini-2.5-flash' entry from modelIdResolutions. In dynamic model configuration, concrete model IDs without explicit resolution rules automatically fall back to the requested model name.
  • Regression Tests (packages/core/src/config/models.test.ts):
    • Added unit tests to ensure gemini-2.5-flash is not rewritten under both legacy and dynamic routing, while verifying that the generic 'flash' alias continues to resolve to gemini-3.5-flash.

Related Issues

Fixes #29213

How to Validate

  1. Verify resolution logic directly:
npx tsx -e "
import { resolveModel, setFlashModels } from './packages/core/src/config/models.ts';
setFlashModels('gemini-3.5-flash', 'gemini-3.5-flash');
console.log('Concrete model:', resolveModel('gemini-2.5-flash', false, false, true, undefined, true));
console.log('Flash alias:', resolveModel('flash', false, false, true, undefined, true));
"

Expected output:

  • Concrete model: gemini-2.5-flash
  • Flash alias: gemini-3.5-flash
  1. Run targeted tests:
npm test -w @google/gemini-cli-core -- src/config/models.test.ts
  1. Run typecheck and linter:
npm run typecheck --workspace @google/gemini-cli-core
npm run lint --workspace @google/gemini-cli-core

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

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
@HariomJangra
HariomJangra requested a review from a team as a code owner September 5, 2026 21:41
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • Model Resolution Fix: Updated the model resolution logic to prevent the automatic rewriting of explicitly pinned models like 'gemini-2.5-flash' to 'gemini-3.5-flash'.
  • Legacy Logic Cleanup: Removed the overly broad 'model.endsWith('flash')' check in 'isFlashModel' to ensure concrete model IDs are not incorrectly treated as generic aliases.
  • Configuration Update: Removed 'gemini-2.5-flash' from dynamic model configurations to allow it to resolve to itself by default.
  • Regression Testing: Added new unit tests to verify that 'gemini-2.5-flash' remains unchanged while generic 'flash' aliases continue to resolve correctly.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/s A small PR label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 31
  • Additions: +19
  • Deletions: -12
  • Files changed: 3

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/core Issues related to User Interface, OS Support, Core Functionality priority/p1 Important and should be addressed in the near term. priority/p2 Important but can be addressed in a future release. size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected model resolution: gemini-2.5-flash is mapped to gemini-3.5-flash

1 participant