Skip to content

feat(server-utils): Add pi-ai integration - #25937

Open
mydea wants to merge 2 commits into
ref/pi-ai-chat-span-helpersfrom
feat/pi-ai-integration-opt-in
Open

mydea wants to merge 2 commits into
ref/pi-ai-chat-span-helpersfrom
feat/pi-ai-integration-opt-in

Conversation

@mydea

@mydea mydea commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

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 piAiIntegration that 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.ts and orchestrion/config/pi-ai.ts. complete* awaits stream*, and compat.stream hands some models to a Models of 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:

  • 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 not enabled by default yet: add Sentry.piAiIntegration() to integrations. It 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.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 06db3de (PR test merge using develop at 6eea71c)

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

⚠️ Baseline mismatch: 3 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 6eea71c 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.19 kB +0.2% +309 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.56 kB +0.19% +250 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 gen-ai-libraries (latest) Test (optional) Failing after 29s Details
❌ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Failing after 26s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Failing after 2m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 54s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 16s Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 17s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 19s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 19s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 59s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 17s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details

mydea and others added 2 commits October 30, 2026 13:53
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
mydea force-pushed the feat/pi-ai-integration-opt-in branch from 0f24663 to 650c252 Compare October 30, 2026 12:54
@mydea
mydea marked this pull request as ready for review October 30, 2026 13:19
@mydea
mydea requested review from a team as code owners October 30, 2026 13:19
@mydea
mydea requested review from andreiborza, chargome, isaacs and nicohrubec and removed request for a team October 30, 2026 13:19

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

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.

2 participants