From 040e5a78d21b6e632349b7d9eb8c9530ce1458af Mon Sep 17 00:00:00 2001 From: Brandon Hancock Date: Mon, 15 Jul 2024 09:21:21 -0400 Subject: [PATCH] Add back in Gui's tool_usage fix --- src/crewai/agent.py | 1 - src/crewai/tools/tool_usage.py | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/crewai/agent.py b/src/crewai/agent.py index bfe980813..92f24e3db 100644 --- a/src/crewai/agent.py +++ b/src/crewai/agent.py @@ -181,7 +181,6 @@ class Agent(BaseAgent): self.agent_executor.tools = parsed_tools self.agent_executor.task = task - # TODO: COMPARE WITH ARGS AND WITHOUT ARGS self.agent_executor.tools_description = self._render_text_description_and_args( parsed_tools ) diff --git a/src/crewai/tools/tool_usage.py b/src/crewai/tools/tool_usage.py index 213ecd2f8..6b507863a 100644 --- a/src/crewai/tools/tool_usage.py +++ b/src/crewai/tools/tool_usage.py @@ -151,16 +151,12 @@ class ToolUsage: for k, v in calling.arguments.items() if k in acceptable_args } - result = tool._run(**arguments) + result = tool.invoke(input=arguments) except Exception: - if tool.args_schema: - arguments = calling.arguments - result = tool._run(**arguments) - else: - arguments = calling.arguments.values() # type: ignore # Incompatible types in assignment (expression has type "dict_values[str, Any]", variable has type "dict[str, Any]") - result = tool._run(*arguments) + arguments = calling.arguments + result = tool.invoke(input=arguments) else: - result = tool._run() + result = tool.invoke(input={}) except Exception as e: self._run_attempts += 1 if self._run_attempts > self._max_parsing_attempts: