Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: bulk_tool call errors#1564

Merged
tusharmath merged 4 commits into
tool-call-failure-countfrom
tool-call-failure-count-integration
Sep 16, 2025
Merged

fix: bulk_tool call errors#1564
tusharmath merged 4 commits into
tool-call-failure-countfrom
tool-call-failure-count-integration

Conversation

@amitksingh1490

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread crates/forge_app/src/orch.rs Outdated
Comment on lines 640 to 651
fn check_tool_call_failures(&self, tool_calls: &[ToolCallFull]) -> bool {
let agent = &self.agent;
agent.max_tool_failure_per_turn.is_some_and(|limit| {
tool_calls
if agent.max_tool_failure_per_turn.is_none() {
return false;
}

let maxed_out_tools = self.tool_error_tracker.maxed_out_tools();
tool_calls.iter().any(|call| {
maxed_out_tools
.iter()
.map(|call| tool_failure_attempts.get(&call.name).unwrap_or(&0))
.any(|count| *count >= limit)
.any(|tool_name| **tool_name == call.name)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactored implementation changes the behavior of tool call failure checking. The original code checked if any tool would exceed its failure limit after the current execution, while the new code only checks if any tool has already reached its maximum failure count. This could allow tool calls to proceed even when they would exceed the limit after execution, potentially bypassing the intended safety mechanism. Consider preserving the original behavior by checking both current and potential future failure states.

Suggested change
fn check_tool_call_failures(&self, tool_calls: &[ToolCallFull]) -> bool {
let agent = &self.agent;
agent.max_tool_failure_per_turn.is_some_and(|limit| {
tool_calls
if agent.max_tool_failure_per_turn.is_none() {
return false;
}
let maxed_out_tools = self.tool_error_tracker.maxed_out_tools();
tool_calls.iter().any(|call| {
maxed_out_tools
.iter()
.map(|call| tool_failure_attempts.get(&call.name).unwrap_or(&0))
.any(|count| *count >= limit)
.any(|tool_name| **tool_name == call.name)
})
fn check_tool_call_failures(&self, tool_calls: &[ToolCallFull]) -> bool {
let agent = &self.agent;
if agent.max_tool_failure_per_turn.is_none() {
return false;
}
let maxed_out_tools = self.tool_error_tracker.maxed_out_tools();
let would_exceed_tools = self.tool_error_tracker.would_exceed_tools(tool_calls);
tool_calls.iter().any(|call| {
maxed_out_tools
.iter()
.any(|tool_name| **tool_name == call.name)
|| would_exceed_tools
.iter()
.any(|tool_name| **tool_name == call.name)
})
}

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@tusharmath tusharmath merged commit f3721db into tool-call-failure-count Sep 16, 2025
2 checks passed
@tusharmath tusharmath deleted the tool-call-failure-count-integration branch September 16, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants