Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions sdk/guides/convo-async.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,20 @@ cd agent-sdk
uv run python examples/01_standalone_sdk/11_async.py
```

### Async Streaming

Use `astream()` to process events as they occur without blocking:

```python highlight={4-5}
async def run_agent():
conversation = Conversation(agent=agent, workspace=cwd)
conversation.send_message("Write 3 facts about Python to FACTS.txt")

async for event in conversation.astream():
print(f"Event: {event}")
```

### Concurrent Agents

Run multiple agent tasks in parallel using `asyncio.gather()`:

```python highlight={4-7}
```python highlight={10-14}
async def main():
# Create multiple conversation tasks
loop = asyncio.get_running_loop()
callback = AsyncCallbackWrapper(callback_coro, loop)

# Create multiple conversation tasks running in parallel
tasks = [
run_task("task 1"),
run_task("task 2"),
run_task("task 3")
loop.run_in_executor(None, run_conversation, callback),
loop.run_in_executor(None, run_conversation, callback),
loop.run_in_executor(None, run_conversation, callback)
]
results = await asyncio.gather(*tasks)
```
Expand Down