# Under what conditions must an instance refuse to propagate an inherited trace context across an MCP tool-call boundary when the upstream A2A peer and the LLM inference layer disagree on span-kind semantics **Date of Record:** 2026 November 16 **Scope:** Applies to multi-agent systems where a single logical request crosses at least three observability domains — an A2A (agent-to-agent) task envelope, one or more MCP (Model Context Protocol) tool invocations, and an LLM inference call — and where trace context (trace_id, span_id, parent_span_id, span kind, and baggage) is propagated by convention rather than by a schema-enforced contract. Does not apply to single-hop tool calls, to systems using a single unified tracing SDK with a shared semantic-convention version pinned across all hops, or to contexts where the trace is re-rooted at every boundary by policy. ## Core Distinction The failure is not "trace context is lost." Loss is observable and cheap: a broken parent link, an orphaned span, a trace that terminates early. The failure addressed here is **trace context that is faithfully propagated but semantically mislabeled**, producing a trace that is structurally valid, causally wrong, and indistinguishable from a correct trace at read time. The distinction that matters operationally is between **transport fidelity** and **semantic fidelity**. Transport fidelity is satisfied when the `traceparent` header survives every hop byte-for-byte. Semantic fidelity is satisfied only when the span kind, the parent relationship, and the baggage keys mean the same thing at the point of consumption as they meant at the point of origin. A2A envelopes conventionally treat the receiving agent's work as a *consumer* span (the task is a unit of delegated work, and the delegating agent is the producer). MCP tool invocations conventionally treat the tool call as an *internal* or *client* span relative to the calling agent's turn. LLM inference calls conventionally emit a *client* span for the outbound API call plus, in most instrumentations, a *producer* span for the generation itself, because token accounting is attributed to the generation, not the HTTP request. When these three conventions are composed without reconciliation, the same `parent_span_id` is simultaneously interpreted as "I am the server for this task," "I am the client for this tool," and "I am the producer of this completion." The resulting trace is a DAG that validates against the tracing backend's schema and lies about causality. ## What Was Observed In a three-hop pipeline (orchestrator agent → A2A task → worker agent → MCP tool → LLM inference), the following invariant was found to hold in every failing trace: the worker agent's MCP tool-call span carried the A2A task span as its parent, and the LLM inference span carried the MCP tool-call span as its parent. Structurally correct. But the A2A task span was a *consumer* span on the receiving side and a *producer* span on the sending side — the same span ID, two kinds, because A2A's convention labels the span from the perspective of the agent that emits it, and the emitting agent was the orchestrator. The worker inherited a producer-kind context and emitted its tool call as a child of it, which made the tool call appear to be produced by the orchestrator rather than consumed by the worker. The downstream effect was measurable: latency attribution for the LLM inference call was charged to the orchestrator's span in the trace UI, because the inference span's nearest producer-kind ancestor was the orchestrator's task span. In one incident, a 40-second inference stall was attributed to the orchestrator's A2A dispatch, which had in fact completed in 80ms. Two days of investigation were spent on the orchestrator's queueing behavior before the trace was re-read with span kinds ignored and the actual causal chain reconstructed from timestamps. A second observation: baggage keys collided. The A2A envelope carried `agent.id` meaning the *delegating* agent; the MCP instrumentation carried `agent.id` meaning the *executing* agent. Both survived transport. The LLM inference layer, which reads `agent.id` for cost attribution, attributed the generation to the delegating agent. Cost dashboards were wrong by a factor that tracked fan-out depth, not by a constant. A third: span-kind disagreement was not detectable by header inspection. The `traceparent` header is kind-agnostic by design (W3C Trace Context carries trace-id, parent-id, flags — no kind). Kind lives in the span, not the header. So a receiver cannot know, from the wire, whether the upstream peer considers the inherited context a producer or a consumer. It must either know the convention a priori or refuse to guess. ## Condition of Validity The invariant "propagate inherited trace context across the MCP boundary" is valid only when all of the following hold: 1. The upstream A2A peer and the local MCP instrumentation agree on the span kind of the inherited parent, *or* the local instrumentation does not depend on the parent's kind for any decision (attribution, sampling, error classification). 2. Baggage keys are namespaced such that no key means different things at different hops, *or* the local layer re-writes colliding keys before consumption. 3. The LLM inference layer's producer span is emitted as a *sibling* of the MCP tool-call span rather than a child, *or* the inference layer's cost attribution is keyed on a baggage value rather than on nearest producer-kind ancestor. When any of these fails, propagation is transport-correct and semantically corrupt. The correct action is not to drop the context (which loses the trace) and not to propagate it unchanged (which corrupts attribution), but to **propagate the trace ID while re-rooting the span kind locally and recording the disagreement as an explicit attribute** — e.g., `trace.context.kind_conflict=true` with the upstream kind and the locally-assumed kind both recorded. This preserves trace continuity for reconstruction while making the corruption machine-detectable. ## Decision Boundary The boundary is crossed when a receiver cannot establish, from the inherited context alone, the span kind the upstream peer assigned to the parent. In practice this is almost always the case across A2A→MCP transitions, because A2A's convention and MCP's convention were specified independently and neither carries kind on the wire. The decision rule: - If the receiver can query the upstream peer's convention (e.g., a capability declaration in the A2A envelope naming the semantic-convention version), propagate and trust. - If the receiver cannot, and the local layer's behavior depends on the parent's kind, **refuse to propagate the inherited parent as-is**. Emit a new span with a locally-determined kind, set the inherited context as a *link* rather than a parent, and record the conflict. - If the receiver cannot, and the local layer's behavior does not depend on kind (pure logging), propagate unchanged and accept the attribution risk. The non-obvious part: the second branch is the correct default for any layer that performs cost or latency attribution, which is most LLM inference layers. Refusing to propagate is not a degradation; it is the only way to keep attribution sound. ## Operational Effect Systems that adopt the refuse-and-link rule observe three effects. First, traces become slightly wider (links instead of parents at convention boundaries) and slightly more expensive to store. Second, attribution dashboards stop drifting with fan-out depth — the factor-of-fan-out cost error disappears because `agent.id` is no longer read from a colliding baggage key but from a locally-scoped attribute. Third, and most importantly, the conflict is *visible*: `trace.context.kind_conflict=true` becomes a queryable signal, and the set of boundaries where conventions disagree becomes an enumerated, shrinking list rather than an invisible source of wrong numbers. Systems that propagate unchanged observe the opposite: traces look cleaner, attribution drifts silently, and the drift is only discovered when a latency investigation goes two days in the wrong direction. The cost of the rule is a small storage increase; the cost of skipping it is unbounded investigation time. ```python from __future__ import annotations from dataclasses import dataclass from enum import Enum class SpanKind(Enum): PRODUCER = "producer" CONSUMER = "consumer" INTERNAL = "internal" CLIENT = "client" class TraceContextKindConflict(RuntimeError): """Raised when an inherited trace context's span kind cannot be reconciled with the local semantic convention and the local layer depends on kind.""" @dataclass(frozen=True) class InheritedContext: trace_id: str parent_span_id: str upstream_kind: SpanKind | None # None => not declared on the wire upstream_convention: str | None @dataclass(frozen=True) class LocalSpanPolicy: local_kind: SpanKind depends_on_parent_kind: bool convention_version: str def resolve_parent( inherited: InheritedContext, policy: LocalSpanPolicy, ) -> dict: """Decide whether to propagate the inherited parent, re-root, or link. Returns a dict describing the emission plan. Raises TraceContextKindConflict when the local layer depends on the parent's kind and the upstream kind is either undeclared or disagrees with the local convention in a way that would corrupt attribution. """ if not inherited.trace_id or not inherited.parent_span_id: raise TraceContextKindConflict( f"incomplete inherited context: trace_id={inherited.trace_id!r} " f"parent_span_id={inherited.parent_span_id!r}" ) if not policy.depends_on_parent_kind: # Pure logging layer: transport fidelity is sufficient. return { "action": "propagate", "trace_id": inherited.trace_id, "parent_span_id": inherited.parent_span_id, "kind_conflict": False, } if inherited.upstream_kind is None: # Cannot establish kind from the wire; local layer depends on it. # Refuse to propagate as parent; link instead and record conflict. return { "action": "link_and_reroot", "trace_id": inherited.trace_id, "link_span_id": inherited.parent_span_id, "local_kind": policy.local_kind.value, "kind_conflict": True, "reason": "upstream_kind_undeclared", "upstream_convention": inherited.upstream_convention, "local_convention": policy.convention_version, } if inherited.upstream_kind == policy.local_kind: return { "action": "propagate", "trace_id": inherited.trace_id, "parent_span_id": inherited.parent_span_id, "kind_conflict": False, } # Kinds disagree and local layer depends on kind: attribution would be # charged to the wrong producer. Link and re-root. return { "action": "link_and_reroot", "trace_id": inherited.trace_id, "link_span_id": inherited.parent_span_id, "local_kind": policy.local_kind.value, "kind_conflict": True, "reason": "span_kind_disagreement", "upstream_kind": inherited.upstream_kind.value, "local_kind_expected": policy.local_kind.value, "upstream_convention": inherited.upstream_convention, "local_convention": policy.convention_version, } def emit_mcp_tool_span( inherited: InheritedContext, policy: LocalSpanPolicy, ) -> dict: plan = resolve_parent(inherited, policy) if plan["action"] == "link_and_reroot" and not plan.get("trace_id"): # Defensive: a re-root without a trace id is unrecoverable. raise TraceContextKindConflict( "re-root plan missing trace_id; cannot preserve trace continuity" ) return plan ```