Fix tool propagation bug in hierarchical crews (#3679) #3680
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 tool propagation bug in hierarchical crews (#3679)
Summary
This PR fixes a bug where tools were unintentionally propagated to manager agents in hierarchical crews. The root cause was the
check_tools
validator intask.py
that automatically extendedtask.tools
withagent.tools
at task creation time. In hierarchical crews, this caused manager agents to inherit tools from task agents when executing those tasks.Key changes:
check_tools
model validator fromTask
classtask.tools or agent_to_use.tools or []
)Review & Testing Checklist for Human
crew.py:884
should handle this, but needs verification)task.tools
is empty at creation time, but doesn't test the full execution flow. Verify manager agents don't get unwanted tools during actual task executiontask.tools
being populated at creation time rather than execution timeNotes
Risk Assessment: This is a behavior change that shifts tool resolution from creation time to execution time. While the crew execution logic should handle this correctly, there's a risk of unintended side effects in edge cases or external code that depends on the old behavior.
Requested by: João ([email protected]) via Slack
Session: https://app.devin.ai/sessions/917aad46e9844e43abad36f8364ac813
Original Issue: #3679