Skip to content

fix: use thinking levels for Gemini 3 models#3609

Open
MashiroCodfish wants to merge 2 commits intochatboxai:mainfrom
MashiroCodfish:fix/gemini-3-thinking-levels
Open

fix: use thinking levels for Gemini 3 models#3609
MashiroCodfish wants to merge 2 commits intochatboxai:mainfrom
MashiroCodfish:fix/gemini-3-thinking-levels

Conversation

@MashiroCodfish
Copy link
Copy Markdown

@MashiroCodfish MashiroCodfish commented Mar 30, 2026

Summary

  • switch Gemini 3 session settings from thinking budgets to documented model-specific thinking levels
  • keep Gemini 2.5 on thinking budgets, but stop guessing Gemini 3 levels from legacy budgets
  • clean up the stale tooltip translation key and tighten a couple of related UI/type edges touched by this change

Notes

  • the Gemini 3 level matrix now follows the documented families instead of broad flash heuristics
  • legacy Gemini 3 thinking budgets are dropped so requests fall back to the model's documented default level instead of using an inferred mapping

Testing

  • pnpm exec vitest run src/shared/utils/google-thinking.test.ts src/shared/models/index.test.ts src/shared/providers/registry.test.ts

Closes #3542

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2669e62e-47ca-47a3-a2cd-0380e4002bd6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MashiroCodfish MashiroCodfish force-pushed the fix/gemini-3-thinking-levels branch from ec8c8b1 to 787782f Compare March 30, 2026 17:05
@themez
Copy link
Copy Markdown
Contributor

themez commented Mar 31, 2026

Nice work overall — the budget vs level split for Gemini 2.5/3 is the right call. Two issues worth addressing:

1. UI shows a default thinking level that is never sent to the API

In GoogleProviderConfig, when a Gemini 3 session has no saved thinkingLevel, currentThinkingLevel falls back to getDefaultGoogleThinkingLevel(modelId) (e.g. "High") and renders it in the SegmentedControl. But if the user saves settings without touching the control, handleLevelChange is never called, so providerOptions.google.thinkingConfig.thinkingLevel stays empty. Then normalizeGoogleThinkingConfig() omits thinkingLevel from the request entirely.

Result: UI says "High", but the actual API call uses the model's server-side default (which may differ).

Fix: write the fallback level into providerOptions when the component mounts or when the model changes, so the displayed value always matches what gets sent.

2. Stale thinkingLevel persists for unsupported Gemini 3 variants

normalizeGoogleThinkingConfig() at line 68-71 preserves thinkingLevel when supportedLevels.length === 0 (the supportedLevels.includes(thinkingLevel) check passes vacuously). So if a user sets a level on gemini-3-flash-preview, then switches to gemini-3.1-flash-image-preview (not in GOOGLE_THINKING_LEVELS_BY_MODEL), the old level is still sent in the request. The UI hides the level control for that model, so the user can't clear it.

Fix: in the mode === 'level' branch of normalizeGoogleThinkingConfig, strip thinkingLevel when supportedLevels.length === 0.

@MashiroCodfish
Copy link
Copy Markdown
Author

Thanks, fixed both points in the latest push (5ac4b78e).

Changes:

  • sync the fallback Gemini 3 thinking level back into providerOptions so the UI value matches what gets sent
  • strip stale thinkingLevel values for Gemini 3 variants that are in level mode but don't have a supported level matrix in our mapping
  • add a regression test covering the unsupported-variant cleanup path

Re-tested with:

  • pnpm exec vitest run src/shared/utils/google-thinking.test.ts src/shared/models/index.test.ts src/shared/providers/registry.test.ts

@themez
Copy link
Copy Markdown
Contributor

themez commented Mar 31, 2026

Thanks for the contribution! The core idea of splitting Gemini 3 thinking levels from Gemini 2.5 thinking budgets is exactly right.

After reviewing this PR, we found a few issues we'd like to address:

  1. Reset behavior: the canonicalThinkingConfig useEffect writes back a default level even after the user resets session settings, making Reset ineffective for Gemini 3 sessions
  2. Missing medium for gemini-3-pro: the official docs list low/medium/high for all Pro models, but the PR only maps low/high
  3. Pro regex matches image models: ^gemini-3-pro also matches gemini-3-pro-image-preview, which shouldn't have thinking level support
  4. Case sensitivity inconsistency: startsWith is case-sensitive but the regex uses /i
  5. Hard-coded model versions: each version needs a separate regex entry; a generalized pattern like gemini-3\.?[\d]*-pro would cover future versions automatically

We've already implemented a fix internally that addresses all of the above. The main design difference is that instead of writing back defaults via useEffect (which breaks Reset), we fill in the default level inside normalizeGoogleThinkingConfig at request time — so the stored config stays clean while the API always receives the correct level.

I plan to land our version directly. Would you mind if we close this PR? Happy to credit you in the commit message for identifying the original issue and the overall approach. Thanks again for the effort!

@MashiroCodfish
Copy link
Copy Markdown
Author

Thanks for the detailed review and for implementing the follow-up fix on your side. Please feel free to close this PR.

And yes, I'd appreciate the credit in the commit message — thanks again for taking this forward.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Gemini 3新系列模型的思考参数已经不支持了Thinking budgets,Thinking budgets无效

2 participants