Repository navigation
feat(server-utils): Add instrumentation for pi-durable - #24993
Merged
Merged
Conversation
JPeer264
added this pull request to stack #25002
October 2, 2026 13:14
Contributor
size-limit report 📦
|
JPeer264
removed this pull request from stack #25002
October 2, 2026 13:31
JPeer264
changed the base branch from
jp/flue-map-messages-conventions
to
jp/bun-conversation-id-integration
October 2, 2026 13:39
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 2, 2026 13:39
1dad424 to
91a0b35
Compare
JPeer264
added this pull request to stack #25004
October 2, 2026 13:57
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 2, 2026 16:59
91a0b35 to
26d39c9
Compare
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 3, 2026 16:23
26d39c9 to
4fc5960
Compare
JPeer264
removed this pull request from stack #25004
October 5, 2026 07:21
JPeer264
added this pull request to stack #25029
October 5, 2026 07:22
Member
Author
|
bugbot run |
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 5, 2026 09:44
4fc5960 to
f8eb62c
Compare
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 5, 2026 11:22
f8eb62c to
c8a1208
Compare
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c8a1208. Configure here.
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 5, 2026 12:53
c8a1208 to
189004f
Compare
JPeer264
marked this pull request as ready for review
October 5, 2026 13:24
JPeer264
requested review from
chargome and
s1gr1d
and removed request for
a team
October 5, 2026 13:24
andreiborza
approved these changes
Oct 7, 2026
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 7, 2026 17:03
1cccf5e to
c42eafb
Compare
pi-durable has no telemetry hooks, so `piDurableIntegration` wraps the `models` and `registry` passed to `Harness.open()`. Each run becomes its own `invoke_agent` trace with `chat` and `execute_tool` children, and a subagent run nests under the tool call that started it. Messages are mapped to the gen_ai conventions, and the system prompt and tools are read from pi-durable's positional system messages. Tool spans record the result the model receives. Failures pi-durable only reports, and task phases that throw, are captured. Throws of the built-in coding tools are not, because they report expected results to the model. On Cloudflare it also covers pi-durable in a Durable Object through the Agents SDK `PiHarness`, including requests that pi-ai sends through the Workers AI binding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…hat starts after its parent trace ended
…o the conversations it created
Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com>
JPeer264
force-pushed
the
jp/pi-durable-instrumentation
branch
from
October 8, 2026 11:27
dcb4c47 to
31179ae
Compare
JPeer264
added a commit
that referenced
this pull request
Oct 8, 2026
Cloudflare now hosts pi-durable in Durable Objects through the Agents SDK `PiHarness` ([changelog](https://developers.cloudflare.com/changelog/post/2026-10-02-pi-harness/)). This app runs pi-durable that way, with `@sentry/cloudflare/vite` as the only Sentry setup. It checks that a prompt becomes an `invoke_agent` trace with `chat`, `execute_tool` and provider `http.client` spans, that a throwing tool is reported on its span, and that a run resumes in a new trace after the Durable Object resets during a tool call. The reset uses `ctx.abort()`, which drops the object like an eviction; the next request starts it again, and `PiHarness` resumes pi from its SQLite state. Like `node-pi-durable` and `cloudflare-think`, it calls a real model through OpenRouter, so it is optional. The changelog example uses Workers AI (`createAI({ binding: env.AI })`), but the AI binding needs a Cloudflare account even in local dev, so that path has a unit test in #24993 instead. This app found a bug that #24993 now fixes: `@sentry/cloudflare` initializes the SDK inside each request, so the client is on the scope of that request only. The task phases ran on a copy of the default scope, had no client, and dropped every pi-durable span and error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
47 tasks
1 of 6 tasks
1 of 6 tasks
andreiborza
added a commit
to getsentry/sentry-docs
that referenced
this pull request
Oct 9, 2026
<!-- Keep the urgency section so automation can prioritize this PR. You may delete other sections you don't need. --> ## DESCRIBE YOUR PR Adds a dedicated `javascript.pi-durable` platform guide for the Pi Durable integration added in getsentry/sentry-javascript#24993 (see also the [Pi Durable announcement](https://earendil.com/posts/pi-durable/)). It follows the same structure as the Flue, Eve, and Mastra guides. - `docs/platforms/javascript/guides/pi-durable/index.mdx`: Node.js setup (preload `instrument.mjs` with `--import`, or use the bundler plugin) - `docs/platforms/javascript/guides/pi-durable/cloudflare.mdx`: Cloudflare setup (`sentryCloudflareVitePlugin()` + `instrument.server.ts`, with an Agents SDK `PiHarness` example) - `includes/pi-durable/`: shared sections covering experimental status, captured telemetry (`gen_ai.invoke_agent` / `gen_ai.chat` / `gen_ai.execute_tool`), conversation IDs across restarts, crash recovery, captured errors, which provider integrations get skipped, current gaps, verification, and next steps - Adds `javascript.pi-durable` to common-page platform lists wherever Mastra appears (install-method pages stay visible, since a Pi Durable app controls its own startup) - Adds a Pi icon (`src/icons/pi-durable.svg`), plus entries on the Agent Tracing index and the Agents getting-started page Bun and Deno are left out for now because their setup couldn't be verified. Only Node and Cloudflare are documented. ## IS YOUR CHANGE URGENT? - [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD - [ ] Other deadline: YYYY-MM-DD - [x] No deadline: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've supplied a deadline. ## PRE-MERGE CHECKLIST - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) <!-- junior-request-attribution:start --> via **Andrei Borza**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0BKK9QLCUA%3A1791533598.406349 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0BKK9QLCUA%3A1791533598.406349) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0BKK9QLCUA%3A1791533598.406349/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Andrei Borza <andrei.borza@sentry.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
piDurableIntegrationfor@earendil-works/pi-durable, Earendil's new durable agent harness. It is on by default in Node, Bun and Deno, and in a Worker built with@sentry/cloudflare/vite, which covers pi-durable in a Durable Object through the Agents SDKPiHarness. Each run becomes its owninvoke_agenttrace withchatandexecute_toolchildren, and the first run of a subagent conversation nests under the tool call that created it.pi-durable has no telemetry hooks (
pi-telemetryexists, but no pi package emits spans through it yet), so the integration hooksHarness.open()and wraps themodelsandregistryit receives. The wrapped options keep the caller's options as prototype, because pi-durable readssettings,envandconversationCreatedat every use.Decisions worth a look:
pi.generationtask after every tool round, so no single task spans a run. The run span ends when the commit that removespi.live.rungoes through, or when the Harness closes with the run in flight.@sentry/cloudflarebinds the client to the scope of each request, not to the default scope.gen_ai.conversation.idis<harness id>:<conversation id>. pi-durable numbers conversations per storage from 1, so the bare id would merge every root conversation into one. The cost is a new id after a restart (on Cloudflare, after every restart of the Durable Object), until pi-durable has a stable storage id.api.output()(all ofbash) and results anafterToolhook redacted.onReport(throwing hooks or sections) and task phases that throw are captured. Throws of the built-in coding tools are not, becausebashthrows for every non-zero exit, a normal result for a coding agent. The built-in tools are recognized by their factories (createBashTool()and friends), so an app that registers them in an extension of its own gets the same treatment. The span keeps its error status.openai,@anthropic-ai/sdkand@google/genaiclients, or through the Workers AI binding withcreateAI()ofagents/models/pi-ai, and those integrations cannot tell pi-ai's calls from the app's own. Bedrock requests go through the AWS SDK, whichawsIntegrationstill reports twice; that skip is a follow-up.Messages, token usage and finish reasons go through the pi-ai mapper from the Flue fix, and the system prompt and tools are replayed from pi-durable's positional system messages.
Not covered yet: spans for tool calls pi-durable answers without running
execute(), spans for custom tasks, agent names (pi-durable has none), a link between a run and the request that submitted it, a marker for compaction requests, and an error event for a failed model request (thechatspan carries the status).🤖 Generated with Claude Code