Title: Anthropic tool runner and message threads drop `gen_ai.chat` spans on `@anthropic-ai/sdk` >=1.2.0 · Issue #25816 · getsentry/sentry-javascript · GitHub
Open Graph Title: Anthropic tool runner and message threads drop `gen_ai.chat` spans on `@anthropic-ai/sdk` >=1.2.0 · Issue #25816 · getsentry/sentry-javascript
X Title: Anthropic tool runner and message threads drop `gen_ai.chat` spans on `@anthropic-ai/sdk` >=1.2.0 · Issue #25816 · getsentry/sentry-javascript
Description: On @anthropic-ai/sdk 1.2.0 and newer, calls made through beta.messages.toolRunner() or beta.messages.thread() produce no gen_ai.chat spans. gen_ai.execute_tool spans still show up. This is the follow-up mentioned in #25750. I ran the eag...
Open Graph Description: On @anthropic-ai/sdk 1.2.0 and newer, calls made through beta.messages.toolRunner() or beta.messages.thread() produce no gen_ai.chat spans. gen_ai.execute_tool spans still show up. This is the foll...
X Description: On @anthropic-ai/sdk 1.2.0 and newer, calls made through beta.messages.toolRunner() or beta.messages.thread() produce no gen_ai.chat spans. gen_ai.execute_tool spans still show up. This is the foll...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25816
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Anthropic tool runner and message threads drop `gen_ai.chat` spans on `@anthropic-ai/sdk` >=1.2.0","articleBody":"On `@anthropic-ai/sdk` 1.2.0 and newer, calls made through `beta.messages.toolRunner()` or `beta.messages.thread()` produce no `gen_ai.chat` spans. `gen_ai.execute_tool` spans still show up. This is the follow-up mentioned in #25750.\n\nI ran the eager streaming tool runner scenario from `suites/tracing/anthropic/v0.129` against several versions with the range widened to `\u003c2`:\n\n| SDK version | `gen_ai.chat` spans | `gen_ai.execute_tool` spans |\n| --- | --- | --- |\n| 0.133.0, 0.137.0, 1.0.0, 1.1.0 | 2 | 2 |\n| 1.2.0, 1.3.0 | 0 | 2 |\n\n**Cause.** 1.2.0 added message threads, which are on by default for the first-party `Anthropic` client (`_supportsMessageThreads = true`). The tool runner now sends each turn through `BetaMessageThread._createWithRecovery`, which still calls `beta.messages.create()`, so our `chat` channel opens a span. But the thread then awaits `request._responseProps()` and builds its own `APIPromise` from the raw props. `wrapApiPromiseResponse` (`packages/server-utils/src/ai/core/apiPromise.ts`) only ends the span from `parseResponse` or `asResponse()`, and neither runs on that path. The span is opened but never ended, so it is never sent.\n\nRequests that fail still end the span, through the `asResponse()` error handler.\n\n**Scope.** This affects every `toolRunner()` call and any direct `thread().send()` on the default client from 1.2.0 on. Bedrock and Vertex clients don't support threads, so they should not be affected (not verified).\n\n**Fix direction.** End the span from the response props as well, for example by also observing `_responseProps()`. The streaming case is harder: the thread builds the `Stream` itself, so we would need to hook that stream to record usage and end the span when it finishes.\n","author":{"url":"https://github.com/chargome","@type":"Person","name":"chargome"},"datePublished":"2026-10-28T13:13:17Z","url":"https://github.com/getsentry/sentry-javascript/issues/25816"}
| 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:98e33e6b-248a-a2b8-8186-89d4b49b902c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0F0:159911:27A85:37133:6B041606 |
| html-safe-nonce | 8bf07516d099a9c9d21e1ce1b8115629689bb8f9c870a781a51073cb18b9466d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEYwOjE1OTkxMToyN0E4NTozNzEzMzo2QjA0MTYwNiIsInZpc2l0b3JfaWQiOiI2NzA3MDI5MzE5MzAwMTU4OTgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3bc44571a0d5bf4081a6675b76465c753c3cf490010ffd95fe82555cd5228c35 |
| hovercard-subject-tag | issue:6079632793 |
| 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/25816/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a3465d53c60ba7cd9e8b45923d8058e101493c8c9f8096473237e00269a2ef48/getsentry/sentry-javascript/issues/25816 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a3465d53c60ba7cd9e8b45923d8058e101493c8c9f8096473237e00269a2ef48/getsentry/sentry-javascript/issues/25816 |
| og:image:alt | On @anthropic-ai/sdk 1.2.0 and newer, calls made through beta.messages.toolRunner() or beta.messages.thread() produce no gen_ai.chat spans. gen_ai.execute_tool spans still show up. This is the foll... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chargome |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| 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