# In what scenarios must an instance refuse to propagate a traceparent across an A2A handoff because the peer’s advertised schema version makes span correlation semantically invalid **Date of Record:** 2026 November 22 **Scope:** Applies to multi-hop agent systems where an orchestrator emits W3C `traceparent`/`tracestate` headers into MCP tool calls and A2A task handoffs, and where downstream peers may run different span-semantics schema versions. Does not apply to single-process agents or to transports that carry no distributed-context headers. ## Core Distinction The common failure model for agent observability is *trace loss*: a header gets dropped, a span is orphaned, the parent-child edge vanishes. The mitigation is mechanical—plumb `traceparent` through every MCP `call_tool` envelope and every A2A `Task`/`Message` payload, and the trace reassembles. The boundary condition that breaks this model is *trace mis-correlation*: the header is propagated faithfully, the peer accepts it, and the resulting span graph is **well-formed but wrong**. This happens because `traceparent` carries only `trace-id`, `parent-id`, and `span-id`—opaque 128/64-bit identifiers with no semantic contract. Correlation validity depends entirely on a *shared, undocumented agreement about what a span boundary means*. When an A2A peer advertises a different span-semantics schema version than the caller, the peer will happily join the trace, but it will attach a span to the wrong logical operation. The trace looks complete. The latency attribution, the causal chain, and the error-propagation edge are all silently corrupted, and no error is ever raised. The invariant: **a `traceparent` may only be propagated across a handoff when caller and peer agree on the span-boundary schema version; identifier opacity is not semantic compatibility.** The `traceparent` version byte (`00`) is a *format* version, not a *semantics* version, and conflating the two is the exact mistake that produces mis-correlation. ## What Was Observed An orchestrator agent (`orch-7`) delegated a retrieval-then-summarize task to an A2A peer (`peer-summarizer`, schema `a2a.span-sem/2.1`) while calling three MCP servers (`mcp-vector`, `mcp-rerank`, `mcp-tokenizer`, all schema `a2a.span-sem/2.1`). The orchestrator itself ran `a2a.span-sem/2.3`. The `2.3` schema introduced a rule: *a retry of a tool call is a sibling span, not a child of the failed attempt*, and *tokenizer spans are emitted per-batch, not per-call*. The `2.1` peer and MCP servers implemented the older rule: *retries nest under the original attempt*, and *one tokenizer span covers the whole call*. Observed trace (abridged, `trace-id` constant across all spans): - `orch-7` root span `S0` (schema 2.3) - `S1` `mcp-vector.call_tool` (2.1) — child of `S0` ✓ - `S1r` retry of `S1` (2.1) — child of `S1` (nested per 2.1) - `S2` `a2a.handoff` to `peer-summarizer` (2.3, emitted by orch) — child of `S0` - `S3` `peer-summarizer.summarize` (2.1) — child of `S2` ✓ - `S4` `mcp-tokenizer.call_tool` (2.1) — child of `S3`, single span for a 4-batch call The trace *rendered*. The trace *was accepted by the collector*. And it was wrong in three ways that no validator caught: 1. **Latency double-count.** The orchestrator's cost report summed `S1` and `S1r` as independent spans (2.3 semantics), but `S1r` was nested inside `S1` (2.1 semantics). Retry latency was attributed twice, once inside `S1`'s wall-clock and once as `S1r`'s own duration. A 1.2s retry inflated the reported tool latency to 2.4s. 2. **Causal-edge inversion.** When `S4` (tokenizer) failed on batch 3, the orchestrator's 2.3 error-propagation logic walked *up* the span tree looking for the first non-retry ancestor to blame. It found `S3`, the summarizer span, and marked the A2A peer as the failure origin. The actual failure was inside `mcp-tokenizer`'s batch 3, which under 2.3 would have been a distinct sibling span but under 2.1 was collapsed into `S4`. The orchestrator escalated a false peer-fault to the auditor. 3. **Cardinality mismatch.** The orchestrator expected one tokenizer span per batch (4 spans) to compute per-batch token throughput. It received one span (2.1 collapsed). Throughput was computed as `total_tokens / 1`, off by 4×, and the anomaly detector never fired because the span count was internally consistent with a *single* batch. The critical detail: `peer-summarizer` returned a valid A2A `Artifact` with `metadata["span_semantics"] = "a2a.span-sem/2.1"`. The orchestrator *received this field and ignored it*, because its handoff code only checked `traceparent` format validity, not semantics version. ## Condition of Validity Propagating `traceparent` across an A2A or MCP boundary is valid **iff** all of the following hold: 1. **Semantics-version equality (or a declared adapter).** The caller must compare its own span-semantics schema version against the peer's advertised version *before* emitting the handoff span. The A2A capability/schema negotiation (the `AgentCard` `skills[].span_semantics` or the MCP `initialize` result's `experimental.span_semantics`) is the authoritative source. If versions differ and no adapter is registered, propagation is invalid. 2. **Span-boundary agreement.** Both sides must agree on: (a) whether retries are siblings or children, (b) whether batch operations emit one span or N, (c) whether a handoff span is owned by caller or callee. Disagreement on any of these three is sufficient to invalidate correlation even when the version string matches. 3. **Cardinality contract.** The caller must know, a priori, the expected span count per logical operation, or must treat span count as uninterpreted. A caller that computes aggregates from span cardinality must pin the peer's cardinality semantics. 4. **Identifier non-reuse across semantics.** A `span-id` emitted under 2.1 semantics must not be re-parented under 2.3 semantics anywhere in the same trace. Re-parenting is the mechanism by which a well-formed graph becomes wrong. If any of these fail, the correct action is **not** to propagate the incoming `traceparent` as-is. The correct action is to **start a new trace** (or a linked trace via `tracestate`'s `link` field) at the boundary, record the handoff as a `span.kind=client` with an explicit `span_semantics_mismatch` attribute, and let the collector stitch traces by a *semantic* join key rather than by parent-child edge. ## Decision Boundary The decision is not "propagate or drop." It is **"propagate as child, propagate as link, or start new trace."** - **Propagate as child** (normal): versions equal *and* span-boundary agreement holds *and* cardinality is pinned. Emit `traceparent` with `parent-id = caller_span`. - **Propagate as link**: versions differ but an adapter is registered that maps the peer's span boundaries to the caller's. Emit `traceparent` with a *new* `parent-id` at the adapter boundary, and carry the original `trace-id` in `tracestate` under a `link=` key. The collector joins by `link`, not by parent edge. - **Start new trace**: versions differ and no adapter. Do **not** forward the caller's `traceparent`. Generate a fresh `trace-id`, record `span_semantics_mismatch=true` and both version strings as span attributes, and emit a `handoff.orphaned` event so the collector can attempt semantic join by task-id. The boundary is triggered by the *first* of these to fail: version equality, boundary agreement, cardinality pin. A system that checks only `traceparent` format validity (the `00-<32hex>-<16hex>-<2hex>` regex) will always take the "propagate as child" branch and will always mis-correlate when versions diverge. The regex is necessary and radically insufficient. A second, subtler boundary: the peer's advertised version may be *stale*. A2A `AgentCard`s are cached; a peer that upgraded from 2.1 to 2.3 but whose card still says 2.1 will be treated as 2.1-compatible, and the caller will apply the wrong adapter. The invariant must therefore include a **version freshness check**: the `AgentCard`'s `span_semantics` must be re-validated against the peer's `initialize` response on every handoff, not trusted from cache. If the two disagree, treat as version-mismatch and start a new trace. ## Operational Effect Without this boundary, three failure classes propagate silently: 1. **Cost and latency reports inflate or deflate** by the retry-nesting factor and the batch-collapse factor. These are not noise; they are systematic, version-dependent biases that make cross-peer SLO comparison meaningless. 2. **Fault attribution inverts.** Error-propagation walks that assume 2.3 sibling semantics will blame the wrong span (and often the wrong *agent*) when the peer emits 2.1 nested semantics. This is how a healthy A2A peer gets quarantined by an auditor that trusted a corrupted trace. 3. **Anomaly detectors go quiet.** Cardinality-based detectors (span-count-per-operation, tokens-per-span) are calibrated to one schema and silently mis-scale under another. The detector reports "healthy" because the corrupted trace is internally consistent. The guardrail is a **pre-handoff semantics gate** in the orchestrator's A2A/MCP client: before emitting the handoff span, fetch the peer's live `span_semantics` from `initialize`, compare to the local version, consult the adapter registry, and choose child-link-newtrace. The gate must run on every handoff, not once per session, because peer versions change under rolling deploys. The cost is one extra round-trip field in `initialize`; the benefit is that the trace graph is *semantically* correct, not merely *structurally* complete. The deeper lesson: distributed tracing was designed for services that share an implicit span-boundary contract (one span = one RPC). Agents break that contract because span boundaries are a *schema choice*, and schemas evolve per-peer. `traceparent` is a correlation *token*, not a correlation *guarantee*. An agent that treats it as a guarantee will produce traces that are beautiful, complete, and wrong. ```python from __future__ import annotations import re from dataclasses import dataclass from enum import Enum _TRACEPARENT_RE = re.compile(r"^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$") class SpanSemanticsMismatch(RuntimeError): """Raised when a traceparent cannot be propagated as a child span because caller and peer disagree on span-boundary semantics.""" class PropagationMode(Enum): CHILD = "child" # normal: same semantics, forward parent-id LINK = "link" # adapter registered: new parent, link in tracestate NEW_TRACE = "new" # no adapter: do not forward traceparent @dataclass(frozen=True) class PeerSpanContract: version: str # e.g. "a2a.span-sem/2.1" retries_are_siblings: bool # 2.3=True, 2.1=False batch_emits_per_item: bool # 2.3=True, 2.1=False handoff_span_owner: str # "caller" | "callee" def _parse_versions(v: str) -> tuple[str, int]: # "a2a.span-sem/2.1" -> ("a2a.span-sem", (2,1)) flattened for compare name, _, ver = v.partition("/") major, _, minor = ver.partition(".") return name, int(major) * 1000 + int(minor) def decide_propagation( traceparent: str, caller: PeerSpanContract, peer_advertised: PeerSpanContract, peer_initialize: PeerSpanContract, adapter_registered: bool, ) -> PropagationMode: if not _TRACEPARENT_RE.match(traceparent): # Format-invalid is a hard error, not a downgrade. raise SpanSemanticsMismatch(f"malformed traceparent: {traceparent!r}") # Freshness gate: cached AgentCard must match live initialize. if peer_advertised.version != peer_initialize.version: raise SpanSemanticsMismatch( "stale AgentCard: advertised " f"{peer_advertised.version} != initialize {peer_initialize.version}; " "refusing to trust cached span semantics" ) caller_name, caller_v = _parse_versions(caller.version) peer_name, peer_v = _parse_versions(peer_initialize.version) if caller_name != peer_name: raise SpanSemanticsMismatch( f"incomparable span-semantics families: {caller_name} vs {peer_name}" ) boundary_agrees = ( caller.retries_are_siblings == peer_initialize.retries_are_siblings and caller.batch_emits_per_item == peer_initialize.batch_emits_per_item and caller.handoff_span_owner == peer_initialize.handoff_span_owner ) if caller_v == peer_v and boundary_agrees: return PropagationMode.CHILD if adapter_registered: return PropagationMode.LINK # No adapter and semantics diverge: forwarding as child would mis-correlate. raise SpanSemanticsMismatch( "span-boundary semantics diverge with no adapter: " f"caller={caller.version} peer={peer_initialize.version} " f"retries_siblings={caller.retries_are_siblings}->{peer_initialize.retries_are_siblings} " f"batch_per_item={caller.batch_emits_per_item}->{peer_initialize.batch_emits_per_item}; " "must start new trace and emit handoff.orphaned" ) def emit_handoff_span( traceparent: str, caller: PeerSpanContract, peer_advertised: PeerSpanContract, peer_initialize: PeerSpanContract, adapter_registered: bool, ) -> dict: mode = decide_propagation( traceparent, caller, peer_advertised, peer_initialize, adapter_registered ) if mode is PropagationMode.CHILD: return {"traceparent": traceparent, "span.kind": "client"} if mode is PropagationMode.LINK: # new parent-id at adapter boundary; original trace-id carried in tracestate return { "traceparent": traceparent, # caller rewrites parent-id before send "tracestate": f"link={traceparent.split('-')[1]}", "span.kind": "client", "span_semantics_adapter": True, } # NEW_TRACE branch is unreachable here because decide_propagation raises; # kept for type completeness if policy changes to downgrade instead of raise. raise SpanSemanticsMismatch("NEW_TRACE must be handled by caller, not emit_handoff_span") ```