Repository navigation
feat(server-utils): Add pi-ai integration - #25937
Merged
mydea merged 2 commits intoNov 12, 2026
Merged
Conversation
Contributor
size-limit report 📦Compared: a62dd4f (PR test merge using develop at 27a41ad) Against: 2b878f1 (develop) · base run #65743
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 5 not successful, 50 successful. See the run.
Successful checks
|
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
from
October 30, 2026 12:53
76ee3f1 to
0f24663
Compare
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
from
October 30, 2026 12:54
0f24663 to
650c252
Compare
mydea
marked this pull request as ready for review
October 30, 2026 13:19
mydea
requested review from
andreiborza,
chargome,
isaacs and
nicohrubec
and removed request for
a team
October 30, 2026 13:19
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
from
November 3, 2026 12:09
650c252 to
f3eb138
Compare
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
from
November 4, 2026 10:03
f3eb138 to
2a02e07
Compare
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
from
November 10, 2026 08:08
2a02e07 to
f05f6d2
Compare
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
2 times, most recently
from
November 11, 2026 14:41
4191444 to
65b1613
Compare
Traces requests sent with `@earendil-works/pi-ai` as `gen_ai.chat` spans, from the `Models` methods and the standalone `compat` functions. Opt-in for now: Flue and pi-durable still record their own chat spans for the same requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mydea
force-pushed
the
feat/pi-ai-integration-opt-in
branch
from
November 11, 2026 15:25
65b1613 to
94329d1
Compare
mydea
added a commit
that referenced
this pull request
Nov 12, 2026
…rable (#25940) **Why:** Flue and pi-durable both send their model calls through pi-ai, and each had its own chat-span code (Flue's turn observations, pi-durable's `models` proxy). With `piAiIntegration` (#25937) enabled by default, pi-ai becomes the single source of `gen_ai.chat` spans, and ~1.1k lines of duplicated span code go away. Flue now hands its conversation id to the pi-ai span through the scope. Stack: #25932 → #25937 → this. #25935 must be merged before #25937 and this: without it, instrumenting pi-ai makes the Cloudflare Flue worker crash at startup. Supersedes #25869. **How to review:** The first commit is the switch. The second adds a one-time warning when Flue runs but pi-ai was not instrumented; it's separate so it can be dropped or split off. The next three scope the provider skip to pi-ai's own requests, make that warning runtime-specific, and keep the Flue and pi-durable recording options working on chat spans. The last two are cleanups: the active pi-ai span replaces the nesting counter, which also catches nested calls made after an `await`, and stale comments go. **Unsure about:** - Chat spans change origin from `auto.ai.flue` / `auto.ai.pi_durable` to `auto.ai.pi_ai`. - Flue's chat spans now need the runtime hook or bundler plugin; a manual-only `instrument(createFlueInstrumentation())` keeps agent and tool spans but loses chat spans, hence the warning. Setups following our docs are unaffected. - `flue.turn.purpose` (compaction vs. agent turn) is dropped, since pi-ai cannot see it. A possible follow-up is to record compaction the way getsentry/sentry-conventions#723 proposes, once it merges: Flue emits `compaction_start` (with a `manual`/`threshold`/`overflow` reason) and `compaction` observations, so it could open a `gen_ai.compact` span with the summarizing `gen_ai.chat` nested under it. - pi-durable records model calls only for a `models` object created with pi-ai's `createModels()`. **Release note:** > - **feat(server-utils): Add pi-ai integration** > > The new `piAiIntegration` traces requests sent with [pi-ai](https://github.com/earendil-works/pi) (`@earendil-works/pi-ai` >= 0.80) as `gen_ai.chat` spans, through `createModels()` or the standalone `stream`/`complete` functions. It is enabled by default and needs the Sentry runtime hook or bundler plugin. > > Requests pi-ai sends are reported once, as its `gen_ai.chat` span; direct calls to `openai`, `@anthropic-ai/sdk`, `@google/genai`, `@mistralai/mistralai` or Workers AI keep their own spans. > > Flue and pi-durable send their model calls through pi-ai, so their `gen_ai.chat` spans now come from this integration: > - Their origin changes from `auto.ai.flue` / `auto.ai.pi_durable` to `auto.ai.pi_ai`. Agent and tool spans keep their origin. > - Flue apps that only call `instrument(Sentry.createFlueInstrumentation())` need the runtime hook (`--import`) or bundler plugin for `gen_ai.chat` spans. Without it, the SDK logs a warning on the first model call. > - The `flue.turn.purpose` attribute is no longer set. > - `recordInputs` and `recordOutputs` on `createFlueInstrumentation()` and `piDurableIntegration()` keep applying to their `gen_ai.chat` spans. > - pi-durable records model calls only for a `models` object created with pi-ai's `createModels()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
51 tasks done
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.
Why: pi-ai had no instrumentation of its own. Only Flue and pi-durable traced its requests, each with its own chat spans. This adds a
piAiIntegrationthat traces every pi-ai request, so direct users are covered and both frameworks can later drop their chat-span code. The version range starts at 0.80 because Flue 2.0–2.2 depend on pi-ai 0.83–0.87.It's opt-in in this PR: Flue and pi-durable still record their own chat spans for the same requests, so enabling it next to them reports each call twice. The follow-up switches both frameworks over to it and enables it by default (it's on the coverage test's opt-in list until then).
Split out of #25869, stacked on #25932, whose helpers it uses.
How to review: Start with
integrations/pi-ai.tsandorchestrion/config/pi-ai.ts.complete*awaitsstream*, andcompat.streamhands some models to aModelsof its own, so a traced call can make another one synchronously. A depth counter gives only the outermost call a span.Merge after #25935. With pi-ai in the orchestrion config, the Cloudflare Flue worker crashes at startup (
Cannot access 'ModelsImpl' before initialization) through the import cycle #25935 removes.Release note:
🤖 Generated with Claude Code