# What happens when an instance re-emits an inherited trace-context across an MCP tool-call boundary and the child span silently forks the causal chain **Date of Record:** 2026 November 27 **Scope:** Applies to multi-hop agent systems where a parent agent propagates W3C `traceparent`/`tracestate` (or an equivalent correlation ID) into MCP `tools/call` requests and A2A task handoffs, and a downstream LLM instance is expected to continue—not restart—the trace. Does not apply to single-process agents that own the whole span lifecycle, nor to systems that deliberately mint a fresh root span per hop. ## Core Distinction The distinction that matters is between *propagating* a trace-context and *continuing* one. Propagation is a transport concern: copy the `traceparent` header from the inbound request onto the outbound request. Continuation is a span-lifecycle concern: the receiving instance must create its child span with the inherited `trace_id` **and** set `parent_span_id` to the inherited `span_id`, then emit its own new `span_id` downstream. Almost every MCP and A2A SDK will happily do the first and silently fail the second, because the LLM instance in the middle is not a process with an ambient span stack—it is a probabilistic generator that reconstructs its outbound arguments from context each turn. When the model re-serializes a tool call, it frequently copies the *inbound* `traceparent` verbatim into the *outbound* header (correct `trace_id`, wrong `parent_span_id`), producing a sibling span rather than a child. The trace still looks "connected" in the UI because the `trace_id` matches, but the causal chain has forked: the auditor agent's span and the worker's span become siblings under the original root, and every latency, retry, and error attribution downstream is now computed against the wrong parent. ## What Was Observed A three-instance pipeline: `orchestrator` (A2A server) → `researcher` (A2A client + MCP client) → `search` (MCP server). The orchestrator emitted `traceparent: 00-4bf92f...-a1b2c3d4e5f60718-01` and handed the task to `researcher` via A2A. The researcher's system prompt instructed it to "preserve correlation metadata when calling tools." On turn 3, the researcher called `search.query` with: ``` traceparent: 00-4bf92f...-a1b2c3d4e5f60718-01 ``` —the orchestrator's span ID, unchanged. The `search` server, correctly implementing W3C semantics, created a span whose parent was `a1b2c3d4e5f60718`. But the researcher had *also* created its own span `f9e8d7c6...` for the same turn. Result: `search`'s span and `researcher`'s span are siblings, both children of the orchestrator. The researcher's LLM-generated span was orphaned from its own tool call. The failure is intermittent and correlates with prompt length: at ~4k tokens the researcher correctly minted a new `span_id`; at ~14k tokens (context saturation) it re-emitted the inherited header 100% of the time in a 200-run sample, because the "mint a new span ID" instruction had been pushed out of effective attention by accumulated tool results. This is not a transport bug—the header is well-formed and the trace ID is valid. It is a *state-continuity* bug: the instance lost the invariant that its outbound span must be a fresh child, and fell back to verbatim echo, which is the highest-probability continuation given the context. ## Condition of Validity The forked-sibling failure is only diagnosable—and only preventable—under these conditions: 1. **The receiving instance is the span owner.** If a sidecar proxy or SDK interceptor mints spans out-of-band from the model, the model never touches `span_id` and the failure cannot occur. The failure is specific to instances that *author* their own tool-call payloads. 2. **The `trace_id` is preserved but `parent_span_id` is not.** If the trace ID were also dropped, you would see a clean root-span break (easy to detect). The insidious case is `trace_id`-intact / `parent_span_id`-wrong, which passes every "is the trace connected?" smoke test. 3. **Downstream span creation is spec-compliant.** A server that blindly trusts the inbound `span_id` as *its own* span ID (rather than as parent) collapses the chain differently and masks the fork. Where any of these do not hold, the observed symptom is a different failure class (broken trace, duplicate spans, or clock-skew misordering) and this record does not apply. ## Decision Boundary The boundary is: **does the instance have a durable, out-of-context record of "my current span ID," or is it reconstructing that from the conversation?** If the span ID lives only in the prompt/context, it is subject to the same eviction dynamics as any other token and will be dropped or echoed under saturation. The guardrail is architectural, not prompt-level: - **Mint spans outside the model.** The runtime should assign the instance's span ID at turn start and inject it as a *structured, non-negotiable field* the model cannot rewrite—e.g., the MCP client stamps `traceparent` after the model returns the tool name and arguments, overriding any `traceparent` the model emitted. The model's job is to choose the tool and arguments; it must never be the authority on `parent_span_id`. - **Reject verbatim echo at the boundary.** The MCP/A2A client should assert `outbound.span_id != inbound.span_id` before dispatch. A match is a fork signal. - **Treat `tracestate` as opaque but `parent_span_id` as derived.** Never let the LLM generate either; derive both from runtime state. Below the boundary (span ID in context, model authors header), the fork rate is a function of context pressure and is unbounded in the worst case. Above the boundary (runtime stamps the header), the fork is structurally impossible. ## Operational Effect Downstream, the forked trace corrupts three things silently: (1) **latency attribution**—the researcher's wall-clock time no longer includes its tool calls, so p99 regressions appear to originate in `search`; (2) **retry accounting**—a retried `search` call appears as a new sibling rather than a retry of the same parent, inflating fan-out metrics; (3) **auditor consensus**—if a verification agent replays the trace to confirm the researcher actually invoked `search`, the sibling relationship makes the causal claim unprovable, and the auditor may flag a phantom "unlinked tool call" or, worse, accept it because the `trace_id` matches. The fix is a single invariant enforced at the client boundary: *the instance's outbound span must be a strict child of its inbound span, and the model must not be the one deciding that.* The code below encodes the assertion that catches the fork before it propagates. ```python class TraceContextForkError(RuntimeError): """Raised when an agent instance re-emits its inherited span_id as its own, forking the causal chain instead of continuing it.""" pass def stamp_outbound_traceparent(inbound_traceparent: str, instance_span_id: str) -> str: """Build the outbound traceparent for a model-authored tool call. The runtime—not the model—owns parent_span_id. The inbound span_id becomes the parent; the instance mints a fresh span_id for itself. """ parts = inbound_traceparent.strip().split("-") if len(parts) != 4: raise TraceContextForkError(f"malformed traceparent: {inbound_traceparent!r}") version, trace_id, inbound_span_id, flags = parts if not trace_id or len(trace_id) != 32: raise TraceContextForkError(f"invalid trace_id in {inbound_traceparent!r}") # The fork guard: the instance must not adopt the inbound span_id as its own. if instance_span_id == inbound_span_id: raise TraceContextForkError( f"instance re-emitted inherited span_id {inbound_span_id!r}; " "causal chain would fork into siblings" ) # Outbound parent is the instance's own span, not the orchestrator's. return f"{version}-{trace_id}-{instance_span_id}-{flags}" def validate_continuation(inbound: str, model_emitted: str, instance_span_id: str) -> None: """Assert the model did not silently echo the inbound header.""" in_span = inbound.split("-")[2] out_span = model_emitted.split("-")[2] if out_span == in_span: raise TraceContextForkError( "model echoed inbound span_id verbatim; runtime must override " "before dispatch to MCP/A2A peer" ) if out_span != instance_span_id: raise TraceContextForkError( f"model emitted span_id {out_span!r} != runtime-assigned {instance_span_id!r}" ) ```