Skip to content

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Oct 9, 2025

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 in task.py that automatically extended task.tools with agent.tools at task creation time. In hierarchical crews, this caused manager agents to inherit tools from task agents when executing those tasks.

Key changes:

  • Removed the check_tools model validator from Task class
  • Tools are now resolved at execution time via existing crew fallback logic (task.tools or agent_to_use.tools or [])
  • Added regression test for hierarchical crews
  • Updated existing test to reflect new creation-time behavior
  • Fixed several regex pattern linting warnings

Review & Testing Checklist for Human

⚠️ HIGH PRIORITY ITEMS (3)

  • Test sequential crews still work correctly - Verify that agent tools are still available during task execution in non-hierarchical crews (the fallback logic in crew.py:884 should handle this, but needs verification)
  • Test actual hierarchical crew execution - The new test only verifies 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 execution
  • Check for breaking changes - Search codebase for any code that might depend on task.tools being populated at creation time rather than execution time

Notes

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

- 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 <[email protected]>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Remove unused 'crew' variable in test_hierarchical_crew_does_not_propagate_agent_tools_to_manager (F841)
- Add raw string prefixes to regex patterns to comply with RUF043 linting rule
- Pre-existing RUF043 errors in changed files were blocking PR, so fixed them

Co-Authored-By: João <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants