Events & Hooks
The framework exposes a typed EventBus and lifecycle hooks for observability and integration.
EventBus
Use EventBus to publish/subscribe runtime events such as:
- turn boundaries
- tool lifecycle
- GUI updates
- subagent interaction events
Hooks
Common hooks include:
onSessionStartonSessionEndonToolCallonToolResultonSubagentSteponAgentTransferonTurnLatencyonMemoryExtractiononBackgroundNotification— fired when a background notification (BackgroundAgent, tool-completion bridge, interactive subagent question, orVoiceSession.notifyBackground) is delivered to the LLM. The event includeslabel,priority,publishedAtMs,deliveredAtMs,deferredMs, and the envelopecorrelationId. See Background Agents.onError
Hooks are ideal for logging, tracing, and metrics.