-
Notifications
You must be signed in to change notification settings - Fork 6.5k
[BUG] Tool repeated execution #3489
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
In crewai.tools.structured_tool, when the invoke function calls the tool, the code is as follows:
` def invoke(
self, input: Union[str, dict], config: Optional[dict] = None, **kwargs: Any
) -> Any:
"""Main method for tool execution."""
parsed_args = self._parse_args(input)
if self.has_reached_max_usage_count():
raise ToolUsageLimitExceeded(
f"Tool '{self.name}' has reached its maximum usage limit of {self.max_usage_count}. You should not use the {self.name} tool again."
)
self._increment_usage_count()
if inspect.iscoroutinefunction(self.func):
result = asyncio.run(self.func(**parsed_args, **kwargs))
return result
try:
result = self.func(**parsed_args, **kwargs)
except Exception:
raise
result = self.func(**parsed_args, **kwargs)
if asyncio.iscoroutine(result):
return asyncio.run(result)
return result`
In fact, self.func(**parsed_args, **kwargs) runs the tool twice, is this a bug?
Steps to Reproduce
N
Expected behavior
N
Screenshots/Code snippets
N
Operating System
Ubuntu 20.04
Python Version
3.10
crewAI Version
0.177.0
crewAI Tools Version
N
Virtual Environment
Conda
Evidence
N
Possible Solution
N
Additional context
N
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working