Skip to content

Commit 61c6cee

Browse files
authored
iterative events - update list (#152)
1 parent 79440ac commit 61c6cee

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/user-guide/concepts/streaming/async-iterators.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Async Iterators for Streaming
22

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.
44

55
> **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.
66
@@ -27,14 +27,15 @@ async def process_streaming_response():
2727
asyncio.run(process_streaming_response())
2828
```
2929

30+
> Note, Strands also offers an [`invoke_async`](../../../api-reference/agent.md#strands.agent.agent.Agent.invoke_async) method for non-iterative async invocations.
31+
3032
## Event Types
3133

3234
The async iterator yields the same event types as [callback handlers](callback-handlers.md#callback-handler-events), including:
3335

3436
### Text Generation Events
3537

3638
- `data`: Text chunk from the model's output
37-
- `complete`: Boolean indicating if this is the final chunk
3839
- `delta`: Raw delta content from the model
3940

4041
### Tool Events
@@ -53,6 +54,7 @@ The async iterator yields the same event types as [callback handlers](callback-h
5354
- `event`: Raw event from the model stream
5455
- `force_stop`: True if the event loop was forced to stop
5556
- `force_stop_reason`: Reason for forced stop
57+
- `result`: The final [`AgentResult`](../../../api-reference/agent.md#strands.agent.agent_result.AgentResult)
5658

5759
### Reasoning Events
5860

@@ -83,17 +85,17 @@ async def stream_response(request: PromptRequest):
8385
tools=[calculator, http_request],
8486
callback_handler=None
8587
)
86-
88+
8789
try:
8890
async for event in agent.stream_async(request.prompt):
8991
if "data" in event:
9092
# Only stream text chunks to the client
9193
yield event["data"]
9294
except Exception as e:
9395
yield f"Error: {str(e)}"
94-
96+
9597
return StreamingResponse(
9698
generate(),
9799
media_type="text/plain"
98100
)
99-
```
101+
```

docs/user-guide/concepts/streaming/callback-handlers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Callback handlers receive the same event types as [async iterators](./async-iter
4242
### Text Generation Events
4343

4444
- `data`: Text chunk from the model's output
45-
- `complete`: Boolean indicating if this is the final chunk
4645
- `delta`: Raw delta content from the model
4746

4847
### Tool Events
@@ -61,6 +60,7 @@ Callback handlers receive the same event types as [async iterators](./async-iter
6160
- `event`: Raw event from the model stream
6261
- `force_stop`: True if the event loop was forced to stop
6362
- `force_stop_reason`: Reason for forced stop
63+
- `result`: The final [`AgentResult`](../../../api-reference/agent.md#strands.agent.agent_result.AgentResult)
6464

6565
### Reasoning Events
6666

0 commit comments

Comments
 (0)