fix: convert thinkingLevel to thinkingBudget for v1internal compatibility#2095
Open
thebtf wants to merge 1 commit intolbjlaq:mainfrom
Open
fix: convert thinkingLevel to thinkingBudget for v1internal compatibility#2095thebtf wants to merge 1 commit intolbjlaq:mainfrom
thebtf wants to merge 1 commit intolbjlaq:mainfrom
Conversation
…lity Clients like OpenClaw and Cline send v1beta-style thinkingLevel (string: "NONE"/"LOW"/"MEDIUM"/"HIGH") in generationConfig.thinkingConfig. When AGM proxies through v1internal, Google rejects thinkingLevel with 400 INVALID_ARGUMENT because v1internal only accepts thinkingBudget (numeric). This fix converts thinkingLevel to the corresponding thinkingBudget value before any budget processing, then removes the thinkingLevel field. The conversion runs early in wrap_request so downstream budget capping and maxOutputTokens logic sees the correct numeric budget. Mapping: NONE=0, LOW=4096, MEDIUM=8192, HIGH=24576.
lbjlaq
added a commit
that referenced
this pull request
Feb 25, 2026
…lity Manually merged PR #2095 from thebtf:fix/thinking-level-conversion. Problem: Clients like OpenClaw and Cline send v1beta-style thinkingLevel (string: "NONE", "LOW", "MEDIUM", "HIGH") in generationConfig.thinkingConfig. When AGM proxies through Google's v1internal API, Google rejects thinkingLevel with 400 INVALID_ARGUMENT because v1internal only accepts numeric thinkingBudget. Fix: Insert a conversion step in wrap_request() before existing budget processing: - NONE → 0 - LOW → 4096 - MEDIUM → 8192 - HIGH → 24576 Tested with OpenClaw sending thinkingLevel: "LOW" to gemini-3.1-pro-high via Gemini native protocol — requests now succeed (200 OK) instead of 400.
lbjlaq
added a commit
that referenced
this pull request
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Clients like OpenClaw and Cline send v1beta-style
thinkingLevel(string:"NONE","LOW","MEDIUM","HIGH") ingenerationConfig.thinkingConfig. When AGM proxies the request through Google's v1internal API, Google rejectsthinkingLevelwith 400 INVALID_ARGUMENT because v1internal only accepts numericthinkingBudget.The existing
is_adaptivecheck (line ~215) detectsthinkingLevelpresence to setmaxOutputTokens, but thethinkingLevelfield itself is never removed or converted — it passes through to Google and causes the 400 error.Fix
Insert a conversion step in
wrap_request()before the existing budget processing logic:thinkingConfig.thinkingLevelexists (string)thinkingBudget:NONE→ 0LOW→ 4096MEDIUM→ 8192HIGH→ 24576thinkingLevel, insertthinkingBudgetThis runs early so all downstream logic (budget capping,
maxOutputTokensadjustment, adaptive detection) sees the correct numeric budget.Testing
Tested with OpenClaw sending
thinkingLevel: "LOW"togemini-3.1-pro-highvia Gemini native protocol — requests now succeed (200 OK) instead of returning 400.Files Changed
src-tauri/src/proxy/mappers/gemini/wrapper.rs— 23 lines added (conversion block only)