Skip to content

Commit ae35bbf

Browse files
docs: remove non-existent astream() method and fix concurrent agents example (#103)
- Remove 'Async Streaming' section that documented astream() method which was never implemented - Update 'Concurrent Agents' example to use actual functions (run_conversation, callback) from the example code instead of undefined run_task() - Properly demonstrate concurrent execution using loop.run_in_executor() with asyncio.gather() Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 4954bed commit ae35bbf

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

sdk/guides/convo-async.mdx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,30 +116,20 @@ cd agent-sdk
116116
uv run python examples/01_standalone_sdk/11_async.py
117117
```
118118

119-
### Async Streaming
120-
121-
Use `astream()` to process events as they occur without blocking:
122-
123-
```python highlight={4-5}
124-
async def run_agent():
125-
conversation = Conversation(agent=agent, workspace=cwd)
126-
conversation.send_message("Write 3 facts about Python to FACTS.txt")
127-
128-
async for event in conversation.astream():
129-
print(f"Event: {event}")
130-
```
131-
132119
### Concurrent Agents
133120

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

136-
```python highlight={4-7}
123+
```python highlight={10-14}
137124
async def main():
138-
# Create multiple conversation tasks
125+
loop = asyncio.get_running_loop()
126+
callback = AsyncCallbackWrapper(callback_coro, loop)
127+
128+
# Create multiple conversation tasks running in parallel
139129
tasks = [
140-
run_task("task 1"),
141-
run_task("task 2"),
142-
run_task("task 3")
130+
loop.run_in_executor(None, run_conversation, callback),
131+
loop.run_in_executor(None, run_conversation, callback),
132+
loop.run_in_executor(None, run_conversation, callback)
143133
]
144134
results = await asyncio.gather(*tasks)
145135
```

0 commit comments

Comments
 (0)