Skip to content

feat(server-utils): Enable pi-ai by default & use it for flue & pi-durable - #25940

Open
mydea wants to merge 2 commits into
feat/pi-ai-integration-opt-infrom
feat/pi-ai-integration-default
Open

mydea wants to merge 2 commits into
feat/pi-ai-integration-opt-infrom
feat/pi-ai-integration-default

Conversation

@mydea

@mydea mydea commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

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.

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 feat(attributes): Add gen_ai conversation compaction conventions 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 (@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.

    Once pi-ai has sent a request, the openai, @anthropic-ai/sdk, @google/genai and Workers AI integrations stop recording requests for the rest of the process, because pi-ai sends its requests through those clients. An app that also calls those SDKs directly no longer gets spans for those calls.

    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.
    • pi-durable records model calls only for a models object created with pi-ai's createModels().

🤖 Generated with Claude Code

@mydea
mydea added this pull request to stack #25938 October 30, 2026 11:04
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 952e2bf (PR test merge using develop at 06db3de)

Against: 446679d (develop) · base run #64414

⚠️ Baseline mismatch: 6 develop commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once develop's baseline build for 06db3de finishes.

Path Size % Change Change
@sentry/browser 30.39 kB - -
@sentry/browser - with treeshaking flags 28.53 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.42 kB - -
@sentry/browser (incl. Tracing) 52.7 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.71 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.68 kB - -
@sentry/browser (incl. Tracing, Replay) 93.01 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.6 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.75 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.74 kB - -
@sentry/browser (incl. Feedback) 47.97 kB - -
@sentry/browser (incl. sendFeedback) 35.49 kB - -
@sentry/browser (incl. FeedbackAsync) 40.6 kB - -
@sentry/browser (incl. Metrics) 31.42 kB - -
@sentry/browser (incl. Logs) 31.72 kB - -
@sentry/browser (incl. Metrics & Logs) 32.44 kB - -
@sentry/react 32.27 kB - -
@sentry/react (incl. Tracing) 55.07 kB - -
@sentry/vue 38.66 kB - -
@sentry/vue (incl. Tracing) 55.72 kB - -
@sentry/svelte 30.42 kB - -
@sentry/remix (Remix 3 client bundle) 57.79 kB - -
CDN Bundle 32.18 kB - -
CDN Bundle (incl. Tracing) 53.23 kB - -
CDN Bundle (incl. Logs, Metrics) 34.45 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.17 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.86 kB - -
CDN Bundle (incl. Tracing, Replay) 91.44 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.56 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.55 kB - -
CDN Bundle - uncompressed 94.62 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.58 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.09 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.31 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.65 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 279.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 284.99 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 298.69 kB - -
@sentry/nextjs (client) 57.87 kB - -
@sentry/sveltekit (client) 53.22 kB - -
@sentry/core/server 44.24 kB - -
@sentry/core/browser 13.93 kB - -
@sentry/node 155.14 kB +0.17% +255 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.21 kB +0.16% +128 B 🔺
@sentry/node - without tracing 96.38 kB +0.18% +173 B 🔺
@sentry/node - without channel injection 135.52 kB +0.16% +212 B 🔺
@sentry/aws-serverless 104.57 kB +0.18% +179 B 🔺
@sentry/cloudflare (withSentry) - minified 197.89 kB - -
@sentry/cloudflare (withSentry) 491.86 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 218.31 kB - -

View base workflow run

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 3 not successful, 49 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Failing after 31s Details
❌ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Failing after 31s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Failing after 2m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 19s Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 51s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 17s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 16s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 19s Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 16s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 20s Details

@mydea
mydea force-pushed the feat/pi-ai-integration-default branch from 7f58fd6 to 91831f6 Compare October 30, 2026 12:53
mydea and others added 2 commits October 30, 2026 13:53
Enables `piAiIntegration` by default. Flue and pi-durable send their model
calls through pi-ai, so they no longer open chat spans of their own: Flue drops
its turn spans and hands the conversation id to the pi-ai span through the
scope, and pi-durable drops its `models` proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Flue's model calls are now traced by the pi-ai integration, which needs the
module hook or bundler plugin, while `instrument()` does not. Without them a
Flue app would silently lose its `gen_ai.chat` spans; it now gets a warning on
its first model call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mydea
mydea force-pushed the feat/pi-ai-integration-default branch from 91831f6 to c5e394f Compare October 30, 2026 12:54
@mydea
mydea marked this pull request as ready for review October 30, 2026 13:21
@mydea
mydea requested review from a team as code owners October 30, 2026 13:21
@mydea
mydea requested review from andreiborza, chargome, isaacs, logaretm, msonnb and nicohrubec and removed request for a team October 30, 2026 13:21
@mydea mydea changed the title feat(server-utils): Trace Flue and pi-durable model calls through pi-ai feat(server-utils): Enable pi-ai by default & use it for flue & pi-durable Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant