Fix tool propagation bug in hierarchical crews (#3679)

- Remove check_tools validator from task.py that was extending task.tools
  with agent.tools at creation time
- This caused manager agents in hierarchical crews to incorrectly inherit
  tools from task agents
- The crew.py execution logic already handles tool resolution correctly
  at execution time via fallback: task.tools or agent_to_use.tools or []
- Add reproduction test test_hierarchical_crew_does_not_propagate_agent_tools_to_manager
- Update test_task_tool_reflect_agent_tools to verify execution-time behavior

Fixes #3679

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-10-09 15:32:45 +00:00
parent cb8bcfe214
commit 01114168df
3 changed files with 46 additions and 8 deletions

View File

@@ -336,12 +336,6 @@ class Task(BaseModel):
setattr(self, key, value)
return self
@model_validator(mode="after")
def check_tools(self):
"""Check if the tools are set."""
if not self.tools and self.agent and self.agent.tools:
self.tools.extend(self.agent.tools)
return self
@model_validator(mode="after")
def check_output(self):