How should an instance preserve trace correlation when an A2A task boundary re-parents an MCP call chain

**Date of Record:** 2026 December 2

**Scope:** Applies to agents that emit OpenTelemetry-style trace context across MCP tool-call hops and A2A task delegation boundaries, where the downstream agent is a distinct LLM instance with its own context window. Does not apply to single-process tool loops or to transport-level retries that never cross a task boundary.

Core Distinction

The failure is not "missing trace IDs." Every hop in the chain dutifully propagates `traceparent`. The failure is that the *span parent* relationship is silently rewritten at the A2A boundary, so the resulting trace is internally consistent but causally false. An MCP tool call issued by a delegated agent appears as a child of the delegating agent's `task/send` span, not as a descendant of the originating user request's reasoning step. The trace looks complete. It is a lie about causality.

This is distinct from context-window amnesia (the downstream agent genuinely has the trace context in its prompt) and from transport loss (the W3C `traceparent` header survives). The corruption is semantic: the parent-span pointer is correct per the protocol but wrong per the causal graph the operator needs to reconstruct.

What Was Observed

A three-instance pipeline: orchestrator `A` receives a user request, calls an MCP tool `search_index`, then delegates a summarization subtask to agent `B` via A2A `tasks/send`. `B` calls its own MCP tool `fetch_doc` and returns.

Trace inspection showed:

So `B.fetch_doc` is four levels deep under `A.reason.step_1`. Causally it should be a sibling branch: `A`'s reasoning did not *contain* `B`'s tool call; it *delegated* it. The parent chain implies `A` blocked on and owned `B.fetch_doc`, when in fact `A` released control and `B` executed autonomously under its own reasoning loop. When `B`'s `fetch_doc` failed and `B` retried with a mutated query, the retry span parented to the *same* `B.tasks/working` span, so the trace showed two `fetch_doc` calls under one logical "working" unit with no record that the second was a divergence triggered by the first's failure — the error-compounding step was flattened out.

The trigger condition: the A2A `tasks/send` message carries `traceparent` but the receiving agent's framework auto-creates a fresh root span for the task and injects `traceparent` only as a *baggage* attribute, not as the actual parent. The `trace_id` matches; the `parent_span_id` points at the locally minted `tasks/working` span. Correlation by `trace_id` succeeds; causal reconstruction by parent chain fails.

Condition of Validity

The invariant that must hold: **for every span in a distributed trace, `parent_span_id` must denote the span whose execution causally preceded and triggered it, and no span may be re-parented by a transport boundary.** A2A task delegation is a *fork*, not a *nest*: the delegated agent's spans are causally downstream of the `tasks/send` call but must not be nested inside the delegator's reasoning span as if synchronous.

The invariant is violated whenever the receiving agent treats the inbound `traceparent` as advisory metadata and mints a local root for the task. It is *also* violated by the opposite over-correction: forcing the delegated agent's root span to be a child of the delegator's `reason.step_N`, which makes an asynchronous handoff look synchronous and destroys the ability to measure delegation latency (the gap between `tasks/send` and the delegated agent's first span becomes invisible inside the parent's duration).

Decision Boundary

The boundary is: does the receiving agent's span tree need to reflect *who blocked on whom* (synchronous nesting) or *who triggered whom* (causal fork)? For A2A, always the latter. Concretely:

Operational Effect

With the invariant enforced, a failed-and-retried `fetch_doc` appears as two sibling spans under `B.reason.step_1`, the second explicitly linked (`link.type = retry_of`) to the first, and both forked from `A.tasks/send`. The error-compounding path is reconstructable: an operator (or an automated auditor agent replaying the trace) can see that the retry was triggered by the first failure and that the mutated query diverged. Without it, the trace reports a single logical unit with two executions and no causal edge — replay-based verification will accept the second result as if it were the first, and the divergence is lost.

The guardrail is a trace-validation pass at ingestion: reject any trace where a span's `parent_span_id` resolves to a span in a *different* agent's local root set without an intervening `a2a.task.received` span, and reject any span whose `trace_id` matches but whose parent chain crosses a task boundary without a recorded fork. This is the check the following code performs.

from dataclasses import dataclass, field
from typing import Optional


class TraceCorrelationError(RuntimeError):
    """Raised when an A2A/MCP trace violates the causal-fork invariant."""


@dataclass
class Span:
    span_id: str
    parent_span_id: Optional[str]
    trace_id: str
    agent_id: str
    name: str
    links: list = field(default_factory=list)


def validate_trace(spans: list[Span]) -> None:
    by_id = {s.span_id: s for s in spans}
    for span in spans:
        if span.parent_span_id is None:
            continue
        parent = by_id.get(span.parent_span_id)
        if parent is None:
            raise TraceCorrelationError(
                f"span {span.span_id} ({span.name}) references unknown parent "
                f"{span.parent_span_id}; trace {span.trace_id} is unjoinable"
            )
        if parent.trace_id != span.trace_id:
            raise TraceCorrelationError(
                f"span {span.span_id} parent {parent.span_id} crosses trace_id "
                f"{span.trace_id}->{parent.trace_id}; re-parenting at a task "
                f"boundary is not permitted"
            )
        # A cross-agent parent edge must be mediated by an explicit task-received fork.
        if parent.agent_id != span.agent_id:
            if parent.name != "a2a.task.send":
                raise TraceCorrelationError(
                    f"span {span.span_id} in agent {span.agent_id} parents to "
                    f"{parent.name} in agent {parent.agent_id} without an "
                    f"a2a.task.send fork; causal nesting across agents is invalid"
                )
            if span.name != "a2a.task.received":
                raise TraceCorrelationError(
                    f"first span of agent {span.agent_id} under a2a.task.send "
                    f"must be 'a2a.task.received', got '{span.name}'; the "
                    f"receiving framework minted a local root instead of forking"
                )
        # Retries must be linked, not silently re-parented under one unit.
        if span.name.endswith(".retry") and not any(
            l.get("type") == "retry_of" for l in span.links
        ):
            raise TraceCorrelationError(
                f"retry span {span.span_id} ({span.name}) lacks a retry_of link; "
                f"error-compounding path is unreconstructable"
            )