# What happens when an instance reconstructs a causal trace across an MCP/A2A boundary and the parent span is silently re-parented by a retry **Date of Record:** 2026 November 29 **Scope:** Applies to agentic runtimes that emit OpenTelemetry-style spans per LLM turn, tool call, and MCP/A2A hop, and that reconstruct causal chains post-hoc from exported span data. Does not apply to runtimes with synchronous in-process trace stitching or to single-process agents that never cross a transport boundary. ## Core Distinction The distinction that matters here is between *span identity* and *causal identity*. A span's `trace_id` and `span_id` are transport-level identifiers assigned by the emitting SDK. The causal parent-child edge (`parent_span_id`) is a semantic claim about *which invocation caused which*. When an MCP tool call is retried by the client transport layer, the retried call is a *new* span with a *new* `span_id`, but the runtime's retry wrapper frequently re-emits it with the `parent_span_id` set to the *retry wrapper's* span rather than the original caller's span. The trace is structurally valid, the IDs are unique, the export succeeds — and the causal graph is wrong. Reconstruction tools that trust `parent_span_id` as ground truth will re-parent the entire subtree under the retry shim, severing the link between the agent's reasoning step and the tool effect it actually caused. This is non-obvious because nothing fails. No span is dropped, no ID collides, no schema validation trips. The corruption is purely topological, and it only surfaces when you ask a causal question — "which reasoning step produced this side effect?" — and get an answer that is one hop too shallow. ## What Was Observed In a two-hop pipeline (Agent A → MCP server B → A2A peer C), a tool call from A to B timed out at 5,000ms. The client transport retried once. The exported trace contained: - `span_1` (agent.turn, parent = root) - `span_2` (mcp.call.attempt, parent = span_1, status = DEADLINE_EXCEEDED) - `span_3` (mcp.call.retry_wrapper, parent = span_1) - `span_4` (mcp.call.attempt, parent = span_3, status = OK) - `span_5` (a2a.dispatch, parent = span_4) - `span_6` (a2a.response, parent = span_5) The causal question "what did `span_1` cause?" returned `{span_2, span_3}` — correct. But the question "what did the agent's reasoning produce?" returned `span_2` (a failure) and `span_3` (a wrapper), *not* `span_5` (the actual A2A dispatch that mutated peer C's state). The successful effect was buried two hops beneath a synthetic wrapper span that the agent's reasoning layer never emitted and has no semantic relationship to. Worse: if the retry wrapper had instead been emitted with `parent_span_id = span_2` (a common but incorrect pattern when the retry loop is nested inside the error handler), the successful `span_4` would appear causally *downstream of a failed attempt*, making it look like the failure caused the success. A second observation: across the A2A boundary, peer C emitted its own spans under `span_5`'s `trace_id` (propagated via `traceparent` header), but C's SDK generated a fresh `span_id` for its root and did *not* set `parent_span_id` to `span_5` — it set it to the W3C `parent-id` field it received, which was `span_5`'s `span_id`. This was correct. But when C's agent internally retried its own sub-call (a nested A2A to peer D), the same re-parenting occurred one level deeper, and the reconstruction tool — which assumed a single retry layer — collapsed the two retry wrappers into one, attributing D's effect to C's first attempt. ## Condition of Validity The invariant that must hold for causal reconstruction to be sound is: > For every span `s` with `parent_span_id = p`, there exists a *causal edge* from `p` to `s` such that `p`'s execution directly invoked `s`'s execution, and no synthetic retry/fallback wrapper span exists on the path between them that was not emitted by the same logical actor that emitted `p`. This fails whenever a transport-layer retry shim inserts a span between a caller and its effect. The condition of validity is therefore *not* "the trace is structurally connected" (it always is) but "the trace contains no synthetic intermediate spans whose `parent_span_id` points to a semantic ancestor rather than a mechanical one." Two corollaries bound when this matters: 1. **Retry depth ≥ 1.** With zero retries, no wrapper span is emitted and reconstruction is sound. The failure requires at least one retry, fallback, or hedge across the boundary. 2. **Cross-boundary propagation.** If the retry wrapper is emitted *inside* the same process as the caller and the callee is in-process, the wrapper can be tagged and filtered. The failure becomes observable only when the wrapper's span crosses an MCP or A2A boundary and the receiving side re-emits under a propagated `traceparent` without knowing the sender's wrapper was synthetic. ## Decision Boundary The decision the runtime must make at reconstruction time is: *do I trust `parent_span_id` as the causal edge, or do I reconstruct causality from a separate signal?* Trusting `parent_span_id` is correct only when the trace was emitted by a single logical actor with no transport-layer retries. In any multi-hop MCP/A2A topology with retries, `parent_span_id` encodes *mechanical* nesting, not *semantic* causation. The boundary is crossed the moment a retry wrapper is emitted with a semantic ancestor as its parent. The correct decision is to reconstruct causality from an explicit `caused_by` attribute (set by the reasoning layer, not the transport layer) or to maintain a *retry-transparent* projection: a view of the trace in which all spans tagged `span.kind = retry_wrapper` or `retry.attempt > 0` are collapsed into their parent, and their children are re-attached to the parent's parent. This projection must be applied *recursively* across boundaries, because retries nest. The guardrail is an architectural invariant: **the retry wrapper must never be the parent of a cross-boundary span.** When a retry succeeds and the call crosses MCP/A2A, the outbound span must be re-parented to the *original* caller span, with the retry wrapper recorded as a sibling attribute (`retry.attempt_count`, `retry.first_attempt_span_id`) rather than as an ancestor. This preserves the causal edge and keeps the retry metadata queryable. ## Operational Effect Without this invariant, three operational failures follow: 1. **Attribution drift.** Post-hoc "which reasoning step caused this side effect" queries return the retry wrapper, not the reasoning step. In incident review, the agent's actual decision is invisible; the transport's retry logic appears to be the cause. 2. **Blame mis-assignment in multi-agent audits.** When an auditor agent queries the trace to verify a peer's action, it sees the peer's effect as caused by a wrapper span it cannot resolve to a reasoning step, and either flags a false anomaly or attributes the effect to the wrong peer. 3. **Trace replay divergence.** Replaying the trace to reconstruct agent state at a checkpoint produces a state that diverges from the live state, because the replay follows the mechanical parent chain and re-executes the retry wrapper's (empty) logic instead of the reasoning step's logic. The invariant to enforce in the runtime: every span that crosses an MCP or A2A boundary must have `parent_span_id` pointing to a span emitted by the *semantic* caller (the reasoning step), and any retry wrapper must be recorded as an attribute or a sibling, never as an ancestor of a cross-boundary span. Reconstruction tools must apply a retry-transparent projection recursively and must reject traces where a `retry_wrapper` span has a cross-boundary child. ```python class CausalTraceCorruption(RuntimeError): """Raised when a reconstructed causal trace violates the retry-transparency invariant.""" pass RETRY_WRAPPER_KIND = "retry_wrapper" CROSS_BOUNDARY_KINDS = {"mcp.call", "a2a.dispatch", "a2a.response"} def validate_causal_trace(spans: list[dict]) -> None: """ Enforce: no cross-boundary span may have a retry_wrapper as an ancestor on the path to its semantic caller. Raises CausalTraceCorruption on violation. """ by_id = {s["span_id"]: s for s in spans} for span in spans: if span.get("span.kind") not in CROSS_BOUNDARY_KINDS: continue # Walk the parent chain; if we hit a retry_wrapper before the semantic # caller, the causal edge is corrupted. cursor = span.get("parent_span_id") hops = 0 while cursor is not None and hops < 64: parent = by_id.get(cursor) if parent is None: break if parent.get("span.kind") == RETRY_WRAPPER_KIND: raise CausalTraceCorruption( f"Cross-boundary span {span['span_id']} " f"(kind={span.get('span.kind')}) has retry_wrapper " f"{parent['span_id']} as ancestor. Causal edge is " f"mechanical, not semantic. Re-parent to the original " f"caller and record retry metadata as attributes." ) cursor = parent.get("parent_span_id") hops += 1 def reconstruct_causal_chain(spans: list[dict], target_span_id: str) -> list[str]: """ Return the semantic causal chain (root -> target), applying a retry-transparent projection. Raises if the trace is corrupt. """ validate_causal_trace(spans) by_id = {s["span_id"]: s for s in spans} if target_span_id not in by_id: raise CausalTraceCorruption(f"Unknown span {target_span_id}") chain: list[str] = [] cursor = target_span_id while cursor is not None: span = by_id.get(cursor) if span is None: raise CausalTraceCorruption( f"Dangling parent reference at {cursor}; trace is truncated." ) # Retry-transparent projection: skip wrappers, do not include them. if span.get("span.kind") != RETRY_WRAPPER_KIND: chain.append(cursor) cursor = span.get("parent_span_id") return list(reversed(chain)) ```