Skip to content

feat(attributes): Add Vercel AI runtime and tool context attributes - #756

Merged
isaacs merged 3 commits into
mainfrom
isaacs/add-vercel-ai-context-objects
Oct 30, 2026
Merged

isaacs merged 3 commits into
mainfrom
isaacs/add-vercel-ai-context-objects

Conversation

@isaacs

@isaacs isaacs commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Add vercel.ai.settings.context.<key> and vercel.ai.tool_call.context.<key>.

ai 7 removed telemetry.metadata. Per-call metadata now goes in runtimeContext and toolsContext. The app opts keys into telemetry with telemetry.includeRuntimeContext and
telemetry.includeToolsContext. The Vercel AI integration in sentry-javascript records the included keys on gen_ai spans (getsentry/sentry-javascript#25774).

The runtime context name matches @ai-sdk/otel, which emits ai.settings.context.<key>, under the usual ai.* to vercel.ai.* renaming. @ai-sdk/otel does not record tool context, so the tool context name uses snake_case for its fixed segments.

The type is string, as for vercel.ai.telemetry.metadata.<key>. Context values can have any type, so SDKs convert them to strings.

ai versions before 7.0.114 publish the full context on the ai:telemetry channel and ignore the include lists. The attributes tell SDKs to read context only from events that carry aiVersion (added in ai 7.0.154), so keys the app did not opt in are not sent.

Related: getsentry/sentry-javascript#24706

Add `vercel.ai.settings.context.<key>` and
`vercel.ai.tool_call.context.<key>`.

`ai` 7 removed `telemetry.metadata`. Per-call metadata now goes in
`runtimeContext` and `toolsContext`. The app opts keys into telemetry
with `telemetry.includeRuntimeContext` and
`telemetry.includeToolsContext`. The Vercel AI integration in
sentry-javascript records the included keys on gen_ai spans
(getsentry/sentry-javascript#25774).

The runtime context name matches `@ai-sdk/otel`, which emits
`ai.settings.context.<key>`, under the usual `ai.*` to `vercel.ai.*`
renaming. `@ai-sdk/otel` does not record tool context, so the tool
context name uses snake_case for its fixed segments.

The type is `string`, as for `vercel.ai.telemetry.metadata.<key>`.
Context values can have any type, so SDKs convert them to strings.

`ai` versions before 7.0.114 publish the full context on the
`ai:telemetry` channel and ignore the include lists. The attributes
tell SDKs to read context only from events that carry `aiVersion`
(added in `ai` 7.0.154), so keys the app did not opt in are not sent.

Related: getsentry/sentry-javascript#24706

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-conventions Ready Ready Preview Oct 30, 2026 5:29pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Attributes

  • Add Vercel AI runtime and tool context attributes by isaacs and claude in #756
  • Register user.geo.subregion and deprecated sentry.user.geo.subregion by edwardgou-sentry in #753
  • Add faas.instance attribute by pabloDeputter in #748
  • Add faas.document.* attributes by pabloDeputter in #747
  • Add page.server_rendering.type attribute by s1gr1d in #740

Internal Changes 🔧

  • Deprecate gen_ai.handoff op by alexander-alderman-webb in #754

🤖 This preview updates automatically when you update the PR.

@Lms24 Lms24 left a comment

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.

Thanks! LGTM from my PoV but would appreciate someone more versed in gen_ai telemetry taking another look!

@alexander-alderman-webb alexander-alderman-webb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No strong opinion on this. I don't think there's overlap with existing gen_ai.* attributes.

@isaacs
isaacs merged commit 41d8018 into main Oct 30, 2026
18 checks passed
@isaacs
isaacs deleted the isaacs/add-vercel-ai-context-objects branch October 30, 2026 17:34
isaacs added a commit to getsentry/sentry-javascript that referenced this pull request Oct 30, 2026
…el AI spans (#25774)

On `ai` 7 the `telemetry.metadata` option is gone. Per-call metadata
goes in `runtimeContext`, and the app opts keys into telemetry with
`telemetry.includeRuntimeContext` (and `includeToolsContext` for tool
context). The channel subscriber did not read either field, so there was
no way to put request-level data on gen_ai spans.

The subscriber now records each included `runtimeContext` key as
`vercel.ai.settings.context.<key>` on the operation span and on its
`generate_content` and `execute_tool` child spans. It records each
included `toolContext` key as `vercel.ai.toolCall.context.<key>` on the
`execute_tool` span. The `runtimeContext` names match `@ai-sdk/otel`
(`ai.settings.context.*`) under the usual `ai.*` to `vercel.ai.*`
renaming.

`ai` before 7.0.114 published the full context to the channel and
ignored the include lists. A filtered context looks the same as an
unfiltered one, so the subscriber only reads context from events that
carry `aiVersion`, which `ai` added in 7.0.154. Older 7.x versions
record no context, so keys the app did not opt in never leave it.

Fixes #24706
Fixes JS-3788
Refs getsentry/sentry-conventions#756

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 728dd799 Deployed Oct 30, 2026 by vercel[bot]
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.

3 participants