Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Attributes
Other
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
mydea
added a commit
to getsentry/sentry-javascript
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 <[email protected]> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
This branch was successfully deployed
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 conventions for tracing GenAI conversation context compaction:
gen_ai.compactspan op and a new well-knowngen_ai.operation.namevaluecompact, for the operation that compacts a conversation's context (for example, summarizing earlier messages to fit the context window). Neither is in OpenTelemetry. The op also gets "Compaction" span name and description groups, andgen_ai.operation.typedocuments that compact spans map toother.gen_ai.conversation.compaction.reason(string, Sentry-specific) is set on thegen_ai.compactspan and records what triggered it, for examplemanual,thresholdoroverflow.gen_ai.conversation.compacted(boolean, from the OpenTelemetry definition) is set on later requests that run on the compacted context. Instrumentations set it totrueonly when compaction was reliably applied and leave it unset otherwise, neverfalse.The resulting trace shape is a
gen_ai.compactspan withgen_ai.conversation.compaction.reason, its childgen_ai.chatspan(s) for the model request that writes the summary, and latergen_ai.chatspans withgen_ai.conversation.compacted. Sentry's coding-agent tracing emits this shape.Relay currently infers
gen_ai.operation.typeai_clientfor unknown operation names, so it needs a follow-up to mapcompacttoother.🤖 Generated with Claude Code