Title: Agents entered via onRequest never get gen_ai.conversation.id · Issue #22845 · getsentry/sentry-javascript · GitHub
Open Graph Title: Agents entered via onRequest never get gen_ai.conversation.id · Issue #22845 · getsentry/sentry-javascript
X Title: Agents entered via onRequest never get gen_ai.conversation.id · Issue #22845 · getsentry/sentry-javascript
Description: How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using? @sentry/cloudflare SDK Version 10.69.0 Framework Version agents 0.20.0, ai 7.0.37, workers-ai-provider 4.0.0 Reproduction Example/SDK Setup An Agent that handles HTT...
Open Graph Description: How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using? @sentry/cloudflare SDK Version 10.69.0 Framework Version agents 0.20.0, ai 7.0.37, workers-ai-provider 4.0.0 Reproduction Exa...
X Description: How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using? @sentry/cloudflare SDK Version 10.69.0 Framework Version agents 0.20.0, ai 7.0.37, workers-ai-provider 4.0.0 Reproduction Exa...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/22845
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Agents entered via onRequest never get gen_ai.conversation.id","articleBody":"### How do you use Sentry?\n\nSentry SaaS (sentry.io)\n\n### Which SDK are you using?\n\n`@sentry/cloudflare`\n\n### SDK Version\n\n10.69.0\n\n### Framework Version\n\nagents 0.20.0, ai 7.0.37, workers-ai-provider 4.0.0\n\n### Reproduction Example/SDK Setup\n\nAn Agent that handles HTTP requests and makes a model call. No manual Sentry code anywhere:\n\n```ts\n// src/server.ts\nexport const OrderSupportAgent = Sentry.instrumentAgentWithSentry(sentryOptions, OrderSupportAgentBase);\n\nexport default Sentry.withSentry(sentryOptions, {\n async fetch(request, env) {\n return (await routeAgentRequest(request, env)) ?? new Response('Not found', { status: 404 });\n },\n});\n\n// src/agents.ts\nexport class OrderSupportAgentBase extends Agent\u003cEnv> {\n async onRequest(request: Request): Promise\u003cResponse> {\n const body = await request.json();\n return this.runTurn(body); // calls generateText() -> Workers AI\n }\n}\n```\n\n### Steps to Reproduce\n\n1. Deploy the Worker above (`@sentry/cloudflare` 10.69.0, `agents` 0.20.0).\n2. `POST /agents/order-support-agent/\u003cinstance>` — the `agents` router sends this to `onRequest`.\n3. Open the resulting trace in Sentry and look at `gen_ai.conversation.id` on the spans.\n\n### Expected Result\n\nThe `gen_ai` spans carry `gen_ai.conversation.id` set to the agent instance name, the same way\nthey do for a chat turn or a `@callable()` RPC call. That is what the Conversations view groups on.\n\n### Actual Result\n\n`gen_ai.conversation.id` is empty on every span. In my trace: 14 spans (`http.server` ×3,\n`gen_ai.invoke_agent` ×2, `gen_ai.generate_content` ×5, `gen_ai.execute_tool` ×3, `rpc` ×1), none\nof them stamped.\n\nAdding a manual `Sentry.setConversationId()` inside the same agent stamps all of them, so\neverything downstream works — the SDK just never sets the id on this path.\n\n### Additional Context\n\n`setAgentConversationId` (`packages/cloudflare/src/instrumentations/agents/types.ts`) has exactly\ntwo callers:\n\n- `instrumentChatAgentConversation.ts` — the `onChatMessage` proxy\n- `instrumentAgentCallableRpc.ts` — the `onMessage` proxy (`@callable()` over WebSocket)\n\nAn HTTP request reaches the agent through the `obj.fetch` proxy in `durableobject.ts`, which wraps\nthe handler in `wrapRequestHandler` and never calls it. `instance.name` — the value it would use —\nis available on this path too.\n\n`onRequest` isn't an edge case: the `agents` docs list it as one of the two ways into an agent\n(\"HTTP requests via `onRequest()` — REST APIs, webhooks, file uploads\"), and a webhook can't hold\na WebSocket.\n\nWorth noting that `dev-packages/e2e-tests/test-applications/cloudflare-agent/tests/ai-streaming.test.ts`\nalready drives both fixture agents over HTTP and asserts a bunch of `gen_ai.*` attributes — it just\nnever asserts `gen_ai.conversation.id`, which is why CI is green today.\n\nI have a fix and will open a PR against this issue.\n","author":{"url":"https://github.com/sergical","@type":"Person","name":"sergical"},"datePublished":"2026-07-30T03:02:42Z","url":"https://github.com/getsentry/sentry-javascript/issues/22845"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e5e336cb-d86c-de91-6f37-0e12ffac56fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED8E:34FCD3:2EE1E:3E7B3:6B042BC1 |
| html-safe-nonce | 5b6e1390b51fdcb0418bd9b6ef89a35f3c6151b7cd5e6c744c9fa6ccebee4f07 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDhFOjM0RkNEMzoyRUUxRTozRTdCMzo2QjA0MkJDMSIsInZpc2l0b3JfaWQiOiI3NjUwMzYwNDUyODM2NTAyNDY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6870131f6139060b302822003f3579812a771c7a3fa1a44f0accb027c2258ffd |
| hovercard-subject-tag | issue:5015636775 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/22845/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5b422eec28fede3889b10fde16f75ae40b06651a6d34365c1e07c467b39daa72/getsentry/sentry-javascript/issues/22845 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5b422eec28fede3889b10fde16f75ae40b06651a6d34365c1e07c467b39daa72/getsentry/sentry-javascript/issues/22845 |
| og:image:alt | How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using? @sentry/cloudflare SDK Version 10.69.0 Framework Version agents 0.20.0, ai 7.0.37, workers-ai-provider 4.0.0 Reproduction Exa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sergical |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width