Agent tracing is now available for applications built with the Agents SDK. Traces show each agent turn alongside model calls, tool runs, approvals, token usage, and Workers runtime operations.
Turn on Workers tracing in your Wrangler configuration:
{
"$schema": "./node_modules/wrangler/config-schema.json",
"observability": {
"traces": {
"enabled": true
}
}
}
[observability.traces]
enabled = true
Think and Flue applications emit agent traces automatically. For direct AI SDK calls, wrap the AI SDK namespace once. wrapAISDK() supports AI SDK v6 and v7. This AI SDK v7 example also supplies the agent identity:
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,
},
},
});
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,
},
},
});
Message and tool payload recording is off by default. Turn it on only when the payloads are safe to store:
const tracedAI = wrapAISDK(ai, {
storeMessages: true,
storeTools: true,
});
const tracedAI = wrapAISDK(ai, {
storeMessages: true,
storeTools: true,
});
Open the Agents tab ↗ in the Cloudflare dashboard to inspect sessions, replay conversations, and view trace waterfalls. For advanced setup, privacy controls, and trace structure, refer to Agent tracing.
Source: Cloudflare


