-
Notifications
You must be signed in to change notification settings - Fork 286
[BUG] Tools are not async #435
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.20.0
Tools Package Version
0.2.18
Tools used
- calculator
- generate_image
Python Version
3.12.13
Operating System
Linux, Windows, MacOS
Installation Method
pip
Steps to Reproduce
- Create a server that runs multiple agents in parallel
- Because of Python's GIL, attempt several sessions between multiple agents concurrently and invoke tool calls on all of them
- Notice that the thread locks up.
Expected Behavior
Unless tools are explicitly defined in an asynchronous manner, the Agent loop seems to treat them as synchronous calls. Normally if you're only running a single Agent in a server, that doesn't cause any issues, but if at any point you call multiple agents in the same Python service whether that's Agent as Tools or just in separate threads, it will lock up the thread, causing the CPU to be completely bottlenecked. This is more of an issue with Python's GIL but because the tools are not implemented asynchronously, it exacerbates the problem. Multi-threading does not necessarily solve this due to the GIL due to shared memory nature of Python
Actual Behavior
Calling multiple tools across multiple agents in the same Python service locks up the main thread.
Additional Context
No response
Possible Solution
No response
Related Issues
No response