fix(gemini): follow provider defaults for Gemini 3 thinking - #25764
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR changes Gemini 3
Confidence Score: 4/5Safe to merge after addressing the flag default direction; logic itself is correct but the default silently breaks existing Gemini 3 thinking integrations. One P1 finding: the feature flag defaults to the new behavior rather than preserving the old one, creating an unannounced breaking change for existing users. The core translation logic and test coverage are sound, limiting exposure, but the default choice conflicts with the project's backwards-compatibility policy. litellm/init.py — flag default direction needs review before merging.
|
| Filename | Overview |
|---|---|
| litellm/init.py | Adds enable_gemini_default_thinking_level_low flag (default False); flag defaults to new behavior, creating a backwards-incompatible change for existing Gemini 3 users. |
| litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py | Removes forced thinkingLevel injection for Gemini 3 models; now only sets it when feature flag is True. Logic is correct; retains pre-existing hardcoded model-name checks. |
| tests/llm_translation/test_gemini.py | Existing test split into default-behavior and feature-flag paths; assertions correctly updated to reflect new provider-default behavior; flag state is restored in finally blocks. |
Reviews (4): Last reviewed commit: "fix(gemini): follow provider defaults fo..." | Re-trigger Greptile
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29203092 | Triggered | Generic High Entropy Secret | 0c4aaa2 | tests/test_litellm/proxy/test_api_key_masking_in_errors.py | View secret |
| 29203053 | Triggered | Generic Password | a86f426 | .circleci/config.yml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Stop forcing Gemini 3 thinkingLevel for Anthropic-style thinking params by default, and gate legacy low/minimal mapping behind an explicit feature flag to avoid provider-default confusion. Made-with: Cursor
a86f426 to
8d9db7b
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8d9db7b. Configure here.
| enable_gemini_default_thinking_level_low: bool = ( | ||
| False # opt-in: force thinkingLevel low/minimal for Gemini 3 thinking param mapping | ||
| ) |
There was a problem hiding this comment.
Backwards-incompatible default — existing users will silently get new behavior
The flag defaults to False, which means every Gemini 3 user upgrading litellm will immediately stop receiving a forced thinkingLevel in their requests without any action on their part. Per the project's backwards-compatibility rule, the safe default is to preserve the existing behavior (defaulting to True) and require users to explicitly opt in to the new provider-default behavior. As written, users who relied on thinkingLevel being set need to find and set this flag to restore it — discovery is poor and the risk of silent regressions is high.
Consider either defaulting to True (preserve old behavior, opt-in to new), or naming the flag around the new behavior (e.g. enable_gemini_provider_default_thinking) and defaulting it to False so existing behavior is unchanged until users explicitly enable it.
Rule Used: What: avoid backwards-incompatible changes without... (source)
mateo-berri
left a comment
There was a problem hiding this comment.
Is greptile issue a concern?
|
@mateo-berri It is talking about backward compatibility, we can just tell the users to use this flag if the want litellm to set default thinking. I don't think we should by default set a thinking level. So i don't think the comment is relevant |
mateo-berri
left a comment
There was a problem hiding this comment.
OK, makes sense. LGTM!
d493606
into
litellm_internal_staging
…_default_thinking fix(gemini): follow provider defaults for Gemini 3 thinking
Summary
thinkingLevelfor Gemini 3 whenthinkingparams are passed, so default behavior follows provider defaultsenable_gemini_default_thinking_level_lowDocs: BerriAI/litellm-docs#60
Note
Medium Risk
Changes Gemini 3 request translation to stop forcing
thinkingLevelwhenthinkingis provided, which can alter model behavior/output and token usage for existing integrations; legacy behavior is retained behind a new feature flag.Overview
Gemini 3+
thinkingparameter mapping now follows provider defaults by default:VertexGeminiConfig._map_thinking_paramsetsincludeThoughtsbut no longer injects athinkingLevelvalue.Adds
litellm.enable_gemini_default_thinking_level_low(defaultFalse) to optionally restore the prior behavior of forcingthinkingLevel(minimalforgemini-3-flash*, otherwiselow). Tests are updated/split to cover both default and feature-flagged behavior, including the fullmap_openai_paramsflow.Reviewed by Cursor Bugbot for commit 8d9db7b. Bugbot is set up for automated code reviews on this repo. Configure here.