Skip to content

fix(core): ensure correct flash model steering in plan mode implementation phase#21871

Merged
jerop merged 1 commit intomainfrom
fix/plan-mode-model-steering
Mar 10, 2026
Merged

fix(core): ensure correct flash model steering in plan mode implementation phase#21871
jerop merged 1 commit intomainfrom
fix/plan-mode-model-steering

Conversation

@jerop
Copy link
Copy Markdown
Contributor

@jerop jerop commented Mar 10, 2026

This fix addresses an issue where using the 'auto' model alias would steer to Gemini 2.5 Flash during the implementation phase, even when Gemini 3 models were preferred.

  • Updated isPreviewModel to include the generic 'auto' alias.
  • Refactored ApprovalModeStrategy to use resolveClassifierModel for consistent resolution that respects Gemini 3.1 launch status.
  • Added getUseCustomToolModel and getUseCustomToolModelSync to Config class to centralize custom model resolution logic based on auth type.
  • Consolidated duplicate custom model resolution logic in ClassifierStrategy, NumericalClassifierStrategy, and policyHelpers.
  • Added regression tests for the 'auto' alias and Gemini 3.1 routing in ApprovalModeStrategy.

Closes #21868


Notice Responding with gemini-3.1-pro-preview when in Plan mode and Auto (Gemini 3) model selection :

image

Notice Responding with gemini-3-flash-preview after exiting Plan mode and Auto (Gemini 3) model selection :
image


Session stats showing gemini-3.1-pro-preview and gemini-3-flash-preview use:
image

…ation phase

This fix addresses an issue where using the 'auto' model alias would steer to Gemini 2.5 Flash during the implementation phase, even when Gemini 3 models were preferred.

- Updated isPreviewModel to include the generic 'auto' alias.
- Refactored ApprovalModeStrategy to use resolveClassifierModel for consistent resolution that respects Gemini 3.1 launch status.
- Added getUseCustomToolModel and getUseCustomToolModelSync to Config class to centralize custom model resolution logic based on auth type.
- Consolidated duplicate custom model resolution logic in ClassifierStrategy, NumericalClassifierStrategy, and policyHelpers.
- Added regression tests for the 'auto' alias and Gemini 3.1 routing in ApprovalModeStrategy.
@jerop jerop requested a review from a team as a code owner March 10, 2026 13:02
@github-actions
Copy link
Copy Markdown

Size Change: +870 B (0%)

Total Size: 26.1 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.7 MB +870 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

@jerop jerop added the release/patch-to-preview PR needs to be patch to preview release label Mar 10, 2026
@jerop jerop enabled auto-merge March 10, 2026 13:07
@jerop jerop added this pull request to the merge queue Mar 10, 2026
@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 10, 2026
Merged via the queue into main with commit 5dd2dab Mar 10, 2026
30 checks passed
@jerop jerop deleted the fix/plan-mode-model-steering branch March 10, 2026 13:43
@jerop
Copy link
Copy Markdown
Contributor Author

jerop commented Mar 10, 2026

/patch preview

@github-actions
Copy link
Copy Markdown

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 5dd2dab189efa0f0007f6472be9506306883dc9f
  • Workflows Created: 1

🔗 Track Progress:

github-actions bot pushed a commit that referenced this pull request Mar 10, 2026
…ation phase (#21871)

# Conflicts:
#	packages/core/src/availability/policyHelpers.ts
@github-actions
Copy link
Copy Markdown

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. ⚠️ Resolve conflicts in the hotfix PR first: #21876
  2. Test your changes after resolving conflicts
  3. Once merged, the patch release will automatically trigger
  4. You'll receive updates here when the release completes

🔗 Track Progress:

@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 a critical issue where the 'auto' model alias would incorrectly default to Gemini 2.5 Flash during the implementation phase, even when newer Gemini 3 models were available and preferred. The changes centralize and streamline the logic for model selection, ensuring that the system consistently steers to the appropriate Gemini 3.1 models based on configuration and authentication type, thereby improving the accuracy and efficiency of model usage.

Highlights

  • Model Alias Recognition: The 'auto' model alias is now correctly recognized as a preview model, preventing incorrect steering to older Gemini Flash models during the implementation phase.
  • Centralized Custom Model Logic: New getUseCustomToolModel and getUseCustomToolModelSync methods were added to the Config class, centralizing the logic for determining when to use a custom tool model based on Gemini 3.1 launch status and authentication type.
  • Refactored Model Resolution: The ApprovalModeStrategy was refactored to use resolveClassifierModel for consistent model resolution, ensuring proper steering to Gemini 3.1 models when preferred. Duplicate custom model resolution logic was consolidated across ClassifierStrategy, NumericalClassifierStrategy, and policyHelpers.
  • Improved Test Coverage: Regression tests were added to verify the correct routing behavior for the 'auto' alias and Gemini 3.1 in the ApprovalModeStrategy.
Changelog
  • packages/core/src/availability/policyHelpers.test.ts
    • Modified the createMockConfig function to include a mock for getUseCustomToolModelSync, aligning with the new centralized model resolution logic.
  • packages/core/src/availability/policyHelpers.ts
    • Removed the direct import of AuthType as its usage was replaced by a centralized configuration method.
    • Updated the resolvePolicyChain function to utilize config.getUseCustomToolModelSync() for determining custom tool model usage, removing redundant logic.
  • packages/core/src/config/config.ts
    • Added getUseCustomToolModel (async) and getUseCustomToolModelSync (sync) methods to the Config class to encapsulate and centralize the logic for custom tool model resolution.
  • packages/core/src/config/models.ts
    • Updated the isPreviewModel function to include GEMINI_MODEL_ALIAS_AUTO, ensuring the 'auto' alias is correctly identified as a preview model.
  • packages/core/src/routing/strategies/approvalModeStrategy.test.ts
    • Imported GEMINI_MODEL_ALIAS_AUTO and AuthType for use in new test cases.
    • Extended the mock configuration to include getGemini31Launched, getUseCustomToolModel, and getContentGeneratorConfig for comprehensive testing.
    • Added new test cases to validate correct model routing for the 'auto' alias in both plan and implementation modes, and to confirm proper routing to the Preview Flash model when Gemini 3.1 is launched.
  • packages/core/src/routing/strategies/approvalModeStrategy.ts
    • Removed direct imports of specific default and preview Gemini models and isPreviewModel.
    • Added imports for resolveClassifierModel, GEMINI_MODEL_ALIAS_FLASH, and GEMINI_MODEL_ALIAS_PRO to support the refactored model resolution.
    • Refactored model selection logic in both planning and implementation phases to leverage resolveClassifierModel, incorporating Gemini 3.1 launch status and custom tool model usage.
  • packages/core/src/routing/strategies/classifierStrategy.test.ts
    • Added a mock for getUseCustomToolModel to the createMockConfig function for testing purposes.
  • packages/core/src/routing/strategies/classifierStrategy.ts
    • Removed the direct import of AuthType as its usage was replaced by a centralized configuration method.
    • Updated the model resolution logic to use config.getUseCustomToolModel() for determining custom tool model usage.
  • packages/core/src/routing/strategies/numericalClassifierStrategy.test.ts
    • Added a mock for getUseCustomToolModel to the createMockConfig function for testing purposes.
  • packages/core/src/routing/strategies/numericalClassifierStrategy.ts
    • Removed the direct import of AuthType as its usage was replaced by a centralized configuration method.
    • Updated the model resolution logic to use config.getUseCustomToolModel() for determining custom tool model usage.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
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
Copy Markdown
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 effectively addresses an issue with model steering in plan mode by ensuring the 'auto' model alias correctly resolves to Gemini 3 models when appropriate. The changes include a crucial update to isPreviewModel to recognize the 'auto' alias. More importantly, the PR introduces a significant refactoring by centralizing the logic for determining custom tool model usage into new methods within the Config class. This removes duplicated code from several routing strategies (ApprovalModeStrategy, ClassifierStrategy, NumericalClassifierStrategy) and helper files, replacing it with calls to the new centralized methods. This not only fixes the bug but also improves code maintainability and consistency. The addition of regression tests for the 'auto' alias and Gemini 3.1 routing further strengthens the changes. The implementation is clean and well-executed.

@github-actions
Copy link
Copy Markdown

🚀 Patch Release Started!

📋 Release Details:

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions
Copy link
Copy Markdown

Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

PrasannaPal21 pushed a commit to PrasannaPal21/gemini-cli that referenced this pull request Mar 10, 2026
@jerop jerop removed the release/patch-to-preview PR needs to be patch to preview release label Mar 10, 2026
kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 12, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
SUNDRAM07 pushed a commit to SUNDRAM07/gemini-cli that referenced this pull request Mar 30, 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 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model steering incorrectly reverts to Gemini 2.5 Flash after Plan Mode when using 'auto' alias

2 participants