Skip to content

[BUG] Tools are not async #435

@ctoh-skechers

Description

@ctoh-skechers

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

  1. calculator
  2. generate_image

Python Version

3.12.13

Operating System

Linux, Windows, MacOS

Installation Method

pip

Steps to Reproduce

  1. Create a server that runs multiple agents in parallel
  2. Because of Python's GIL, attempt several sessions between multiple agents concurrently and invoke tool calls on all of them
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions