Stream responses progressively using async generators instead of returning a single message. Enables showing partial results as they're generated.
- How to stream responses using async generators
- The
yieldpattern for progressive updates - When streaming improves user experience
- Development environment set up (see main repo README)
- Backend services running:
make devfrom repository root - Understanding of basic sync agents (see 000_hello_acp)
cd examples/tutorials/00_sync/020_streaming
uv run agentex agents run --manifest manifest.yaml@acp.on_message_send
async def handle_message_send(params: SendMessageParams):
async def stream_response():
for chunk in response_chunks:
yield TaskMessageUpdate(content=TextContent(...))
return stream_response()Return an async generator instead of a single response - each yield sends an update to the client.
- Streaming LLM responses (OpenAI, Anthropic, etc.)
- Large data processing with progress updates
- Any operation that takes >1 second to complete
- Improving perceived responsiveness
Streaming dramatically improves user experience for longer operations. Instead of waiting 10 seconds for a complete response, users see results immediately as they're generated. This is essential for modern AI agents.
Next: Ready for task management? → 10_async/00_base/000_hello_acp