Async agents use three handlers for async task management: on_task_create, on_task_event_send, and on_task_cancel. Unlike sync agents, tasks persist and can receive multiple events over time.
- The three-handler pattern for async agents
- How tasks differ from sync messages
- When to use async vs sync agents
- Development environment set up (see main repo README)
- Backend services running:
make devfrom repository root - Understanding of sync agents (see 00_sync/000_hello_acp)
cd examples/tutorials/10_async/00_base/000_hello_acp
uv run agentex agents run --manifest manifest.yaml@acp.on_task_create
async def handle_task_create(params: CreateTaskParams):
# Initialize task state, send welcome message
@acp.on_task_event_send
async def handle_event_send(params: SendEventParams):
# Handle each message/event in the task
@acp.on_task_cancel
async def handle_task_cancel(params: CancelTaskParams):
# Cleanup when task is cancelledThree handlers instead of one, giving you full control over task lifecycle. Tasks can receive multiple events and maintain state across them.
- Conversational agents that need memory
- Operations that require task tracking
- Agents that need lifecycle management (initialization, cleanup)
- Building towards production systems
The task-based model is the foundation of production agents. Unlike sync agents where each message is independent, async agents maintain persistent tasks that can receive multiple events, store state, and have full lifecycle management. This is the stepping stone to Temporal-based agents.
Next: 010_multiturn - Add conversation memory