Event structure
Every event has these fields:agent and name identify the source agent — agent is the class name and name is the Durable Object instance name.
Channels
Events are routed to eight named channels based on their type:Subscribing to events
Typed subscribe helper
Thesubscribe() function from agents/observability provides type-safe access to events on a specific channel:
event is narrowed to only the event types that flow through that channel.
Raw diagnostics_channel
You can also subscribe directly using the Node.js API:Tail Workers (production)
In production, all diagnostics channel messages are automatically forwarded to Tail Workers. No subscription code is needed in the agent itself — attach a Tail Worker and access events viaevent.diagnosticsChannelEvents:
Custom observability
You can override the default implementation by providing your ownObservability interface:
observability to undefined to disable all event emission:
Event reference
RPC events
State events
Message and tool events (AIChatAgent)
These events are emitted by AIChatAgent from @cloudflare/ai-chat. They track the chat message lifecycle, including client-side tool interactions.