mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-02 07:42:40 +00:00
Fix custom tool registration in CrewAI 0.150.0
- Update validate_tools method in BaseAgent to accept all documented tool patterns: * Function tools (with or without @tool decorator) * Dict-based tool definitions * BaseTool class inheritance * Direct function assignment - Change tools field type annotation from List[BaseTool] to List[Any] to allow Pydantic validation - Update parse_tools function to accept all BaseTool instances (not just CrewAITool) - Add comprehensive tests covering all custom tool patterns from issue #3226 - Add reproduction script to verify all patterns work correctly Fixes #3226 Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -30,10 +30,13 @@ def parse_tools(tools: List[BaseTool]) -> List[CrewStructuredTool]:
|
||||
tools_list = []
|
||||
|
||||
for tool in tools:
|
||||
if isinstance(tool, CrewAITool):
|
||||
if isinstance(tool, BaseTool):
|
||||
tools_list.append(tool.to_structured_tool())
|
||||
else:
|
||||
raise ValueError("Tool is not a CrewStructuredTool or BaseTool")
|
||||
raise ValueError(
|
||||
f"Tool must be a BaseTool instance, got {type(tool)}. "
|
||||
"Ensure tools are properly validated before calling parse_tools."
|
||||
)
|
||||
|
||||
return tools_list
|
||||
|
||||
|
||||
Reference in New Issue
Block a user