Skip to content

WIP: Implement orchestrion-based instrumentation for vercel-ai v6#21658

Draft
mydea wants to merge 1 commit into
fn/vercel-ai-v7from
fn/try-orchestrion
Draft

WIP: Implement orchestrion-based instrumentation for vercel-ai v6#21658
mydea wants to merge 1 commit into
fn/vercel-ai-v7from
fn/try-orchestrion

Conversation

@mydea

@mydea mydea commented Jun 19, 2026

Copy link
Copy Markdown
Member

WIP...

This is on top of #21613

When using orchestrion, this replaces the regular vercelAiIntegration with 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.

@mydea mydea self-assigned this Jun 19, 2026

@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 4 potential issues.

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 3417464. Configure here.

end(rawCtx) {
if (!config.lazy) {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sync throw leaves spans open

High Severity

For orchestrion-wrapped async Vercel AI calls (generateText, embed, executeToolCall), a synchronous throw yields starterrorend 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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3417464. Configure here.

void Promise.resolve(completion).then(
() => finishSpan(ctx, undefined),
() => finishSpan(ctx, undefined),
);

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 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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3417464. Configure here.

void Promise.resolve(completion).then(
() => finishSpan(ctx, undefined),
() => finishSpan(ctx, undefined),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

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'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 3417464. Configure here.

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