Skip to main content
Async agents run non-blocking AI tasks with await, letting you process multiple requests in parallel or embed agents inside async web servers.
The user sends concurrent requests; each 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

Set async_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

Call asyncio.run(main()) once at the program entry point. Avoid calling it inside already-running event loops — use await there instead.
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.
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.
Callbacks can be async (async def callback(output): ...). The runtime dispatches them safely even when called from within a running event loop.

Workflows

Build parallel and sequential multi-agent workflows

Async Crew Kickoff

Run YAML-defined crews asynchronously