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
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
Plugin Type
VSCode Extension
Cline Version
3.38.0
What happened?
Problem Description
When using Gemini models through the
GeminiHandler, thethinkingBudgetparameter in the API request defaults to0. This is because the_thinkingBudgetvariable insrc/core/api/providers/gemini.tsis initialized withthis.options.thinkingBudgetTokens ?? 0.This default value of
0causes 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 athinkingBudgetbetween128and32768, or-1for dynamic allocation. Sending0to this model is incorrect.For other models like Gemini 2.5 Flash Lite, the default behavior is no thinking, so
0is acceptable. However, having a single static default for all models is problematic.Suggested Solution
The default value for
thinkingBudgetshould 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
thinkingBudgetaccordingly:This change ensures that:
-1), which is their recommended behavior.0, preserving their standard behavior.thinkingBudgetTokens.References
thinkingBudgetcan be found here: https://ai.google.dev/gemini-api/docs/thinking#supported-modelsSteps to reproduce
and chat
Provider/Model
gemini-2.5-pro
System Information
OS: mac m1
ram: 16gb