Skip to content

Conversation

@RulaKhaled
Copy link
Member

@RulaKhaled RulaKhaled commented Jan 20, 2026

Introduces a new Sentry.setConversationId() API to track multi turn AI conversations across API calls.

We want to leverage each AI frameworks built-in functionalities wherever possible. OpenAIs conversation_id, sessions, etc to create the gen_ai.conversation.id attribute.
However if the framework does not provide such a mechanism (such as Google GenAI or Anthropic) we shall provide a common function: Sentry.setConversationId(...) or sentry_sdk.set_conversation_id(), which adds the conversation ID to the Scope in a similar way as Sentry.setUser() and sentry_sdk.set_user() do. When provided in such a way it will override any automatically detected value.

Why not just add this as an attribute?
it should only appear as a span attribute, not propagate to logs and metrics. This keeps AI conversation context isolated to spans where it's semantically relevant.

@linear
Copy link

linear bot commented Jan 20, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.3 kB +0.37% +93 B 🔺
@sentry/browser - with treeshaking flags 23.81 kB +0.43% +101 B 🔺
@sentry/browser (incl. Tracing) 42.19 kB +0.41% +170 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.8 kB +0.32% +149 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.79 kB +0.21% +163 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.44 kB +0.24% +162 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.49 kB +0.2% +163 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.69 kB +0.17% +160 B 🔺
⛔️ @sentry/browser (incl. Feedback) (max: 42 kB) 42.02 kB +0.22% +92 B 🔺
@sentry/browser (incl. sendFeedback) 29.98 kB +0.3% +88 B 🔺
@sentry/browser (incl. FeedbackAsync) 34.99 kB +0.3% +102 B 🔺
@sentry/browser (incl. Metrics) 26.42 kB +0.43% +112 B 🔺
@sentry/browser (incl. Logs) 26.55 kB +0.35% +91 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.23 kB +0.42% +113 B 🔺
⛔️ @sentry/react (max: 27 kB) 27.03 kB +0.37% +97 B 🔺
@sentry/react (incl. Tracing) 44.42 kB +0.38% +164 B 🔺
@sentry/vue 29.81 kB +0.56% +165 B 🔺
@sentry/vue (incl. Tracing) 43.98 kB +0.39% +167 B 🔺
@sentry/svelte 25.31 kB +0.36% +89 B 🔺
CDN Bundle 27.88 kB +0.37% +101 B 🔺
CDN Bundle (incl. Tracing) 42.96 kB +0.31% +131 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 43.78 kB +0.31% +134 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.66 kB +0.17% +130 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.13 kB +0.19% +159 B 🔺
⛔️ CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) (max: 86 kB) 86.04 kB +0.19% +157 B 🔺
CDN Bundle - uncompressed 81.55 kB +0.36% +285 B 🔺
⛔️ CDN Bundle (incl. Tracing) - uncompressed (max: 127 kB) 127.24 kB +0.34% +427 B 🔺
⛔️ CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed (max: 130 kB) 130.07 kB +0.33% +427 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 243.78 kB +0.18% +427 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 256.57 kB +0.17% +427 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 259.38 kB +0.17% +427 B 🔺
@sentry/nextjs (client) 46.78 kB +0.34% +158 B 🔺
@sentry/sveltekit (client) 42.56 kB +0.41% +171 B 🔺
@sentry/node-core 52 kB +0.19% +98 B 🔺
@sentry/node 165.61 kB +0.12% +197 B 🔺
@sentry/node - without tracing 93.76 kB +0.11% +103 B 🔺
@sentry/aws-serverless 109.27 kB +0.1% +108 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,830 - 8,959 -1%
GET With Sentry 1,709 19% 1,585 +8%
GET With Sentry (error only) 5,831 66% 6,016 -3%
POST Baseline 1,172 - 1,171 +0%
POST With Sentry 579 49% 570 +2%
POST With Sentry (error only) 1,045 89% 1,030 +1%
MYSQL Baseline 3,241 - 3,248 -0%
MYSQL With Sentry 426 13% 358 +19%
MYSQL With Sentry (error only) 2,615 81% 2,590 +1%

View base workflow run

@RulaKhaled RulaKhaled changed the title wip(ai): Support scope-level conversation ID for AI tracing feat(core): Add scope-level conversation ID API to support linking AI conversations Jan 21, 2026
@RulaKhaled RulaKhaled requested a review from Lms24 January 21, 2026 15:18
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.

2 participants