Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/tracing/vercel-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes';
import {
AI_MODEL_ID_ATTRIBUTE,
AI_OPERATION_ID_ATTRIBUTE,
AI_PROMPT_MESSAGES_ATTRIBUTE,
AI_PROMPT_TOOLS_ATTRIBUTE,
AI_RESPONSE_OBJECT_ATTRIBUTE,
Expand Down Expand Up @@ -65,8 +66,9 @@ function onVercelAiSpanStart(span: Span): void {
return;
}

// Check if this is a Vercel AI span by name pattern.
Copy link

Choose a reason for hiding this comment

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

V6 tool call spans incorrectly processed as generate spans

High Severity

The tool call span check at line 64 requires name === 'ai.toolCall'. If V6 tool call spans also have "default" as their name (like other V6 spans), they will fail this check but pass the new V6 detection at line 71, causing them to be incorrectly processed by processGenerateSpan instead of processToolCallSpan. This breaks tool call error linking via toolCallSpanMap and applies wrong attribute transformations.

Additional Locations (1)

Fix in Cursor Fix in Web

if (!name.startsWith('ai.')) {
// V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.
// V5+ Check if this is a Vercel AI span by name pattern.
if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {
Copy link

Choose a reason for hiding this comment

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

V6 streaming spans incorrectly marked as non-streaming

Medium Severity

The ai.streaming attribute is set based on name.includes('stream'), which relies on V5 naming conventions where span names contain "stream" (e.g., ai.streamText). For V6 spans with a "default" name, this check will always return false, causing streaming operations to be incorrectly marked as ai.streaming = false. The fix allows V6 spans to be processed, but this downstream logic wasn't updated to handle V6 naming.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

V6 spans missing sentry.op attribute

Medium Severity

The getSpanOpFromName(name) function relies on V5 naming conventions and returns undefined for V6 spans with non-standard names like "default". Since the op is only set when getSpanOpFromName returns a truthy value, V6 spans will not have SEMANTIC_ATTRIBUTE_SENTRY_OP set, which could affect span categorization and display in Sentry.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

V6 spans missing op attribute after filter bypass

Medium Severity

The filter change at line 71 allows v6 spans with AI_OPERATION_ID_ATTRIBUTE through, but processGenerateSpan still relies on the span name for determining the sentry.op via getSpanOpFromName(). For v6 spans with a "default" name, getSpanOpFromName('default') returns undefined, so no op attribute is set. Additionally, name.includes('stream') will always be false for "default" names, and the span name won't be updated with the model ID since the switch statement only matches ai.* patterns. The fix allows v6 spans through but doesn't update the processing logic to use AI_OPERATION_ID_ATTRIBUTE or OPERATION_NAME_ATTRIBUTE for determining span characteristics.

Fix in Cursor Fix in Web

return;
}

Expand Down
Loading