[BUG] Agent SDK / headless turns no longer emit `claude_code.interaction`, so inbound TRACEPARENT is ignored and `llm_request` spans become orphan roots (regression in 2.1.257)

Status Open
Reported on v2.1.252
Maintainer reply None cached
Activity 1 comment · opened Oct 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

With traces enabled, an Agent SDK turn no longer produces a claude_code.interaction span. Each claude_code.llm_request is exported as a parentless root span in its own new trace.

The interaction span is also where the CLI reads TRACEPARENT. Without it, inbound trace context is dropped. The run no longer nests under the host application's span, as described in Observability → Link traces to your application. It shows up as disconnected single-span traces instead.

The breakage happens in all of these cases:

  • TRACEPARENT auto-injected by the SDK from an active span;
  • TRACEPARENT set explicitly in options.env;
  • TRACEPARENT inherited from the process environment;
  • string-prompt input and streaming (AsyncIterable) input.

What Should Happen?

As documented in the Monitoring reference's span hierarchy:

  • each turn emits claude_code.interaction (with parent.source = "env" when TRACEPARENT is set);
  • claude_code.llm_request and claude_code.tool are its children;
  • the interaction span is a child of the inbound TRACEPARENT context.

This is what CLI 2.1.252 and earlier do.

Error Messages/Logs

No error output. CLAUDE_CODE_OTEL_DIAG_STDERR=1 prints nothing; export itself succeeds.

CLI 2.1.289, TRACEPARENT=00-eeeeeeeeeeeeeeeeeeeeeeeeeeee0289-ffffffffffffffff-01 via options.env (spans as received by an Aspire dashboard):
claude_code.llm_request  trace 13e93ee373bc5343d53c858505622d9a  parent None
claude_code.llm_request  trace 2f8951645634ab58ba239606a760afc0  parent None

Same script, CLI 2.1.207:
claude_code.interaction  trace 8f5ef1c7…  parent None   span.type=interaction, interaction.sequence=1
claude_code.llm_request  trace 8f5ef1c7…  parent 2e0c11a9abcf433e

Steps to Reproduce

  1. Run any OTLP receiver. I used the standalone Aspire dashboard (mcr.microsoft.com/dotnet/aspire-dashboard, OTLP/HTTP on :4318).
  2. Save as repro.mjs:

```js
import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const m of query({
prompt: "Reply with the single word OK.",
options: {
model: "claude-haiku-4-5-20251001",
tools: [],
maxTurns: 1,
settingSources: [],
persistSession: false,
env: {
...process.env,
TRACEPARENT: "00-eeeeeeeeeeeeeeeeeeeeeeeeeeee0289-ffffffffffffffff-01",
},
// To bisect CLI versions under the same SDK:
// pathToClaudeCodeExecutable: "<extracted @anthropic-ai/claude-agent-sdk-<platform>@X>/package/claude",
},
})) {
if (m.type === "result") console.log(m.subtype, m.is_error);
}
```

  1. Run it with:

``bash
CLAUDE_CODE_ENABLE_TELEMETRY=1 CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 \
OTEL_TRACES_EXPORTER=otlp OTEL_METRICS_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp \
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
OTEL_SERVICE_NAME=repro node repro.mjs
``

  1. Look at the spans for service repro. There is no claude_code.interaction span. The llm_request spans are roots in new traces, not children of trace eeee…0289.

Bisect: SDK 0.3.289 driving older CLI binaries through pathToClaudeCodeExecutable. Platform packages 0.3.253–0.3.256 are not published.

| CLI | claude_code.interaction emitted | Parented to inbound TRACEPARENT |
|---|---|---|
| 2.1.207 | yes | yes |
| 2.1.248 | yes | yes |
| 2.1.252 | yes | yes |
| 2.1.257 | no | no |
| 2.1.258 | no | no |
| 2.1.259 | no | no |
| 2.1.270 | no | no |
| 2.1.289 | no | no |

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.252

Claude Code Version

2.1.289 (Claude Code), bundled with @anthropic-ai/claude-agent-sdk@0.3.289

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Non-interactive/CI environment

Additional Information

  • Possibly related: the 2.1.257 changelog entry "Fixed telemetry (OTEL) settings pushed through server-managed settings being ignored on warm starts". This is a guess; I haven't confirmed it.
  • 2.1.289 also contains an undocumented parent.source = "event" path, which reads trace context from an incoming event. SDK 0.3.289 still propagates only through TRACEPARENT/TRACESTATE in the environment, so SDK hosts never reach that path.
  • Impact: we can't pin around this. Opus 5.5 support arrived in 2.1.280, so no CLI version both supports claude-opus-5-5 and emits the interaction span.
  • Reproduced on macOS arm64 and seen on Linux x64 (Docker) in production; the CLI runs as an Agent SDK subprocess under Node 22. Not model-specific: reproduced with claude-haiku-4-5-20251001, seen in production with claude-sonnet-5-5.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗