fix: bulk_tool call errors#1564
Merged
tusharmath merged 4 commits intoSep 16, 2025
Merged
Conversation
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) | ||
| }) |
Contributor
There was a problem hiding this comment.
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
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.