fix: clarify Gemini thinkingConfig support guard to prevent 400 errors

This commit is contained in:
Roo Code 2025-12-24 20:29:13 +00:00
parent 1e71015e54
commit e13dfb030c

View file

@ -131,6 +131,11 @@ export const getGeminiReasoning = ({
reasoningEffort,
settings,
}: GetModelReasoningOptions): GeminiReasoningParams | undefined => {
// Only send thinkingConfig to models that advertise support for it; Gemini 3 rejects
// the field and returns 400 otherwise.
const supportsThinkingConfig =
typeof model.maxThinkingTokens === "number" || model.supportsReasoningBudget || model.supportsReasoningEffort
// Budget-based (2.5) models: use thinkingBudget, not thinkingLevel.
if (shouldUseReasoningBudget({ model, settings })) {
return { thinkingBudget: reasoningBudget!, includeThoughts: true }
@ -150,6 +155,11 @@ export const getGeminiReasoning = ({
return undefined
}
// Skip thinking config for models that don't advertise support (e.g., Gemini 3).
if (!supportsThinkingConfig) {
return undefined
}
// Effort-based models on Google GenAI support minimal/low/medium/high levels.
if (!isGeminiThinkingLevel(selectedEffort)) {
return undefined