diff --git a/sdk/guides/convo-async.mdx b/sdk/guides/convo-async.mdx index d47ca998..4f763c6a 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) ```