Skip to content

Stream responses

Stream an agent’s output as it happens instead of waiting for the final response: text tokens, tool calls, and lifecycle events, as they occur. This is what drives responsive user interfaces and real-time monitoring.

Strands emits the same set of events regardless of how you consume them; you choose the consumption model that fits your application. Async iterators suit asynchronous server frameworks, and callback handlers suit synchronous Python.

The smallest real thing streaming does is print an agent’s answer token by token as the model produces it. Iterate over the stream and forward the text chunks:

import asyncio
from strands import Agent
agent = Agent(callback_handler=None)
async def main():
async for event in agent.stream_async("Tell me about agents in one sentence."):
if "data" in event:
print(event["data"], end="", flush=True)
asyncio.run(main())

Each data chunk is one piece of the model’s output. The event reference lists everything else the stream carries: tool calls, lifecycle signals, and multi-agent coordination.

New to streaming? Start with Async Iterators to consume the stream in an async server, or Callback Handlers if your Python application is synchronous. Both receive the same events; the event reference is the complete list of what you can react to.