Skip to main content
Run PraisonAI crews with native async execution from FastAPI, Jupyter, Discord bots, and other event loop contexts. The user awaits agent.astart() from an async app; the crew kickoff runs natively on the event loop without thread offload.

Quick Start

1

FastAPI Route

Native async execution — no worker threads, true cooperative multitasking:
2

Jupyter Notebook

Works directly in async cells without blocking:

How It Works

Non-blocking startup

Config loading, adapter setup, and workflow preparation run in a worker thread via asyncio.to_thread, so a slow disk read or heavy adapter import never stalls the event loop. The _aload_config and _aprepare_for_run helpers wrap the blocking open() / yaml.safe_load / adapter setup calls, keeping the loop free to serve other requests while startup work runs off-thread.
Sync/Async Parity: As of PR #1870, sync and async kickoff paths share the same prep logic (AutoGen version selection, AgentOps init, cli_backend validation), so behavior is identical between generate_crew_and_kickoff() and agenerate_crew_and_kickoff().
Extended in PR #2738: Config validation, merge, and dump logic live in a single _build_yaml_workflow builder shared by both paths, so sync and async behavior can no longer drift apart.
PR #3252 (July 2026) extended parity to the process: workflow path — observability, cli_backend validation, and tool_timeout diagnostics now fire on workflow YAML for both sync and async, matching the sequential / hierarchical treatment.

What’s actually async

Workflow mode

YAML files with process: workflow also run natively async via YAMLWorkflowParser + workflow.astart() — no extra configuration needed.

Configuration Options


Common Patterns

FastAPI Background Task

Concurrent Crew Execution


Best Practices

Under native async, asyncio.CancelledError and asyncio.wait_for now actually cancel SDK work instead of being trapped behind a worker thread:
When running multiple crews, use asyncio.gather for parallel execution:
All supported frameworks work with async execution — praisonai-native uses true async, others fall back to thread offload automatically:
Wrap async crew execution in try-catch blocks:

YAML Template Variables

Use placeholders safely alongside JSON literals

Framework Adapter Plugins

Custom framework adapters with async support