Skip to main content
Agents emit structured events for every significant operation — RPC calls, state changes, schedule execution, workflow transitions, MCP connections, and more. These events are published to diagnostics channels and are silent by default (zero overhead when nobody is listening).

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

The subscribe() function from agents/observability provides type-safe access to events on a specific channel:
The callback is fully typed — 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 via event.diagnosticsChannelEvents:
This gives you structured, filterable observability in production with zero overhead in the agent hot path.

Custom observability

You can override the default implementation by providing your own Observability interface:
Set 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.

Schedule and queue events

Lifecycle events

Workflow events

MCP events

Email events