Cloudflare Agent Tracing Exposes Models, Tools and Token Usage
Introduction
An Agent returning HTTP 200 does not necessarily mean that it worked correctly. It may have selected the wrong tool, passed stale context to a subagent, or entered a retry loop that keeps consuming tokens. Conventional application telemetry can show a Fetch request, KV read, or D1 query, but it rarely explains which agent decision caused the problem. Cloudflare’s Agent Tracing is designed to provide that missing runtime view.
Tracking agent behavior, not just infrastructure
Built on Workers Tracing, Agent Tracing adds agent-level spans for each interaction. A trace can show an agent invocation followed by a model call, tool execution, and tool approval, with model information and token usage attached as metadata. Subagent work is nested beneath the operation that initiated it. If a parent agent delegates a task and the subagent calls a model, executes a tool, reads D1, and writes to KV, the complete sequence appears as one waterfall across both levels.
The dashboard uses three fields to connect spans with an agent: Agent name identifies the logical implementation, Agent ID identifies a specific instance, and Conversation ID identifies a session. Cloudflare warns against generating Agent name dynamically from request or user identifiers, since that would fragment the dashboard into a large number of agents.
Session Replay can reconstruct recorded data across multiple interaction turns, including messages, reasoning steps, tool arguments and results, and subagent activity. It replays stored information; it does not execute the Agent again. Approval spans also have a specific limitation: they cover lifecycle events inside a Worker invocation, not the time a user spends responding across multiple invocations. As a result, they do not represent the full human-in-the-loop delay.
Payload defaults deserve careful review
The most important operational difference may be the default payload policy:
- Think does not store message or tool payloads unless
storeMessagesandstoreToolsare enabled in the Agent class. wrapAISDK()follows the same default behavior.- Flue stores messages, system instructions, tool definitions, arguments, and results by default;
content: falseis required to stop recording them.
Those fields can contain personal data, secrets, or internal instructions. Teams should therefore review recording scope, redaction, retention, and access controls before enabling the feature broadly.
Truncation, integration and cost
Cloudflare says a Trace is not a complete, lossless conversation record. Span size limits can truncate long messages, reasoning content, tool arguments, and tool results. Session Replay also does not display images. The feature is therefore better suited to debugging than to serving as a complete audit archive.
Think and Flue v2 or later instrument each interaction automatically. Direct AI SDK users must wrap calls with wrapAISDK(), providing identity fields because no Agent instance is available to supply them. Custom harnesses need the Workers Custom Spans API and should follow OpenTelemetry’s GenAI semantic conventions. Traces can be exported to any OTLP endpoint, although Workers does not yet directly support the OpenTelemetry API; Cloudflare says that support is in development.
The beta is free. Starting October 1, 2026, Agent Tracing will enter the Workers Observability billing system. Workers Free includes 200,000 Events per day with three days of retention, while Workers Paid includes 20 million Events per month with seven days of retention. Additional usage costs $0.60 per million Events. Every span counts toward usage, including SDK-generated and other Worker-level spans that may not appear in the Agents view.
Why it matters
The release reflects a broader shift: agent runtimes need telemetry that captures decisions, not only infrastructure activity. Developers can now inspect model selection, tool parameters, approval points, and token consumption in one flow. Yet privacy defaults, incomplete approval timing, truncation, retention, and event-based billing mean that observability must be designed alongside security and cost controls.
Source: InfoQ Chinese
Comments
Checking sign-in status...
Loading comments...