Skip to content

async tools support #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2025
Merged

async tools support #391

merged 3 commits into from
Jul 10, 2025

Conversation

pgrayy
Copy link
Member

@pgrayy pgrayy commented Jul 9, 2025

Description

Support async tool definitions.

Related Issues

#83

Documentation PR

Will be following up on this.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare
  • Wrote new unit tests.
  • Ran the integ tests.
  • Ran the following test script:
@strands.tool
async def math_agent(exp: str):
    model = OpenAIModel({"api_key": "****"}, model_id="gpt-4o")
    agent = Agent(model=model, callback_handler=None)
    prompt = f"What is {exp}? Think through the steps."
    result = await agent.invoke_async(prompt)
    return result.message


model = OpenAIModel({"api_key": "****"}, model_id="gpt-4o")
agent = Agent(model=model, tools=[math_agent], callback_handler=None)
result = agent("Can you run the math_agent tool 4 times to help me with the calculation '2+2'? I want different perspectives")
print(result.message)

The tool is executed 4 times concurrently. Note, we are using Agent.__call__ which is synchronous itself but under the hood it creates an async event loop.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary 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, or no new docs are needed
  • 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.

@pgrayy pgrayy requested a review from zastrowm July 9, 2025 13:54
@pgrayy pgrayy marked this pull request as ready for review July 9, 2025 13:54
@pgrayy pgrayy changed the title async tools async tools support Jul 9, 2025
jer96
jer96 previously approved these changes Jul 9, 2025
@pgrayy pgrayy temporarily deployed to auto-approve July 9, 2025 21:48 — with GitHub Actions Inactive
@pgrayy pgrayy merged commit e36eb59 into strands-agents:main Jul 10, 2025
12 checks passed
@jer96 jer96 mentioned this pull request Jul 10, 2025
8 tasks
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.

3 participants