You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/concepts/streaming/async-iterators.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Async Iterators for Streaming
2
2
3
-
Strands Agents SDK provides support for asynchronous iterators through the `stream_async` method, enabling real-time streaming of agent responses in asynchronous environments like web servers, APIs, and other async applications.
3
+
Strands Agents SDK provides support for asynchronous iterators through the [`stream_async`](../../../api-reference/agent.md#strands.agent.agent.Agent.stream_async) method, enabling real-time streaming of agent responses in asynchronous environments like web servers, APIs, and other async applications.
4
4
5
5
> **Note**: If you want to use callbacks instead of async iterators, take a look at the [callback handlers](./callback-handlers.md) documentation. Async iterators are ideal for asynchronous frameworks like FastAPI, aiohttp, or Django Channels. For these environments, Strands Agents SDK offers the `stream_async` method which returns an asynchronous iterator.
> Note, Strands also offers an [`invoke_async`](../../../api-reference/agent.md#strands.agent.agent.Agent.invoke_async) method for non-iterative async invocations.
31
+
30
32
## Event Types
31
33
32
34
The async iterator yields the same event types as [callback handlers](callback-handlers.md#callback-handler-events), including:
33
35
34
36
### Text Generation Events
35
37
36
38
-`data`: Text chunk from the model's output
37
-
-`complete`: Boolean indicating if this is the final chunk
38
39
-`delta`: Raw delta content from the model
39
40
40
41
### Tool Events
@@ -53,6 +54,7 @@ The async iterator yields the same event types as [callback handlers](callback-h
53
54
-`event`: Raw event from the model stream
54
55
-`force_stop`: True if the event loop was forced to stop
55
56
-`force_stop_reason`: Reason for forced stop
57
+
-`result`: The final [`AgentResult`](../../../api-reference/agent.md#strands.agent.agent_result.AgentResult)
0 commit comments