Fix hierarchical delegation bug where manager couldn't delegate to all crew agents (#3887) #3888
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix hierarchical delegation bug where manager couldn't delegate to all crew agents (#3887)
Summary
Fixes a bug in hierarchical process where the manager agent's delegation tools were incorrectly limited to only the task's assigned agent instead of all crew agents. This caused delegation errors when the manager tried to delegate to other agents in the crew.
The Fix: Changed one line in
crew.py(_update_manager_toolsmethod) to passself.agentsinstead of[task.agent]when injecting delegation tools for hierarchical crews with assigned tasks.Changes:
lib/crewai/src/crewai/crew.py: Updated line 1125 to pass all crew agents to delegation toolslib/crewai/tests/test_crew.py: Added 2 comprehensive tests reproducing the bug scenario and updated 1 existing test to reflect correct behaviorlib/crewai/tests/cassettes/*.yaml: Updated VCR cassette from test runReview & Testing Checklist for Human
This is a YELLOW RISK change - small code change but affects core delegation logic.
test_hierarchical_crew_creation_tasks_with_async_execution.yaml- it's a new HTTP interaction recording from my test run. Ensure it looks legitimate (it's a tracing API call).Test Plan Recommendation
manager_agent(e.g., "Coordinator")crew.agentslist (e.g., ["Planner", "Developer"])Notes