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

@@ -20,11 +20,13 @@ from crewai.utilities.string_utils import interpolate_only
def test_task_tool_reflect_agent_tools():
"""Test that agent tools are available during task execution via crew fallback logic."""
from crewai.tools import tool
@tool
def fake_tool() -> None:
def fake_tool() -> str:
"Fake tool"
return "result"
researcher = Agent(
role="Researcher",
@@ -40,7 +42,9 @@ def test_task_tool_reflect_agent_tools():
agent=researcher,
)
assert task.tools == [fake_tool]
assert task.tools == []
assert researcher.tools == [fake_tool]
def test_task_tool_takes_precedence_over_agent_tools():