fix: disable reasoning for Gemini/Vertex during context condensing

- Prevents API errors when using Gemini Flash with reasoning enabled
- Reasoning blocks interfere with condensing prompt structure
- Fixes issue #9867
This commit is contained in:
Roo Code 2025-12-08 13:12:13 +00:00
parent 1f7e1ee630
commit 927f0e52b6

View file

@ -1314,7 +1314,17 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
})
// Ensure profile and apiProvider exist before trying to build handler
if (profile && profile.apiProvider) {
condensingApiHandler = buildApiHandler(profile)
// For Gemini providers, disable reasoning features during condensing to prevent API errors
// Reasoning blocks can interfere with the condensing prompt structure
if (profile.apiProvider === "gemini" || profile.apiProvider === "vertex") {
condensingApiHandler = buildApiHandler({
...profile,
enableReasoningEffort: false,
modelMaxThinkingTokens: undefined,
})
} else {
condensingApiHandler = buildApiHandler(profile)
}
}
}
}
@ -3460,7 +3470,17 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// Ensure profile and apiProvider exist before trying to build handler.
if (profile && profile.apiProvider) {
condensingApiHandler = buildApiHandler(profile)
// For Gemini providers, disable reasoning features during condensing to prevent API errors
// Reasoning blocks can interfere with the condensing prompt structure
if (profile.apiProvider === "gemini" || profile.apiProvider === "vertex") {
condensingApiHandler = buildApiHandler({
...profile,
enableReasoningEffort: false,
modelMaxThinkingTokens: undefined,
})
} else {
condensingApiHandler = buildApiHandler(profile)
}
}
}
}