Glean 拾遗
Daily /2026-08-08 / Introducing Cloudflare Agents: Agent Tracing and Observability

Introducing Cloudflare Agents: Agent Tracing and Observability

Source blog.cloudflare.com Glean’d 2026-08-08 06:01 Read 9 min
AI summary

Cloudflare introduces Cloudflare Agents, a unified console to deploy and manage hosted agents, launching with agent tracing. The feature adds agent-aware spans for model calls, tool executions, approval events, token usage, and supported subagent calls, overlaying existing Workers infrastructure traces (fetch, KV, D1). It is initially compatible with Think, Flue, and AI SDK, with plans to accept OpenTelemetry semantic conventions directly in Workers. Developers can replay recorded sessions to inspect full conversation context, or view execution waterfalls that show subagent delegation and the Cloudflare resources used. Traces can be exported to any OTLP destination, enabling evaluation and analytics. Pricing is based on existing Workers observability events, free during beta and then included in Workers Free/Paid plans. The feature targets teams running agents on Cloudflare who need behavior-level insight beyond traditional telemetry.

Original · 9 min
blog.cloudflare.com ↗
§ 1

We're bringing together everything you need to deploy and manage hosted agents on Cloudflare, starting with observability.

BLOG-3387 2.png

We've spent the last nine years building a developer platform, and agents are the perfect use case. They're really just another type of application, but what you need to build them — model access, durable runtime, orchestration, sandboxed execution, persistent storage — happens to be exactly what we've already built.

Now, we’re making it even easier to deploy and manage your agents on Cloudflare. Cloudflare Agents brings all of your deployed agent sessions into a single experience, surfacing key information and insights into how your agents perform at scale.

我们正在把所有在 Cloudflare 上部署和管理托管 Agent 所需的一切整合到一起,首先从可观测性开始。

BLOG-3387 2.png

过去九年,我们一直在构建开发者平台,而 Agent 正是最合适的用例。它们其实只是另一种类型的应用,但构建它们所需要的——模型访问、持久运行环境、编排、沙箱执行、持久存储——恰好都是我们已经构建好的能力。

现在,我们让在 Cloudflare 上部署和管理 Agent 变得更加容易。Cloudflare Agents 将你所有已部署的 Agent 会话整合到单一体验中,并呈现关键信息和洞见,帮助你了解 Agent 在大规模运行时的表现。

§ 2

We are launching agent tracing for more direct visibility and insight into agent behavior. With agent-aware traces, you can now understand exactly what your agent is doing and what it costs: every model call, tool execution, and token is measured and presented here. Agent tracing launches today with support for OpenTelemetry-compatible agent harnesses including Think, Flue, and AI SDK, and more.

我们正式推出 Agent 追踪,为 Agent 行为提供更直接的可见性和洞察。借助感知 Agent 的追踪,你现在可以准确了解 Agent 在做什么、成本如何:每一次模型调用、工具执行和 token 消耗都会被测量并在此展示。Agent 追踪今日上线,支持兼容 OpenTelemetry 的 Agent 框架,包括 Think、Flue 和 AI SDK,后续还将增加更多。

§ 3

Agent traces are just the beginning. Once you have observability into your agent’s thought process and real-world behavior, you can start to analyze this data and make real improvements. Plug this data into your agent development lifecycle, and you suddenly have autonomous, self-improving agents. This is the vision for Cloudflare Agents: one place to deploy, observe, and continuously improve every agent you run.

Agent 追踪仅仅是个开始。一旦你对 Agent 的思维过程和真实行为有了可观测性,就可以开始分析这些数据并做出实质改进。将这些数据接入 Agent 开发生命周期,你会突然拥有自主、自我改进的 Agent。这正是 Cloudflare Agents 的愿景:在一个地方部署、观察并持续改进你运行的每一个 Agent。

§ 4

An agent can return HTTP 200 and still fail. It may choose the wrong tool, pass stale context to a subagent, or spend tokens in a retry loop. Traditional application telemetry might show the API request or database query, but not the agent behavior that caused it.

Agent-level telemetry should answer questions such as:

  • Where did the time go: the model, the tool, or the infrastructure?
  • Did the turn pause for approval?
  • Which model did the agent call, and how many tokens did the turn use?
  • Did the agent choose the right tool?
  • When the tool called an external API, did it receive a successful response or time out?
  • Which subagent performed the work, and how did that work affect the final response?

Workers tracing already covers the infrastructure layer, including fetch calls, KV reads, and D1 queries, but until now, traces for agents running on Workers contained those infrastructure spans without the agent operations surrounding them. Agent tracing closes that gap, adding spans for agent invocations, model calls, tool execution, approval events, and supported subagent calls alongside the Workers data already captured. You also get context such as the model and token usage attached as metadata.

Starting today, agents built with Think, Flue, and AI SDK will send agent traces to Cloudflare, letting you visualize them in the dashboard or export them to a supported OpenTelemetry-compatible destination.

一个 Agent 可能返回 HTTP 200,但仍然失败了。它可能选错了工具,向子 Agent 传递了过期的上下文,或者在重试循环中浪费 token。传统的应用遥测可能显示 API 请求或数据库查询,但看不到导致问题的 Agent 行为。

Agent 级遥测应当回答这样一些问题:

  • 时间花在了哪里:模型、工具还是基础设施?
  • 这一轮是否因审批而暂停?
  • Agent 调用了哪个模型,这一轮用了多少 token?
  • Agent 是否选择了正确的工具?
  • 当工具调用外部 API 时,收到的是成功响应还是超时?
  • 哪个子 Agent 执行了工作,该工作对最终响应有什么影响?

Workers 追踪已经涵盖了基础设施层,包括 fetch 调用、KV 读取和 D1 查询,但在此之前,运行在 Workers 上的 Agent 的追踪只包含这些基础设施 span,而没有它们周围的 Agent 操作。Agent 追踪弥补了这个缺口,在已捕获的 Workers 数据之外,增加了 Agent 调用、模型调用、工具执行、审批事件以及受支持的子 Agent 调用等 span。你还可以获得像模型和 token 用量这类附加为元数据的上下文。

从今天起,使用 Think、Flue 和 AI SDK 构建的 Agent 会将 Agent 追踪发送到 Cloudflare,让你在仪表盘中可视化它们,或将其导出到受支持的 OpenTelemetry 兼容目的地。

§ 5

The Cloudflare dashboard now has a dedicated Agents view that lists observed agents and their traces alongside runs, sessions, instances, and reported token usage.

BLOG-3387 3.png

When you open an agent, you can visualize, understand, and debug what it’s doing in two ways:

Replay a session to review captured context across all turns

View a trace to inspect the execution of each turn

Cloudflare 仪表盘现在有一个专用的 Agents 视图,列出已观测到的 Agent 及其追踪,以及运行记录、会话、实例和上报的 token 用量。

BLOG-3387 3.png

当你打开一个 Agent 时,可以通过两种方式可视化、理解和调试它所做的事情:

回放一个会话,查看所有轮次中捕获的上下文

查看追踪,检查每一轮的执行情况

§ 6

The Messages tab assembles the full conversation for a given turn: system instructions, user messages, the model's thinking, tool calls with their arguments and results, and the final response. It's a replay of recorded data, not a re-execution of the agent. This lets you catch a malformed tool argument, see the context available when a tool was selected, understand handoff to subagents, or identify how an earlier turn influenced a later result.

BLOG-3387 4.png

In this example, a user asks to plan a two-day trip to Lisbon. You can see the model's reasoning, watch it call destination_researcher twice (it retried), read the tool results, and follow its thinking as it moves on to building the itinerary. If the agent made a bad decision, this is where you find it.

Exactly what gets recorded depends on your harness or framework. For Think, Flue, and the AI SDK, storeMessages and storeTools control whether message and tool payloads are captured. You can turn payload recording off when that data may contain personal information, secrets, or other sensitive data.

Messages 标签页会组装出某一轮对话的完整上下文:系统指令、用户消息、模型的思考过程、工具调用及其参数和结果,以及最终响应。这是对已记录数据的回放,而不是重新执行 Agent。你可以借此发现格式错误的工具参数,查看工具被选中时可用的上下文,理解到子 Agent 的交接,或识别较早的轮次如何影响了后来的结果。

BLOG-3387 4.png

在这个例子中,用户要求规划一次为期两天的里斯本之旅。你可以看到模型的推理过程,观察它两次调用 destination_researcher(它重试了),阅读工具结果,并跟随它的思路继续构建行程。如果 Agent 做出了糟糕的决策,你就能在这里发现。

具体记录哪些内容取决于你的 harness 或框架。对于 Think、Flue 和 AI SDK,storeMessages 和 storeTools 控制是否捕获消息和工具负载。当这些数据可能包含个人信息、密钥或其他敏感数据时,你可以关闭负载记录。

§ 7

The Traces tab shows the execution waterfall, where you can determine how time was spent and connect agent operations to Workers infrastructure.

unnamed (1).png

In this trace, a Travel_Planner agent delegates to an itinerary_builder subagent, which calls a model, runs a tool, hits D1, and writes to KV — all visible in a single waterfall:

  • invoke_agent TravelPlanner: The parent agent invocation, 2.72 minutes total. Identifiers for the agent class, conversation, and Durable Object are attached so you can correlate across traces.
  • invoke_agent itinerary_builder: The subagent, nested under the parent, taking 1.83 minutes of that time.
  • chat @cf/zai-org/glm-4.7-flash: Model calls at each level, with duration and provider-reported token usage attached. The first call (17.59s) was the parent's routing decision; the subagent made its own calls underneath.
  • execute_tool record_itinerary_builder_execution: The tool execution, 104ms.
  • cloudflare-d1 run d1_run: A D1 query triggered by the tool, also 104ms.
  • execute_tool record_respond_ready: The tool execution, 232ms.
  • cloudflare-kv put kv_put: A KV write from a later tool, 232ms.

Workers tracing already instruments bindings such as KV, D1, Durable Object, service-binding, and fetch calls, so the Cloudflare infrastructure used by a tool appears under the agent operation that triggered it. Supported subagent calls nest under the parent when child work runs within the active traced context. That lets you follow a turn from the parent agent, through delegated work, to the Cloudflare resources each agent used.

Traces 标签页显示执行瀑布流,你可以判断时间花在哪里,并将 Agent 操作与 Workers 基础设施关联起来。

unnamed (1).png

在这个追踪中,Travel_Planner Agent 委托给 itinerary_builder 子 Agent,后者调用模型、运行工具、访问 D1 并写入 KV——这一切都在一个瀑布流中可见:

  • invoke_agent TravelPlanner:父 Agent 调用,总计 2.72 分钟。附有 Agent 类、会话和 Durable Object 的标识符,方便你在不同追踪之间关联。
  • invoke_agent itinerary_builder:子 Agent,嵌套在父级之下,占用其中 1.83 分钟。
  • chat @cf/zai-org/glm-4.7-flash:每一层的模型调用,附带持续时间和提供商上报的 token 用量。第一次调用(17.59 秒)是父级的路由决策;子 Agent 在其下进行了自己的调用。
  • execute_tool record_itinerary_builder_execution:工具执行,104 毫秒。
  • cloudflare-d1 run d1_run:由工具触发的 D1 查询,同样为 104 毫秒。
  • execute_tool record_respond_ready:工具执行,232 毫秒。
  • cloudflare-kv put kv_put:来自后续工具的 KV 写入,232 毫秒。

Workers 追踪早已对 KV、D1、Durable Object、service-binding 和 fetch 调用等绑定进行了检测,因此工具所使用的 Cloudflare 基础设施会出现在触发它的 Agent 操作之下。当子任务在活动追踪上下文中运行时,受支持的子 Agent 调用会嵌套在父级之下。这样你就可以从父 Agent 出发,跟踪一轮对话如何经过委托工作,直到每个 Agent 所使用的 Cloudflare 资源。

§ 8

First, enable tracing in wrangler.jsonc, the Worker's project configuration:

{
  "observability": {
    "traces": {
      "enabled": true,
    }
  }
}

Setup after that depends on the stack.

首先,在 Worker 的项目配置文件 wrangler.jsonc 中启用追踪:

{
  "observability": {
    "traces": {
      "enabled": true,
    }
  }
}

之后的设置取决于你使用的技术栈。

§ 9

We’re working to support the OpenTelemetry API directly inside Workers. This means frameworks that already emit OpenTelemetry Generative AI semantic conventions spans will be able to visualize them in the Agents view without waiting for a Cloudflare-specific adapter. When those spans include standard agent and conversation identifiers, the Agents view can group them into agents and sessions just like our built-in integrations. Cloudflare can already export OpenTelemetry data; this adds the other direction by accepting standard telemetry generated inside Workers.

Your agent telemetry isn’t locked into Cloudflare. You can export traces to any OTLP-compatible provider by configuring a destination in your Worker’s Wrangler configuration file. Because every trace is structured, the same data that helps you debug agents can also power evaluations, analytics, and token-usage reporting. This means traces aren’t just something you inspect when things break, but also a feedback loop for improving your agent’s quality, performance, and cost.

我们正在努力让 Workers 直接支持 OpenTelemetry API。这意味着,已经能产生 OpenTelemetry 生成式 AI 语义约定 span 的框架,无需等待 Cloudflare 专用适配器,就能在 Agents 视图中将其可视化。当这些 span 包含标准的 Agent 和会话标识符时,Agents 视图可以像内置集成一样将它们分组为 Agent 和会话。Cloudflare 已经能够导出 OpenTelemetry 数据;这次增加了反向支持,即接受在 Workers 内部产生的标准遥测数据。

你的 Agent 遥测数据并不会被锁定在 Cloudflare 里。你可以通过在 Worker 的 Wrangler 配置文件中配置目的地,将追踪导出到任何兼容 OTLP 的提供商。由于每条追踪都是结构化的,帮助你调试 Agent 的同一份数据也可以用于评估、分析和 token 用量报告。这意味着追踪不仅是在出问题时检查的东西,更是改善 Agent 质量、性能和成本的反馈回路。

§ 10

Agent traces are built on Workers tracing, so pricing is straightforward. The Agents view shows your agent's operations, but the full Worker trace may include additional spans from SDK internals and other Worker-level operations. To see the full trace, click “View in Observability”.

BLOG-3387 7.png

Every span counts as an observability event, not just the ones visible in the Agents view. All tracing is currently free while in beta. Starting October 1, 2026, tracing pricing will be included as part of existing Workers Observability pricing:

Tier Events Retention
Workers Free 200,000 per day 3 days
Workers Paid 20 million included per month; $0.60 per additional million events 7 days

Agent 追踪构建在 Workers 追踪之上,因此定价很直接。Agents 视图显示你的 Agent 操作,但完整的 Worker 追踪可能包含来自 SDK 内部和其他 Worker 级操作的额外 span。要查看完整追踪,请点击“在 Observability 中查看”。

BLOG-3387 7.png

每一个 span 都计入一个可观测性事件,而不仅仅是 Agents 视图中可见的那些。目前,在测试期间,所有追踪都是免费的。从 2026 年 10 月 1 日起,追踪定价将纳入现有 Workers Observability 定价:

层级 事件量 保留时间
Workers Free 每天 200,000 个 3 天
Workers Paid 每月包含 2000 万;每额外 100 万个事件 $0.60 7 天
§ 11

Tracing is the first piece as we keep building out Cloudflare Agents into the place where you easily deploy, observe, and continuously improve every agent you run.

Ready to see what your agents are doing? Check out our documentation to enable observability on your agent and head over to the Agents dashboard to inspect your first trace or replay a session.

追踪只是我们持续建设 Cloudflare Agents 的第一块拼图,目标是在一个地方轻松部署、观察并持续改进你运行的每一个 Agent。

准备好看看你的 Agent 在做什么吗?查阅文档为你的 Agent 启用可观测性,然后前往 Agents 仪表盘查看你的第一条追踪或回放一个会话。

Open source ↗