You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Anthropic tool runner and message threads drop gen_ai.chat spans on @anthropic-ai/sdk >=1.2.0 #25816
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 eager streaming tool runner scenario from suites/tracing/anthropic/v0.129 against several versions with the range widened to <2:
SDK version
gen_ai.chat spans
gen_ai.execute_tool spans
0.133.0, 0.137.0, 1.0.0, 1.1.0
2
2
1.2.0, 1.3.0
0
2
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.
Requests that fail still end the span, through the asResponse() error handler.
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).
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.
Activity
linear-code commentedon Oct 28, 2026
JS-4030