How It Works
Quick Start
1
Subscribe and publish
2
Global bus with an agent
publish() returns immediately when there are no subscribers — no lock, no UUID, no history. Wrap expensive payload construction in a has_subscribers check.Event Types
Common Patterns
Async subscriber:Best Practices
Check has_subscribers before heavy work
Check has_subscribers before heavy work
Building summaries or embeddings for events nobody listens to wastes CPU — guard with
bus.has_subscribers.Filter by event_types
Filter by event_types
Pass
event_types= to subscribe() so handlers only run for relevant events.Use get_default_bus for cross-component wiring
Use get_default_bus for cross-component wiring
The shared default bus lets agents, memory, and hooks emit events without passing a bus instance everywhere.
Prefer sync handlers unless you need async
Prefer sync handlers unless you need async
Sync callbacks run inline; async handlers are awaited during
publish_async only.Related
Hook Events
Hook lifecycle events alongside the bus
Spawn & Announce
Sub-agent events and coordination

