From 4e2aafce566a8eab9c075b347e6290a1135d5263 Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 12 Nov 2025 17:07:21 +0000 Subject: [PATCH] docs: remove non-existent astream() method and fix concurrent agents example - 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 --- sdk/guides/convo-async.mdx | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/sdk/guides/convo-async.mdx b/sdk/guides/convo-async.mdx index 79a96785..9fa4279d 100644 --- a/sdk/guides/convo-async.mdx +++ b/sdk/guides/convo-async.mdx @@ -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) ```