Quick Start
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
on_step | Callable | None | None | Called on each agent step |
on_tool_call | Callable | None | None | Called on tool execution |
middleware | List[Any] | [] | Middleware chain |
Common Patterns
Pattern 1: Logging All Events
Pattern 2: Custom Middleware
Best Practices
Keep Callbacks Lightweight
Keep Callbacks Lightweight
Callbacks run synchronously. Keep them fast to avoid slowing down the agent.
Use Middleware for Cross-Cutting Concerns
Use Middleware for Cross-Cutting Concerns
Middleware is ideal for logging, metrics, authentication, etc.
Handle Errors in Callbacks
Handle Errors in Callbacks
Wrap callback logic in try/except to prevent callback errors from crashing the agent.

