Skip to content

fcakyon/claude-codex-settings / plugins/cloudflare-skills/skills/agents-sdk

agents-sdk

Verified

Build, debug, or review Cloudflare Agents SDK applications using the agents package.

references/observability.md

View on GitHub
# Observability

Fetch https://developers.cloudflare.com/agents/runtime/operations/observability/index.md for complete documentation.

Agents emit structured events via Node.js `diagnostics_channel`. Subscribe in development or forward via Tail Workers in production.

## Subscribe to Events

```typescript
import { subscribe } from "agents/observability";

subscribe("agents:rpc", (event) => {
  console.log(`RPC call: ${event.payload.method}`);
});

subscribe("agents:state", (event) => {
  console.log(`State change on ${event.agent}`);
});
```

## Available Channels

| Channel | Events |
|---------|--------|
| `agents:state` | State changes |
| `agents:rpc` | `@callable` invocations |
| `agents:message` | WebSocket messages |
| `agents:schedule` | Schedule triggers |
| `agents:lifecycle` | Agent start, connect, disconnect |
| `agents:workflow` | Workflow progress, completion, errors |
| `agents:mcp` | MCP server connections, tool calls |
| `agents:email` | Email received |

## Per-Agent Override

```typescript
export class MyAgent extends Agent<Env, State> {
  observability = undefined; // disable for this agent
}
```

## Production: Tail Workers

In production, events appear as `diagnosticsChannelEvents` on the Tail Worker `event` object. Attach a Tail Worker to your agent's Worker to forward events to your observability platform.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall