Gemini `thinkingBudget` defaults to 0, which is incompatible with some models like Gemini 2.5 Pro
Plugin Type
VSCode Extension
Cline Version
3.38.0
What happened?
Problem Description
When using Gemini models through the GeminiHandler, the thinkingBudget parameter in the API request defaults to 0. This is because the _thinkingBudget variable in src/core/api/providers/gemini.ts is initialized with this.options.thinkingBudgetTokens ?? 0.
// file: src/core/api/providers/gemini.ts
// ...
// Configure thinking budget if supported
const _thinkingBudget = this.options.thinkingBudgetTokens ?? 0;
// ...
This default value of 0 causes issues because it's not a valid setting for all models. For example, according to the official documentation, Gemini 2.5 Pro does not support disabling thinking and requires a thinkingBudget between 128 and 32768, or -1 for dynamic allocation. Sending 0 to this model is incorrect.
For other models like Gemini 2.5 Flash Lite, the default behavior is no thinking, so 0 is acceptable. However, having a single static default for all models is problematic.
Suggested Solution
The default value for thinkingBudget should be set dynamically based on the selected model to ensure compatibility and leverage the best default behavior for each.
A more robust implementation would be to check the model ID and set the default thinkingBudget accordingly:
// file: src/core/api/providers/gemini.ts (Proposed Change)
let _thinkingBudget: number;
if (options.thinkingBudgetTokens !== undefined) {
_thinkingBudget = options.thinkingBudgetTokens;
} else {
// Default behavior based on model, see https://ai.google.dev/gemini-api/docs/thinking#supported-models
switch (modelId) {
case GeminiModelId.GEMINI_2_5_PRO:
case GeminiModelId.GEMINI_2_5_FLASH:
_thinkingBudget = -1; // Default to dynamic thinking
break;
default:
_thinkingBudget = 0; // Default to off for other models like Flash Lite
break;
}
}
This change ensures that:
-
Gemini 2.5 Pro and Flash default to dynamic thinking (
-1), which is their recommended behavior. - Other models, like Flash Lite, default to
0, preserving their standard behavior. - Users can still explicitly override this by setting
thinkingBudgetTokens.
References
-
Google AI for Developers - Supported Models & Thinking Budget: Details on model-specific constraints for
thinkingBudgetcan be found here: https://ai.google.dev/gemini-api/docs/thinking#supported-models
Steps to reproduce
- on extention settings
- set API provider and apikey and model (gemini-2.5-pro)
- uncheck enable thinking
- click done
and chat
Provider/Model
gemini-2.5-pro
System Information
OS: mac m1 ram: 16gb
Hey Thank you for the report. I use Gemini A lot So I will follow up and make sure we address these issues as soon as possible.
im having an issue right now cline using Gemini 2.5 pro. The "enable thinking" box is unchecked (ive tried checking and unchecking) but every prompt using 2.5 pro fails saying model doesnt support thinking.... I dont want to use gemini 3.0 as its overloaded a lot