Skip to content

feat(core): fallback to 2.5 models with no access for toolcalls#21283

Merged
sehoon38 merged 1 commit intomainfrom
sehoon/model
Mar 5, 2026
Merged

feat(core): fallback to 2.5 models with no access for toolcalls#21283
sehoon38 merged 1 commit intomainfrom
sehoon/model

Conversation

@sehoon38
Copy link
Contributor

@sehoon38 sehoon38 commented Mar 5, 2026

Summary

This PR adds an optional hasAccessToPreview parameter to the resolveModel function in @google/gemini-cli-core. When this flag is set to false, any resolved preview model is automatically downgraded to its stable equivalent (e.g., gemini-3-pro-preview -> gemini-2.5-pro).

Details

  • Modified resolveModel in packages/core/src/config/models.ts to accept hasAccessToPreview: boolean = true.
  • Implemented downgrade logic for both pro and flash preview models.
  • Updated policyHelpers.ts to pass the access flag from the configuration.
  • Fixed a React hook dependency warning in useGeminiStream.ts that was blocking preflight.
  • Updated cli-help-agent.ts to use a concrete preview model directly.

Related Issues

Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1284

How to Validate

  1. Run unit tests: npm test -w @google/gemini-cli-core -- src/config/models.test.ts
  2. Verify that resolveModel with hasAccessToPreview: false returns non-preview models even when a preview model or alias is requested.

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

@sehoon38 sehoon38 requested a review from a team as a code owner March 5, 2026 16:46
@gemini-code-assist
Copy link
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 enhances the model resolution mechanism within the "@google/gemini-cli-core" package by introducing a new parameter to control access to preview models. This ensures that users without explicit access to preview models are automatically provided with stable alternatives, improving reliability and preventing unintended usage. Additionally, it includes a minor dependency fix in a React hook and updates an agent's model reference.

Highlights

  • Model Resolution Logic: Introduced a new "hasAccessToPreview" parameter to the "resolveModel" function, allowing for conditional downgrading of preview models to their stable equivalents if access is denied.
  • Preview Model Downgrade: Implemented logic within "resolveModel" to automatically downgrade requested preview models (e.g., "gemini-3-pro-preview") to their stable versions (e.g., "gemini-2.5-pro") when "hasAccessToPreview" is "false".
  • Configuration Integration: Updated "policyHelpers.ts" to retrieve and pass the "hasAccessToPreview" flag from the configuration to the "resolveModel" function, ensuring consistent model resolution based on user access.
  • Dependency Fix: Resolved a React hook dependency warning in "useGeminiStream.ts" by removing an unnecessary "config" dependency.
  • Agent Model Update: Modified "cli-help-agent.ts" to directly use "PREVIEW_GEMINI_FLASH_MODEL" instead of an alias, aligning with the new model resolution strategy.
Changelog
  • packages/cli/src/ui/hooks/useGeminiStream.ts
    • Removed "config" from the dependency array of "useGeminiStream" to resolve a React hook warning.
  • packages/core/src/agents/cli-help-agent.ts
    • Updated the import for the Flash model from "GEMINI_MODEL_ALIAS_FLASH" to "PREVIEW_GEMINI_FLASH_MODEL".
    • Changed the "modelConfig" to use "PREVIEW_GEMINI_FLASH_MODEL" directly.
  • packages/core/src/availability/policyHelpers.ts
    • Added "hasAccessToPreview" parameter to the "resolveModel" function call.
    • Moved the "hasAccessToPreview" variable declaration to before the "resolveModel" call.
    • Changed the return statement for proactive downgrade to an assignment to "chain".
  • packages/core/src/config/models.test.ts
    • Added a new test suite for "hasAccessToPreview" logic, including tests for downgrading preview models to default stable models when access is false.
  • packages/core/src/config/models.ts
    • Added "hasAccessToPreview: boolean = true" as a new parameter to the "resolveModel" function.
    • Refactored the "resolveModel" function to store the initial resolved model in a "resolved" variable.
    • Implemented conditional logic to check "hasAccessToPreview" and "isPreviewModel(resolved)", downgrading flash-lite, flash, and other preview models to their stable equivalents if access is false.
Activity
  • Unit tests were run for "src/config/models.test.ts".
  • Validation was performed on MacOS using "npm run".
  • New tests were added for the model resolution logic.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

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

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 introduces a hasAccessToPreview parameter to the resolveModel function to automatically downgrade preview models to their stable counterparts when a user lacks access. The changes are well-implemented across the affected files, including updates to policy helpers and tests. I've identified one area for improvement in packages/core/src/config/models.ts where the model downgrade logic could be made more robust to prevent potential issues with future model naming conventions. Overall, this is a solid feature addition that improves model resolution logic.

@sehoon38 sehoon38 changed the title feat(core): add hasAccessToPreview parameter to resolveModel feat(core): default to gemini 3 for cli-help-agent Mar 5, 2026
@sehoon38 sehoon38 marked this pull request as draft March 5, 2026 17:00
@sehoon38 sehoon38 marked this pull request as ready for review March 5, 2026 17:00
Copy link
Contributor

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

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 introduces a mechanism to gracefully downgrade preview models to their stable equivalents for users without preview access by adding a hasAccessToPreview flag to the resolveModel function. However, the implementation is incomplete. Critical functions like resolveClassifierModel do not respect the new access control flag, leading to widespread bypasses of the intended security policy. Furthermore, the model downgrade logic in models.ts should be made more robust, explicit, and less reliant on string matching to enhance future maintainability.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Size Change: +763 B (0%)

Total Size: 26 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.5 MB +763 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 5, 2026
@sehoon38 sehoon38 force-pushed the sehoon/model branch 2 times, most recently from a25a8ba to 27ec435 Compare March 5, 2026 18:27
@sehoon38 sehoon38 changed the title feat(core): default to gemini 3 for cli-help-agent feat(core): fallback to 2.5 models with no access for toolcalls Mar 5, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 22d962e Mar 5, 2026
28 checks passed
@sehoon38 sehoon38 deleted the sehoon/model branch March 5, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants