diff --git a/lib/crewai/src/crewai/agent/core.py b/lib/crewai/src/crewai/agent/core.py index d1e034557..24ae171e1 100644 --- a/lib/crewai/src/crewai/agent/core.py +++ b/lib/crewai/src/crewai/agent/core.py @@ -1091,7 +1091,9 @@ class Agent(BaseAgent): ) ) - def get_delegation_tools(self, agents: Sequence[BaseAgent], task: Task | None = None) -> list[BaseTool]: + def get_delegation_tools( + self, agents: Sequence[BaseAgent], task: Task | None = None + ) -> list[BaseTool]: agent_tools = AgentTools(agents=agents, task=task) return agent_tools.tools() diff --git a/lib/crewai/src/crewai/agents/agent_adapters/langgraph/langgraph_adapter.py b/lib/crewai/src/crewai/agents/agent_adapters/langgraph/langgraph_adapter.py index cda19674c..46dcbbfcb 100644 --- a/lib/crewai/src/crewai/agents/agent_adapters/langgraph/langgraph_adapter.py +++ b/lib/crewai/src/crewai/agents/agent_adapters/langgraph/langgraph_adapter.py @@ -274,7 +274,9 @@ class LangGraphAgentAdapter(BaseAgentAdapter): available_tools: list[Any] = self._tool_adapter.tools() self._graph.tools = available_tools - def get_delegation_tools(self, agents: Sequence[BaseAgent], task: Any | None = None) -> list[BaseTool]: + def get_delegation_tools( + self, agents: Sequence[BaseAgent], task: Any | None = None + ) -> list[BaseTool]: """Implement delegation tools support for LangGraph. Creates delegation tools that allow this agent to delegate tasks to other agents. diff --git a/lib/crewai/src/crewai/agents/agent_adapters/openai_agents/openai_adapter.py b/lib/crewai/src/crewai/agents/agent_adapters/openai_agents/openai_adapter.py index 88d153a2c..5aadd751b 100644 --- a/lib/crewai/src/crewai/agents/agent_adapters/openai_agents/openai_adapter.py +++ b/lib/crewai/src/crewai/agents/agent_adapters/openai_agents/openai_adapter.py @@ -223,7 +223,9 @@ class OpenAIAgentAdapter(BaseAgentAdapter): """ return self._converter_adapter.post_process_result(result.final_output) - def get_delegation_tools(self, agents: Sequence[BaseAgent], task: Any | None = None) -> list[BaseTool]: + def get_delegation_tools( + self, agents: Sequence[BaseAgent], task: Any | None = None + ) -> list[BaseTool]: """Implement delegation tools support. Creates delegation tools that allow this agent to delegate tasks to other agents. diff --git a/lib/crewai/src/crewai/crew.py b/lib/crewai/src/crewai/crew.py index 404db214e..821607c0f 100644 --- a/lib/crewai/src/crewai/crew.py +++ b/lib/crewai/src/crewai/crew.py @@ -1724,7 +1724,9 @@ class Crew(FlowTrackable, BaseModel): ) -> list[BaseTool]: if self.manager_agent: if task.agent: - tools = self._inject_delegation_tools(tools, task.agent, [task.agent], task=task) + tools = self._inject_delegation_tools( + tools, task.agent, [task.agent], task=task + ) else: tools = self._inject_delegation_tools( tools, self.manager_agent, self.agents, task=task diff --git a/lib/crewai/src/crewai/task.py b/lib/crewai/src/crewai/task.py index 95c8ebf6b..0b64ca71e 100644 --- a/lib/crewai/src/crewai/task.py +++ b/lib/crewai/src/crewai/task.py @@ -909,8 +909,9 @@ class Task(BaseModel): tasks_slices = [description] if self.constraints: - constraints_text = "\n\nTask Constraints (MUST be respected):\n" + "\n".join( - f"- {constraint}" for constraint in self.constraints + constraints_text = ( + "\n\nTask Constraints (MUST be respected):\n" + + "\n".join(f"- {constraint}" for constraint in self.constraints) ) tasks_slices.append(constraints_text) diff --git a/lib/crewai/src/crewai/tools/agent_tools/base_agent_tools.py b/lib/crewai/src/crewai/tools/agent_tools/base_agent_tools.py index b4f31faaa..b7c77514d 100644 --- a/lib/crewai/src/crewai/tools/agent_tools/base_agent_tools.py +++ b/lib/crewai/src/crewai/tools/agent_tools/base_agent_tools.py @@ -16,7 +16,10 @@ class BaseAgentTool(BaseTool): """Base class for agent-related tools""" agents: list[BaseAgent] = Field(description="List of available agents") - original_task: Task | None = Field(default=None, description="The original task being delegated, used to propagate constraints") + original_task: Task | None = Field( + default=None, + description="The original task being delegated, used to propagate constraints", + ) def sanitize_agent_name(self, name: str) -> str: """ @@ -130,8 +133,9 @@ class BaseAgentTool(BaseTool): constraints, ) # Append constraints to context so the worker agent sees them - constraints_text = "\n\nTask Constraints (MUST be respected):\n" + "\n".join( - f"- {c}" for c in constraints + constraints_text = ( + "\n\nTask Constraints (MUST be respected):\n" + + "\n".join(f"- {c}" for c in constraints) ) if context: context = context + constraints_text