ref(server-utils): Add orchestrion support for Vercel AI v5#21979
ref(server-utils): Add orchestrion support for Vercel AI v5#21979mydea wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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]); | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit d2d3306. Configure here.
There was a problem hiding this comment.
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.
size-limit report 📦
|
| ...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'), |
There was a problem hiding this comment.
q: Why don't we just adjust the ranges for these 4 apis?
| // 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.'); | ||
| } |
There was a problem hiding this comment.
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?


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