-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: handle Ask mode responses without tool usage for Google Gemini grounding #6674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rounding - 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
| } else { | ||
| nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }] | ||
| this.consecutiveMistakeCount++ | ||
| // In Ask mode, we allow responses without tool usage since it's designed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good fix: the code now checks task mode before pushing the no-tools-used error. In Ask mode, the loop breaks gracefully. Consider abstracting the check (e.g. a helper function isAskMode()) to reduce duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this code 5 minutes ago and already forgot why. Classic me.
| // 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage for this new behavior. This is a critical change that prevents infinite loops in Ask mode - we should have tests to ensure it works correctly and prevent regressions.
Consider adding tests that verify:
- Ask mode allows responses without tool usage
- Other modes still trigger the noToolsUsed() error
- The consecutiveMistakeCount is not incremented in Ask mode
| // 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is duplicated from lines ~1349-1360. Consider extracting into a helper method to follow DRY principles:
| const isAskMode = currentMode === "ask" | |
| private async shouldAllowResponseWithoutToolUsage(): Promise<boolean> { | |
| const currentMode = await this.getTaskMode() | |
| return currentMode === "ask" | |
| } |
Then both locations could use:
if (!await this.shouldAllowResponseWithoutToolUsage()) {
// Handle the error case
}| // 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we considered if other modes might benefit from allowing responses without tool usage? The Orchestrator mode, for example, has an empty groups array and might face similar issues with certain LLM providers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea, maybe not check explicit for Ask mode but maybe have a setting for Models with Grounding Mode?
|
Closing, see #6671 (comment) |
Summary
This PR fixes an infinite loop issue that occurs when using Google Gemini with grounding/search enabled in Ask mode.
Problem
When using Google Gemini with URL context and grounding/search enabled in Ask mode, the system expects a tool use but the model provides direct answers. This causes Roo Code to repeatedly send the
noToolsUsed()error, creating an infinite loop that eventually errors out with "This may indicate a failure in the model's thought process or inability to use a tool properly".Solution
The fix adds logic to detect when the task is in Ask mode and skips the tool validation for responses without tool usage. This is appropriate because Ask mode is specifically designed to provide direct answers without requiring tool usage.
Changes
Task.tsto check if the current mode is "ask" before triggering thenoToolsUsed()errorrecursivelyMakeClineRequestsmethod (line ~1789)initiateTaskLoopmethod (line ~1349)Testing
Fixes #6671
Important
Fixes infinite loop in Ask mode with Google Gemini by skipping tool validation for direct answers in
Task.ts.recursivelyMakeClineRequestsandinitiateTaskLoopmethods inTask.ts.This description was created by
for 2e41089. You can customize this summary. It will automatically update as commits are pushed.