How It Works
Quick Start
1
Register a callback
2
Log tool calls
3
Async callback for dashboards
Callback Types
Register with
register_display_callback(type, fn, is_async=False). Alias: add_display_callback.
Configuration Options
Callbacks receive keyword arguments matching the event (for example
message, response, tool_name, agent_name). Extra kwargs are filtered to the function signature automatically.
Best Practices
Keep handlers lightweight
Keep handlers lightweight
Display callbacks run on the hot path. Log or enqueue work — avoid heavy I/O in sync handlers.
Use async for network and UI
Use async for network and UI
Set
is_async=True when writing to WebSockets, Slack, or dashboards so the agent loop stays responsive.Wrap custom logic in try/except
Wrap custom logic in try/except
A failing callback should not crash the agent. Catch, log, and return.
Compose with hooks for fine control
Compose with hooks for fine control
Use display callbacks for output formatting; use hooks when you need to allow, block, or mutate tool calls.
Related
Display System
TaskOutput, terminal rendering, and global registries
Callbacks
Broader callback patterns for agents and tasks

