Skip to content

Conversation

@cagataycali
Copy link
Member

@cagataycali cagataycali commented Jul 22, 2025

Description

Fixed a critical bug in the swarm tool where sub-agents were receiving tool names as strings instead of actual tool objects from the parent agent's registry. This caused sub-agents to treat tool names like "shell" and "editor" as file paths, attempting to load files like ./shell.py and resulting in "Tool file not found" errors.

The fix modifies _create_custom_agents() to properly retrieve actual tool objects from parent_agent.tool_registry.registry instead of passing tool name strings, ensuring sub-agents receive functional tool instances.

Thanks for reporting: @westonbrown

Related Issues

Addresses bug reported by Aaron Brown regarding swarm sub-agents being unable to use tools due to incorrect tool object passing.

Documentation PR

[Link to related associated PR in the agent-docs repo - if needed]

Type of Change

  • Bug fix
  • New Tool
  • Breaking change
  • Other (please describe):

Testing

The change has been thoroughly tested with:

  • hatch fmt --linter
  • hatch fmt --formatter
  • hatch test --all

Added comprehensive unit test test_create_agents_tool_objects_retrieval() that verifies:

  • Actual tool objects are retrieved from parent registry
  • Tool objects (not strings) are passed to sub-agents
  • Correct tool instances are provided to Agent constructor

Checklist

  • I have read the CONTRIBUTING document

  • I have added tests that prove my fix is effective or my feature works

  • I have updated the documentation accordingly

  • I have added an appropriate example to the documentation to outline the feature

  • My changes generate no new warnings

  • Any dependent changes have been merged and published

  • By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…sub-agents

- Fixed bug where swarm tool was passing tool names as strings to sub-agents
- Sub-agents were treating strings as file paths and trying to load ./shell.py etc.
- Now retrieves actual tool objects from parent_agent.tool_registry.registry
- Added test to verify tool objects are passed correctly
- Resolves 'Tool file not found' errors in swarm sub-agents

Fixes issue reported by Aaron Brown where sub-agents couldn't use tools
@cagataycali cagataycali requested a review from a team as a code owner July 22, 2025 13:45
jer96
jer96 previously approved these changes Jul 22, 2025
@cagataycali cagataycali enabled auto-merge (squash) July 22, 2025 14:38
The test was failing due to timing variations where actual sleep time
exceeded the expected 0.7 second upper bound. Removed the test and
unused time import to fix test reliability.
@cagataycali cagataycali merged commit d3b5fec into strands-agents:main Jul 22, 2025
14 of 28 checks passed
@cagataycali cagataycali deleted the fix/swarm-tool-objects-instead-of-strings branch July 22, 2025 14:53
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.

2 participants