Repository navigation
fix(gemini): map minimal thinking to low for Gemini 3.7 and 3.8 Flash - #41201
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryGemini 3.7 and 3.8 Flash now use
Confidence Score: 5/5The PR appears safe to merge. No blocking issue remains. The metadata covers the bare, Gemini, and Vertex names for both affected models. The new bridge test checks the full disabled-thinking request path. Both earlier review threads are resolved. Important Files Changed
Reviews (2): Last reviewed commit: "fix(gemini): read the minimal thinking f..." | Re-trigger Greptile |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Live Vertex e2e done: main returns 400 THINKING_LEVEL_MINIMAL from Claude Code and curl with thinking disabled, this tip returns 200. Full output on LIT-7775 |
…ver the /v1/messages bridge
|
|
|
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 a1ad95d. Configure here.
TLDR
Problem this solves:
thinkingLevel: minimalwith a 400minimalforreasoning_effortminimal, none and disable on them/v1/messages,thinking: {type: disabled}hit the same path and failedHow it solves it:
thinkingLevel: lowsupports_minimal_reasoning_effort: falseon those entriesminimalenable_gemini_default_thinking_level_lowpath uses the same ruleis_explicitly_disabled_factoryinlitellm.utilsgoes public, as its provider-config readers already implied/v1/messageswith thinking disabled through the Gemini bridgeUser Flow
Before: a developer who aliases a Claude model name to
vertex_ai/gemini-3.8-flashgets a 400 whenever their client turns thinking off"model": "claude-sonnet-5"and"thinking": {"type": "disabled"}Vertex_aiException BadRequestErrorwith"Thinking level is unsupported: THINKING_LEVEL_MINIMAL"MAX_THINKING_TOKENS=0), every prompt ends inAPI Error: 500 ... THINKING_LEVEL_MINIMALafter ten retries"model": "vertex_ai/gemini-3.8-flash"and"reasoning_effort": "minimal","none"or"disable"After: the same requests succeed
"model": "claude-sonnet-5"and"thinking": {"type": "disabled"}"reasoning_effort": "minimal","none"or"disable"onvertex_ai/gemini-3.8-flashalso returns 200Relevant issues
Fixes #37314
Overlaps with community PRs #36874 and #37478, which target a non-default branch and cover a subset of the paths
Affected release
Linear ticket
Resolves LIT-7775
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Setup shared by both legs. Config
lit7775-qa-config.yamlhas five deployments, allvertex_location: global(the only location serving 3.8 Flash):claude-sonnet-5andclaude-haiku-4-5are aliases ofvertex_ai/gemini-3.8-flash, andvertex_ai/gemini-3.8-flash,vertex_ai/gemini-3.7-flashand the controlvertex_ai/gemini-3.6-flashare listed under their own names, withmaster_key: sk-lit7775-qa,drop_params: falseand no database. Each leg is one proxy with two workers,python litellm/proxy/proxy_cli.py --config lit7775-qa-config.yaml --port <port> --num_workers 2 --detailed_debug: Before from the merge base 7e3ca14 on port 53382, After from a1ad95d on port 56949. Claude Code v2.1.273 runs interactively in tmux asANTHROPIC_BASE_URL=http://127.0.0.1:<port> ANTHROPIC_AUTH_TOKEN=sk-lit7775-qa ANTHROPIC_MODEL=claude-sonnet-5 ANTHROPIC_SMALL_FAST_MODEL=claude-haiku-4-5 MAX_THINKING_TOKENS=0 claudeand gets the promptReply with just the single word ok. The curl cases useH='Authorization: Bearer sk-lit7775-qa'and the messageReply with the single word okBefore (7e3ca14)
Claude Code with thinking off
Retrying in Ns · attempt N/10for 3m 45s and ends onAPI Error: 500 litellm.APIError: litellm.BadRequestError: Vertex_ai_betaException BadRequestError - b'{ "error": { "code": 400, "message": "Thinking level is unsupported: THINKING_LEVEL_MINIMAL", "status": "INVALID_ARGUMENT" } }'/v1/messages thinking disabled
curl -s -w "HTTP %{http_code}\n" http://127.0.0.1:53382/v1/messages -H "$H" -H 'content-type: application/json' -d '{"model":"claude-sonnet-5","max_tokens":64,"thinking":{"type":"disabled"},"messages":[{"role":"user","content":"Reply with the single word ok"}]}'HTTP 400with body{"type": "invalid_request_error", "message": "litellm.BadRequestError: Vertex_aiException BadRequestError - {\"error\": {\"code\": 400, \"message\": \"Thinking level is unsupported: THINKING_LEVEL_MINIMAL\", \"status\": \"INVALID_ARGUMENT\"}}. Received Model Group=claude-sonnet-5 ..."}/v1/messages thinking disabled, streamed
"stream": true, read withcurl -s -N{"error":{"message":"litellm.APIError: litellm.BadRequestError: Vertex_ai_betaException BadRequestError - b'{ \"error\": { \"code\": 400, \"message\": \"Thinking level is unsupported: THINKING_LEVEL_MINIMAL\", \"status\": \"INVALID_ARGUMENT\" } }'","type":"internal_server_error","param":null,"code":"500"}}/v1/chat/completions reasoning_effort minimal, none, disable
for m in vertex_ai/gemini-3.8-flash vertex_ai/gemini-3.7-flash; do for e in minimal none disable; do curl -s -w "HTTP %{http_code}\n" http://127.0.0.1:53382/v1/chat/completions -H "$H" -H 'content-type: application/json' -d "{\"model\":\"$m\",\"max_tokens\":64,\"reasoning_effort\":\"$e\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with the single word ok\"}]}"; done; doneHTTP 400with{"message": "litellm.BadRequestError: Vertex_aiException BadRequestError - {\"error\": {\"code\": 400, \"message\": \"Thinking level is unsupported: THINKING_LEVEL_MINIMAL\", \"status\": \"INVALID_ARGUMENT\"}}. Received Model Group=<model> ..."}Controls
/v1/messagesonclaude-sonnet-5with"thinking":{"type":"enabled","budget_tokens":1024}and"max_tokens":2048:HTTP 200, content block types["text"]/v1/messagesonvertex_ai/gemini-3.6-flashwith"thinking":{"type":"disabled"}:HTTP 200, content[{"type": "text", "text": "ok"}]After (a1ad95d)
Claude Code with thinking off
⏺ okafterBaked for 4s/v1/messages thinking disabled
HTTP 200, content[{"type": "text", "text": "ok"}]/v1/messages thinking disabled, streamed
event: message_startwith"model":"claude-sonnet-5", thenevent: content_block_startfor a text block, thenevent: content_block_deltawith{"type": "text_delta", "text": "ok"}/v1/chat/completions reasoning_effort minimal, none, disable
HTTP 200. The threevertex_ai/gemini-3.8-flashcalls andvertex_ai/gemini-3.7-flashwithminimalanswer"ok";vertex_ai/gemini-3.7-flashwithnoneanddisablecame back with emptychoicesand"completion_tokens_details": {"reasoning_tokens": 61, "text_tokens": 0}, since levellowstill thinks and the 64-token budget ran out before the answer"max_tokens":256:HTTP 200, content"ok",reasoning_tokens91 and 100noneanddisablerequest leaving withthinkingConfig: {'thinkingLevel': 'low', 'includeThoughts': False}, andminimalonly on thegemini-3.6-flashcontrolControls
/v1/messagesonclaude-sonnet-5with thinking enabled:HTTP 200, content block types["text"]/v1/messagesonvertex_ai/gemini-3.6-flashwith thinking disabled:HTTP 200, content[{"type": "text", "text": "ok"}], and the chat form withnonereports"completion_tokens_details": {"text_tokens": 1}with no reasoning tokensObservations from the run:
allowed_function_names; pre-existing, untouched/v1/messagesBefore error arrived as a 500-shaped bodyType
🐛 Bug Fix
Caveats (if any)
Low
supports_minimal_reasoning_effort: falsestill getsminimalgemini-3.8-flash-previewand other unlisted names stay in that bucket until their entries carry the flaglowis the lowest level 3.7 and 3.8 Flash accept, so a disabled or minimal request still spends reasoning tokens there (57 to 100 on the one-word prompt above, none on 3.6 Flash atminimal), and amax_tokensthat small can come back with emptychoices. Same mapping Gemini 3 Pro already had; leavingthinkingConfigout would hand the model its own, higher, default level/model_group/infonow advertisessupported_reasoning_efforts["none", "low", "medium", "high"]for the 3.7 and 3.8 Flash groups instead of the six-level default, so the dashboard's complexity router tiers stop offeringminimalandxhighon themMINIMALuntil the map reloads or the proxy restarts; the bundled map ships the flagllm_translation_testing,local_testing_part1,local_testing_part2andlitellm_router_testingare red at the tip on Together AImodel_not_available(openai/gpt-oss-20bis no longer serverless), two Azure fallback assertions and one proxy-provider embedding capture that passes locally at both the tip and the merge base; the same four jobs are red on main pipeline #89670 andtests/llm_translation/test_gemini.pypasses in the same jobminimal,disableandnonetominimal; docs follow-upFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/cfec9b931a8d4e9fb8b2ab6a7140f9f3
Open in Devin Desktop: https://app.devin.ai/desktop/session/cfec9b931a8d4e9fb8b2ab6a7140f9f3?variant=devin