Skip to content

fix(config): prevent complexity routing from overriding manually selected concrete models - #29266

Closed
amelidev wants to merge 1 commit into
google-gemini:mainfrom
amelidev:b_556300139
Closed

amelidev wants to merge 1 commit into
google-gemini:mainfrom
amelidev:b_556300139

Conversation

@amelidev

@amelidev amelidev commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses issue b_556300139, where the GCA (Normal Mode) would override explicit manually selected concrete models (e.g. chat-gemini-3-1-pro-preview-paid-tier) with Gemini 2.5 Flash when CliComplexityBasedRouting__enabled is set to true.

Details

  • Model Classification Robustness (packages/core/src/config/models.ts):

    • Refactored isAutoModel to defensively normalize (trim and lowercase) the incoming model ID.
    • Correctly handled dynamic model configurations: if a model ID is not registered in the dynamic model config service (like raw GCA configurations), it safely falls back to standard static checks (such as checking if it starts with auto- or matches auto aliases).
    • Any explicit manually selected concrete model will now correctly return false from isAutoModel, which forces OverrideStrategy to bypass complexity-based routing and respect the user's manual selection.
  • New Test Suite (packages/core/src/routing/strategies/complexityRoutingManualSelection.test.ts):

    • Added a dedicated test suite with full coverage of the manual model selection override logic under active complexity routing conditions. All tests pass successfully.

Related Issues

Fixes b_556300139

How to Validate

  1. Run the newly added test suite to verify manual selection override and complexity-based routing bypass:
    npm test -w @google/gemini-cli-core -- src/routing/strategies/complexityRoutingManualSelection.test.ts
  2. Run other existing config and override strategy tests:
    npm test -w @google/gemini-cli-core -- src/config/models.test.ts
    npm test -w @google/gemini-cli-core -- src/routing/strategies/overrideStrategy.test.ts

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

@amelidev
amelidev requested a review from a team as a code owner September 9, 2026 16:45
@github-actions github-actions Bot added the size/m A medium sized PR label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 114
  • Additions: +110
  • Deletions: -4
  • Files changed: 3

@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 resolves an issue where complexity-based routing incorrectly overrode manually selected models. By improving the robustness of model classification and ensuring that explicit selections bypass the automatic routing strategy, the system now consistently respects user-defined model preferences.

Highlights

  • Model Classification Robustness: Refactored the isAutoModel function to normalize model IDs by trimming and lowercasing, ensuring more reliable identification of auto-routing configurations.
  • Manual Selection Priority: Updated logic to ensure that manually selected concrete models are correctly identified as non-auto, preventing the complexity-based routing strategy from overriding user choices.
  • Test Coverage: Added a new test suite in complexityRoutingManualSelection.test.ts to verify that manual model selections are respected even when complexity-based routing is enabled.
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. ↩

@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 normalizes model names in isAutoModel and adds a check for the auto- prefix to identify auto-routing models. It also introduces unit tests to ensure manual model selections bypass complexity-based routing. The reviewer pointed out that checking for the auto- prefix is too broad and could mistakenly match non-Gemini models (e.g., auto-gpt), suggesting to restrict the prefix check to auto-gemini- instead.

Comment thread packages/core/src/config/models.ts Outdated
@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Sep 9, 2026
@amelidev

amelidev commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 updates the isAutoModel utility in packages/core/src/config/models.ts to normalize the model string by trimming and lowercasing it, and adds support for model names starting with the 'auto-' prefix. Additionally, it introduces a new test suite in packages/core/src/routing/strategies/complexityRoutingManualSelection.test.ts to verify that manual model selections correctly bypass complexity-based routing. I have no feedback to provide.

…cted concrete models

Enhances isAutoModel in models.ts to defensively trim and lowercase
all model IDs. If a model ID (such as GCA's raw model ID configurations)
does not exist in the dynamic model config service, it cleanly falls
back to static checks. This ensures concrete models are not misclassified
as auto models, allowing OverrideStrategy to correctly respect explicit
manual selections and bypass backend complexity-based routing.

Adds a new test suite to guarantee manual model selections are
respected under active complexity routing conditions.

Bug: b_556300139
@amelidev
amelidev force-pushed the b_556300139 branch 2 times, most recently from 40c2dc7 to a44c09e Compare September 9, 2026 17:31
@amelidev

amelidev commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 updates the isAutoModel utility in packages/core to normalize model names by trimming and converting them to lowercase, and adds support for identifying any model prefixed with auto-gemini- as an auto model. Additionally, it introduces corresponding unit tests and a new test suite (complexityRoutingManualSelection.test.ts) to ensure that manual model selection successfully bypasses complexity-based routing. There are no review comments, so no feedback is provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR 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.

1 participant