Skip to content

ref(server-utils): Add orchestrion support for Vercel AI v5#21979

Open
mydea wants to merge 3 commits into
developfrom
fn/vercel-ai-v5
Open

ref(server-utils): Add orchestrion support for Vercel AI v5#21979
mydea wants to merge 3 commits into
developfrom
fn/vercel-ai-v5

Conversation

@mydea

@mydea mydea commented Jul 6, 2026

Copy link
Copy Markdown
Member

This adds orchestrion support for Vercel AI v5 (v6 support already exists).

@mydea mydea self-assigned this Jul 6, 2026
@mydea mydea force-pushed the fn/vercel-ai-v5 branch from 4bbdac5 to f47a718 Compare July 7, 2026 10:12
@mydea mydea force-pushed the fn/vercel-ai-v5 branch from f47a718 to d2d3306 Compare July 7, 2026 10:12

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d2d3306. Configure here.

const parent = resolveModelCallParent();
if (!parent || toolCallSpans.has(parent)) {
return original.apply(this, [input, ...rest]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

streamText v5 tools miss spans

Medium Severity

For Vercel AI v5 under orchestrion, patchToolExecute only opens a tool span when resolveModelCallParent() finds an active operation span. streamText is wired as a synchronous channel, so its invoke_agent span ends as soon as streamText returns, while tool execute runs later during stream consumption. The parent check then fails and tool calls are silently not traced.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d2d3306. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this behaves the same as in v5, things may be emitted weirdly but it's fine to keep consistency with v5 in otel I'd say here.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.24 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.01 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.01 kB - -
@sentry/browser (incl. Tracing, Replay) 85.53 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.14 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.23 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.89 kB - -
@sentry/browser (incl. Feedback) 44.76 kB - -
@sentry/browser (incl. sendFeedback) 32.38 kB - -
@sentry/browser (incl. FeedbackAsync) 37.51 kB - -
@sentry/browser (incl. Metrics) 28.67 kB - -
@sentry/browser (incl. Logs) 28.91 kB - -
@sentry/browser (incl. Metrics & Logs) 29.59 kB - -
@sentry/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.51 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.11 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.24 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.54 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.81 kB - -
CDN Bundle (incl. Tracing, Replay) 85.74 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.03 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.53 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.81 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.96 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.93 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.75 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.13 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.09 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.83 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.78 kB - -
@sentry/nextjs (client) 50.95 kB - -
@sentry/sveltekit (client) 46.65 kB - -
@sentry/core/server 78.38 kB - -
@sentry/core/browser 64.73 kB - -
@sentry/node-core 63.21 kB - -
@sentry/node 123.75 kB +0.01% +1 B 🔺
@sentry/node (incl. diagnostics channel injection) 129.97 kB +0.22% +274 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.72 kB +0.01% +1 B 🔺
@sentry/node - without tracing 74.82 kB - -
@sentry/aws-serverless 85.6 kB - -
@sentry/cloudflare (withSentry) - minified 181.68 kB - -
@sentry/cloudflare (withSentry) 449.39 kB - -

View base workflow run

@mydea mydea marked this pull request as ready for review July 7, 2026 12:35
@mydea mydea requested a review from a team as a code owner July 7, 2026 12:35
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team July 7, 2026 12:35
Comment on lines +23 to +26
...vercelAiEntries('>=5.0.0 <6.0.0', 'generateText', 'generateText', 'Async'),
...vercelAiEntries('>=5.0.0 <6.0.0', 'streamText', 'streamText', 'Sync'),
...vercelAiEntries('>=5.0.0 <6.0.0', 'embed', 'embed', 'Async'),
...vercelAiEntries('>=5.0.0 <6.0.0', 'embedMany', 'embedMany', 'Async'),

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.

q: Why don't we just adjust the ranges for these 4 apis?

Comment on lines +434 to +444
// This runs inside the channel `start` transform (no upstream try/catch), so a throw here would break
// the user's `ai` call. Instrumentation must never do that — degrade to no tool span instead.
try {
for (const [toolName, tool] of Object.entries(tools)) {
if (isRecord(tool)) {
patchToolExecute(toolName, tool as PatchableTool, tools, options);
}
}
} catch {
DEBUG_BUILD && debug.log('Vercel AI orchestrion tool patching failed.');
}

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.

m: Maybe we could move the try/catch inside the loop so we can continue patching tools even if earlier tools fail to patch for whatever reason, wdyt?

Or does one failure indicate we can never patch the other tools anyway?

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