-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(desktop): add Gemini 2.5 thinking budget controls to reduce API costs #7159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4eb86af
Add thinking budget controls to GeminiClient for Gemini 2.5 cost redu…
beastoin 3f8e7ec
Add defense-in-depth thinking budget injection to Gemini proxy
beastoin fb1fa78
Add changelog entry for thinking budget cost reduction
beastoin 53688e7
Remove unused GeminiClient methods and add explicit thinkingBudget=0 …
beastoin 576e1e6
Update proxy thinking budget comment to reflect client-side budget=0
beastoin 47789b8
Use model-aware thinking budget minimum (Pro requires 128, Flash allo…
beastoin 6554f85
Inject thinking budget when generation_config is absent entirely
beastoin fd46118
Add edge case tests for proxy thinking budget injection
beastoin c416c65
Allow thinkingBudget override in sendImageToolLoop for tool-calling f…
beastoin 48f387e
Set thinkingBudget=1024 for TaskAssistant tool-calling loop
beastoin e0fb37c
Set thinkingBudget=1024 for InsightAssistant multi-turn SQL and analysis
beastoin 8f4894f
Add Swift tests for ThinkingConfig budget logic and request encoding
beastoin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generation_configis absentThe injection only fires when the request already contains a
generation_config/generationConfigobject. A request that omits the key entirely (valid Gemini API behavior — model uses defaults) skips this block, leaving thinking unlimited. The PR comment says "inject default budget=1024 when client omits thinkingConfig" but the actual contract is narrower: the budget is injected only when ageneration_configexists without athinkingConfig. Any future client call that forgets to setgenerationConfigbypasses the proxy's cost cap entirely, defeating the stated defense-in-depth goal.The fix is to add a fallback after the loop: if neither
generation_confignorgenerationConfigexists in the object, insert a newgeneration_configcontaining only the defaultthinkingConfig.