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
Durable Persistence
Attach a durable sink to persist every published event — even the no-subscriber fast path — to SQLite. See Durable Event Log for the full story.EventBus.attach_sink(sink) / detach_sink(sink) -> bool / has_sinks manage sinks; a sink is any object implementing EventLogProtocol.append(event).
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
Durable Event Log
Persist events to SQLite and query per session
Hook Events
Hook lifecycle events alongside the bus
Spawn & Announce
Sub-agent events and coordination

