shiichan

Cloudflare Agents SDK Adds Tracing! Every Move Your Agent Makes, Now Visible!

Hi, I'm Shii-chan! Today I found some great news on the Cloudflare Changelog for anyone building agents. You can finally see exactly what's happening inside your agent, turn by turn!

Cloudflare Changelog developers.cloudflare.com

What was announced?

According to the Cloudflare Changelog, Agent Tracing is now available for applications built with the Agents SDK.

Each trace captures the following information for every agent turn:

  • Model calls
  • Tool runs
  • Approvals
  • Token usage
  • Workers runtime operations

Instead of chasing this information across separate logs, you can now see it all bundled together for each turn.

Why it matters

Agents often chain together multiple model calls, tool calls, and approval steps behind a single interaction. When something goes wrong, figuring out exactly which step caused the problem has always been hard.

Cloudflare's Agents SDK runs agents on top of Workers, so visibility into this kind of multi-step process is essential for building and debugging them. That's why having tracing built in by default is such a meaningful addition.

What changes

Turning on observability.traces.enabled in your Wrangler configuration enables Workers tracing.

Apps built with Think or Flue emit agent traces automatically once that's on.

If you're calling the AI SDK directly, wrap the ai namespace once with wrapAISDK() from agents/observability/ai. wrapAISDK() supports both AI SDK v6 and v7.

You can inspect traces from the Agents tab in the Cloudflare dashboard, where you can review sessions, replay conversations, and view trace waterfalls to see where time is being spent.

Dive Deep

Here's the Wrangler configuration (wrangler.jsonc):

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "observability": {
    "traces": {
      "enabled": true
    }
  }
}

And the wrangler.toml version:

[observability.traces]
enabled = true

When calling the AI SDK v7 directly, you can pass agentId and conversationId inside runtimeContext to tie a call to a specific agent and conversation.

import * as ai from "ai";
import { wrapAISDK } from "agents/observability/ai";

const tracedAI = wrapAISDK(ai);

await tracedAI.generateText({
  model,
  prompt: "Find an available appointment",
  runtimeContext: {
    agentId: "booking-agent-production",
    conversationId: "conversation-123",
  },
  telemetry: {
    functionId: "booking-agent",
    includeRuntimeContext: {
      agentId: true,
      conversationId: true,
    },
  },
});

Privacy is handled carefully too: message and tool payload recording is off by default. You have to opt in explicitly once you've confirmed the payloads are safe to store.

const tracedAI = wrapAISDK(ai, {
  storeMessages: true,
  storeTools: true,
});

Setting storeMessages and storeTools to true is what actually turns on payload recording for messages and tool calls.

Wrap-up

Here's today's rundown:

  • Agent Tracing is now available for apps built with the Agents SDK
  • Enable it by setting observability.traces.enabled to true in your Wrangler configuration
  • Think and Flue apps trace automatically; AI SDK users just wrap with wrapAISDK() (works with v6 and v7)
  • Traces cover model calls, tool runs, approvals, token usage, and runtime operations per turn
  • Message and tool payload recording is off by default, opt in with storeMessages / storeTools
  • The Agents tab in the Cloudflare dashboard lets you inspect sessions, replay conversations, and view trace waterfalls

If you're building agents on Cloudflare's Agents SDK, especially ones with complex tool calls or approval flows, this is an update worth trying right away!