From ff97ae3e8e478c45b2bcbf0f86d0869dc7613af3 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Wed, 13 May 2026 04:32:42 -0400 Subject: [PATCH] fix: enhance tool async check in ConversationalAgentExecutor - Added a check for `None` tools in the `_tool_has_arun` method to prevent errors during tool validation. - Improved the logic to exclude tools from the `crewai.tools.base_tool` module when determining if they have a real async `_arun` method, ensuring more accurate tool handling. These changes aim to improve the robustness of tool validation within the CrewAI framework. --- lib/crewai/src/crewai/new_agent/executor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/crewai/src/crewai/new_agent/executor.py b/lib/crewai/src/crewai/new_agent/executor.py index d9aaa6565..e4da7a4e2 100644 --- a/lib/crewai/src/crewai/new_agent/executor.py +++ b/lib/crewai/src/crewai/new_agent/executor.py @@ -2088,14 +2088,17 @@ class ConversationalAgentExecutor(BaseModel): @staticmethod def _tool_has_arun(tool: Any) -> bool: """Check if a tool has a real async _arun (not the default NotImplementedError stub).""" + if tool is None: + return False arun = getattr(tool, "_arun", None) if arun is None: return False - # BaseTool's default _arun raises NotImplementedError — skip it for cls in type(tool).__mro__: if "_arun" in cls.__dict__: - return cls.__name__ != "BaseTool" and cls.__name__ != "StructuredTool" - + mod = getattr(cls, "__module__", "") or "" + if "crewai.tools.base_tool" in mod: + return False + return True return False def _parse_tool_call(self, tool_call: Any) -> tuple[str | None, Any, str | None]: