Instrument the Codex agent loop on Cloudflare Workers

未关闭
#26,476 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
ai-infra-agents, javascript, typescript

调研方向

Read the related issues #16966, #18910, and #24993, then inspect the existing instrumentAgentWithSentry support and pi-durable instrumentation mentioned in the issue. Reproduce the Cloudflare example with its offline StressModel and a tool-calling turn to confirm which spans are missing. Done means agent runs, Task steps, and direct LanguageModelV4.doStream/doGenerate calls are represented in traces, including aborted and replayed turns.

由索引模型根据 Issue 内容生成。

描述

agents Cloudflare Workers Feature Package: cloudflare
Problem Statement

Cloudflare's Codex agent loop example (changelog) runs the Codex turn loop in a plain DurableObject composed with the Agents SDK Lifecycle, Tasks, Sessions, and Streams capabilities. With @sentry/cloudflare 11.12.0 and sentryCloudflareVitePlugin, a turn runs and request, alarm, and error traces work. The agent loop itself does not show up in traces.

Observed running the example locally in workerd (agents 0.33.0, the example's offline StressModel, a turn with tool calls):

  • No gen_ai spans. The harness calls model.doStream() on the LanguageModelV4 directly, not streamText/generateText, so the Vercel AI integration does not see model calls. Tools run inside the harness, so there are no execute_tool spans either. With a real Workers AI binding, instrumentWorkersAiClient may add bare chat spans (not verified). There would still be no agent or tool spans.
  • The turn is an anonymous alarm trace. Tasks enqueues the turn and a Durable Object alarm runs it. The alarm trace links to the request that scheduled it (previous_trace), but nothing marks it as an agent run or shows its Task run and steps.
  • Lost segment when the object resets. When the Durable Object aborts mid-turn (ctx.abort), the aborted alarm's child spans arrive without their parent alarm segment, and no error is recorded. The replayed run succeeds in a new alarm trace with nothing that ties it to the aborted attempt.
Solution Brainstorm

Starting points, not a design:

  • Recognize Lifecycle.install(this) Durable Objects and the Task runs and steps they execute, the way instrumentAgentWithSentry covers Agent classes and PiHarness is covered for pi-durable.
  • Capture model calls made through LanguageModelV4.doStream/doGenerate, not only through the ai helpers.
Additional Context

Related: getsentry/sentry-javascript#16966, getsentry/sentry-javascript#18910, getsentry/sentry-javascript#24993

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

via Jan Peer Stöcklmair.

--

View Session [Sentry]

主要语言
TypeScript
星标
8.8k
派生
1.9k
平均合并
1 天 8 小时
30 天内合并 PR
744

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。