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
How It Works
Sync vs Async Methods
| Sync | Async | Use When |
|---|---|---|
agent.start() | await agent.astart() | Running an agent |
agent.chat() | await agent.achat() | Conversational turn |
agents.start() | await agents.astart() | Multi-agent orchestration |
Configuration Options
Setasync_execution=True on individual tasks to mark them for async execution:
| Option | Type | Default | Description |
|---|---|---|---|
async_execution | bool | False | Mark task for async execution |
callback | Callable | None | Sync or async callback on task completion |
Common Patterns
Parallel Requests
Async Callback
Inside a Web Framework (FastAPI)
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

