fix: handle Ask mode responses without tool usage for Google Gemini grounding

- Skip tool validation in Ask mode to allow direct answers
- Prevents infinite loop when using Google Gemini with grounding/search
- Ask mode is designed to provide answers without requiring tool usage

Fixes #6671
This commit is contained in:
Roo Code 2025-08-04 17:43:28 +00:00
parent 4e8b17486b
commit 2e410899ab

View file

@ -1346,8 +1346,18 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// the user hits max requests and denies resetting the count.
break
} else {
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }]
this.consecutiveMistakeCount++
// In Ask mode, we allow responses without tool usage since it's designed
// to provide direct answers, especially when using features like Google Gemini's grounding
const currentMode = await this.getTaskMode()
const isAskMode = currentMode === "ask"
if (!isAskMode) {
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }]
this.consecutiveMistakeCount++
} else {
// For Ask mode, end the loop gracefully without error
break
}
}
}
}
@ -1781,7 +1791,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// either use a tool or attempt_completion.
const didToolUse = this.assistantMessageContent.some((block) => block.type === "tool_use")
if (!didToolUse) {
// In Ask mode, we allow responses without tool usage since it's designed
// to provide direct answers, especially when using features like Google Gemini's grounding
const currentMode = await this.getTaskMode()
const isAskMode = currentMode === "ask"
if (!didToolUse && !isAskMode) {
this.userMessageContent.push({ type: "text", text: formatResponse.noToolsUsed() })
this.consecutiveMistakeCount++
}