Skip to content

async model stream interface #306

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 29 commits into from
Jul 3, 2025
Merged

Conversation

pgrayy
Copy link
Member

@pgrayy pgrayy commented Jun 27, 2025

Description

We are currently working on support for an iterative async stream method on the agent class (#83). As part of this work, we need to convert any component that yields model events into an async generator.

NOTE: There is still follow up work to transition to using async versions of the underlying clients for each model provider. For example, OpenAIModel provider will transition to use the AsyncOpenAI client.

Related Issues

#83

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

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.

@ryanycoleman ryanycoleman moved this to We're Working On It in Strands Agents Roadmap Jun 27, 2025
@pgrayy pgrayy marked this pull request as draft June 30, 2025 13:35
@pgrayy pgrayy temporarily deployed to auto-approve July 1, 2025 19:23 — with GitHub Actions Inactive
Copy link
Member

@zastrowm zastrowm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure this does not go out today if we're releasing.

I'd like to bug bash on this before it shipped a bit

@pgrayy pgrayy temporarily deployed to auto-approve July 2, 2025 15:15 — with GitHub Actions Inactive
@pgrayy pgrayy temporarily deployed to auto-approve July 2, 2025 15:20 — with GitHub Actions Inactive
@austinmw
Copy link

austinmw commented Jul 2, 2025

Hey, I tried using this WIP PR, but found I couldn't run agents concurrently. Maybe it's because self.client.converse_stream(**request) in BedrockModel.stream() is a blocking boto3 call that prevents asyncio.gather() from running multiple agents in parallel?

@zastrowm
Copy link
Member

zastrowm commented Jul 2, 2025

Hey, I tried using this WIP PR, but found I couldn't run agents concurrently. Maybe it's because self.client.converse_stream(**request) in BedrockModel.stream() is a blocking boto3 call that prevents asyncio.gather() from running multiple agents in parallel?

@pgrayy this might be something to explore/file an issue for. We've seen something similar before strands-agents/tools#91 (comment). Ultimately this might accelerate the usage of the experimental client.

@pgrayy
Copy link
Member Author

pgrayy commented Jul 3, 2025

Hey, I tried using this WIP PR, but found I couldn't run agents concurrently. Maybe it's because self.client.converse_stream(**request) in BedrockModel.stream() is a blocking boto3 call that prevents asyncio.gather() from running multiple agents in parallel?

Yes this is correct. Bedrock does have an async client in the works though (source). We will likely work out a process to give customers an option to opt-in for its use while we wait for a 1.0 release. In the meanwhile, we will update our docs to identify current limitations with async. I will note though that for strands 1.0, some model providers will be converted to full async. For example, the OpenAIModel provider will be updated to use AsyncOpenAI.

@pgrayy pgrayy changed the title async models async model stream interface Jul 3, 2025
@pgrayy pgrayy temporarily deployed to auto-approve July 3, 2025 01:00 — with GitHub Actions Inactive
@austinmw
Copy link

austinmw commented Jul 3, 2025

Ah okay thanks, didn't know about the experimental async client. Providing that option would be great!


For context, my team uses Strands heavily and needs offline concurrent utilities for evaluation:

  • Running all agents × all test queries (many-to-many)
  • Running a single model.structured_output against multiple llm-as-a-judge prompts (one-to-many)

@pgrayy pgrayy temporarily deployed to auto-approve July 3, 2025 12:37 — with GitHub Actions Inactive
@pgrayy pgrayy merged commit 8ff53b1 into strands-agents:main Jul 3, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from We're Working On It to Just Shipped in Strands Agents Roadmap Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Just Shipped
Development

Successfully merging this pull request may close these issues.

3 participants