await, letting you process multiple requests in parallel or embed agents inside async web servers.
astart() yields on I/O so the server stays responsive under load.
Quick Start
1
Simple Usage
Use
astart() inside an async function:2
With Configuration
Run multiple agents in parallel with
asyncio.gather:How It Works
Sync vs Async Methods
Configuration Options
Setasync_execution=True on individual tasks to mark them for async execution:
Common Patterns
Parallel Requests
Async Callback
Inside a Web Framework (FastAPI)
Lifecycle Hooks in Async Workflows
on_task_start and on_task_complete fire from astart() / arun_task() exactly as they do from start():
async def callbacks are awaited; sync callbacks are offloaded to the default executor. See Multi-Agent Hooks for the full contract.
Best Practices
Always use asyncio.run() as the entry point
Always use asyncio.run() as the entry point
Call
asyncio.run(main()) once at the program entry point. Avoid calling it inside already-running event loops — use await there instead.Limit concurrency to avoid rate limits
Limit concurrency to avoid rate limits
Use
asyncio.Semaphore(n) to cap simultaneous LLM calls: async with asyncio.Semaphore(5): result = await agent.astart(...). Start with n=5 and tune based on your API limits.Handle errors per-task with gather(return_exceptions=True)
Handle errors per-task with gather(return_exceptions=True)
Pass
return_exceptions=True to asyncio.gather() so one failed task doesn’t cancel the others. Check each result for isinstance(result, Exception) before using it.Use async callbacks for async downstream work
Use async callbacks for async downstream work
Callbacks can be async (
async def callback(output): ...). The runtime dispatches them safely even when called from within a running event loop.Related
Workflows
Build parallel and sequential multi-agent workflows
Async Crew Kickoff
Run YAML-defined crews asynchronously

