Skip to content

Commit 2e41089

Browse files
committed
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
1 parent 4e8b174 commit 2e41089

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/core/task/Task.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,18 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
13461346
// the user hits max requests and denies resetting the count.
13471347
break
13481348
} else {
1349-
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }]
1350-
this.consecutiveMistakeCount++
1349+
// In Ask mode, we allow responses without tool usage since it's designed
1350+
// to provide direct answers, especially when using features like Google Gemini's grounding
1351+
const currentMode = await this.getTaskMode()
1352+
const isAskMode = currentMode === "ask"
1353+
1354+
if (!isAskMode) {
1355+
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }]
1356+
this.consecutiveMistakeCount++
1357+
} else {
1358+
// For Ask mode, end the loop gracefully without error
1359+
break
1360+
}
13511361
}
13521362
}
13531363
}
@@ -1781,7 +1791,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
17811791
// either use a tool or attempt_completion.
17821792
const didToolUse = this.assistantMessageContent.some((block) => block.type === "tool_use")
17831793

1784-
if (!didToolUse) {
1794+
// In Ask mode, we allow responses without tool usage since it's designed
1795+
// to provide direct answers, especially when using features like Google Gemini's grounding
1796+
const currentMode = await this.getTaskMode()
1797+
const isAskMode = currentMode === "ask"
1798+
1799+
if (!didToolUse && !isAskMode) {
17851800
this.userMessageContent.push({ type: "text", text: formatResponse.noToolsUsed() })
17861801
this.consecutiveMistakeCount++
17871802
}

0 commit comments

Comments
 (0)