Quick Start
How It Works
| Hook | When it fires | Use case |
|---|---|---|
on_task_start | Before each task begins | Logging, resource allocation |
on_task_complete | After each task succeeds | Notifications, result storage |
completion_checker | After task, before marking done | Quality gates, validation |
Configuration Options
MultiAgentHooksConfig SDK Reference
Full parameter reference for MultiAgentHooksConfig
| Option | Type | Default | Description |
|---|---|---|---|
on_task_start | Callable | None | None | Called before a task begins. Signature: (task) -> None |
on_task_complete | Callable | None | None | Called after a task finishes. Signature: (task, result) -> None |
completion_checker | Callable | None | None | Custom validator. Signature: (task, result) -> bool |
Common Patterns
Pattern 1 — Logging workflow progress
Pattern 2 — Quality gate with retry logic
Best Practices
Keep hooks lightweight
Keep hooks lightweight
Hook callbacks run synchronously in the orchestrator loop. Expensive operations (database writes, HTTP requests) should be done asynchronously or offloaded to a background thread to avoid slowing down task execution.
Use completion_checker for quality gates
Use completion_checker for quality gates
The
completion_checker is ideal for enforcing output quality requirements — minimum length, required fields, absence of error text. Return False to trigger a retry and True to accept the result.Don't mutate task objects in hooks
Don't mutate task objects in hooks
Hook callbacks receive task references. Mutating task properties during execution can cause unexpected behavior. Use hooks for observation and notification, not for changing task state.
Related
Hooks
Single-agent lifecycle hooks
Callbacks
Agent callback system
Multi-Agent Output
Control output verbosity across agents
Multi-Agent Execution
Configure iteration and retry limits

