Fix issue #2434: Allow tools to specify if they permit repeated usage

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-03-21 12:35:52 +00:00
parent 03f1d57463
commit 245399bca0
5 changed files with 190 additions and 0 deletions

View File

@@ -279,6 +279,10 @@ class ToolUsage:
if not self.tools_handler:
return False # type: ignore # No return value expected
if last_tool_usage := self.tools_handler.last_used_tool:
tool = self._select_tool(calling.tool_name)
# If the tool allows repeated usage, don't check arguments
if getattr(tool, "allow_repeated_usage", False):
return False # type: ignore # No return value expected
return (calling.tool_name == last_tool_usage.tool_name) and ( # type: ignore # No return value expected
calling.arguments == last_tool_usage.arguments
)