WIP: Implement orchestrion-based instrumentation for vercel-ai v6#21658
WIP: Implement orchestrion-based instrumentation for vercel-ai v6#21658mydea wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3417464. Configure here.
| end(rawCtx) { | ||
| if (!config.lazy) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Sync throw leaves spans open
High Severity
For orchestrion-wrapped async Vercel AI calls (generateText, embed, executeToolCall), a synchronous throw yields start → error → end with no asyncEnd. The error handler only sets span status via failSpan and never ends the span, while the end hook returns immediately when lazy is false, so those spans never finish.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3417464. Configure here.
| void Promise.resolve(completion).then( | ||
| () => finishSpan(ctx, undefined), | ||
| () => finishSpan(ctx, undefined), | ||
| ); |
There was a problem hiding this comment.
StreamText span skips usage enrichment
Medium Severity
For lazy streamText, the subscriber waits for totalUsage/usage on the sync return value, then calls finishSpan with undefined instead of the result object. enrichSpanOnEnd exits when result is not a record, so the invoke_agent span never gets token usage or other fields populated from the stream result after usage settles.
Reviewed by Cursor Bugbot for commit 3417464. Configure here.
| void Promise.resolve(completion).then( | ||
| () => finishSpan(ctx, undefined), | ||
| () => finishSpan(ctx, undefined), | ||
| ); |
There was a problem hiding this comment.
Stream usage rejection omits error
Medium Severity
When streamText's usage/totalUsage promise rejects, the lazy end handler still calls finishSpan in both fulfillment and rejection branches without setting error status. Failed streams can end the invoke_agent span as if they succeeded.
Reviewed by Cursor Bugbot for commit 3417464. Configure here.
| describe.each([ | ||
| ['6', {}, '^6.0.0'], | ||
| ['7', {}, '7.0.0-beta.179'], | ||
| ['7', { USE_ORCHESTRION: '1' }, '7.0.0-beta.179'], |
There was a problem hiding this comment.
Missing v6 orchestrion E2E coverage
Low Severity
This feature adds orchestrion-based Vercel AI v6 instrumentation, but the integration matrix only enables USE_ORCHESTRION for AI v7. AI v6 with orchestrion—the main new subscriber path—is not exercised by the E2E suite.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 3417464. Configure here.


WIP...
This is on top of #21613
When using orchestrion, this replaces the regular
vercelAiIntegrationwith the channel-variant. This today supports vercel ai v6 and v7 (v5/v4 support TBD).Test coverage exists and everything passes. This does not add any event processors etc. anymore, everything works inside of the integrations.
OTEL Spans emitted directly by vercel-ai v6 or below are ignored to avoid double instrumentation.