fix: update type annotations in agent.py for CrewStructuredTool compatibility

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-04-27 20:21:40 +00:00
parent aa1d04af41
commit 1133994ec7

View File

@@ -17,6 +17,7 @@ from crewai.security import Fingerprint
from crewai.task import Task from crewai.task import Task
from crewai.tools import BaseTool from crewai.tools import BaseTool
from crewai.tools.agent_tools.agent_tools import AgentTools from crewai.tools.agent_tools.agent_tools import AgentTools
from crewai.tools.structured_tool import CrewStructuredTool
from crewai.utilities import Converter, Prompts from crewai.utilities import Converter, Prompts
from crewai.utilities.agent_utils import ( from crewai.utilities.agent_utils import (
get_tool_names, get_tool_names,
@@ -185,7 +186,7 @@ class Agent(BaseAgent):
self, self,
task: Task, task: Task,
context: Optional[str] = None, context: Optional[str] = None,
tools: Optional[List[BaseTool]] = None tools: Optional[List[Union[BaseTool, CrewStructuredTool]]] = None
) -> str: ) -> str:
"""Execute a task with the agent. """Execute a task with the agent.
@@ -406,14 +407,14 @@ class Agent(BaseAgent):
)["output"] )["output"]
def create_agent_executor( def create_agent_executor(
self, tools: Optional[List[BaseTool]] = None, task=None self, tools: Optional[List[Union[BaseTool, CrewStructuredTool]]] = None, task=None
) -> None: ) -> None:
"""Create an agent executor for the agent. """Create an agent executor for the agent.
Returns: Returns:
An instance of the CrewAgentExecutor class. An instance of the CrewAgentExecutor class.
""" """
raw_tools: List[BaseTool] = tools or self.tools or [] raw_tools: List[Union[BaseTool, CrewStructuredTool]] = tools or self.tools or []
parsed_tools = parse_tools(raw_tools) parsed_tools = parse_tools(raw_tools)
prompt = Prompts( prompt = Prompts(