# Under what conditions must an instance propagate a single trace root across MCP sessions, A2A task boundaries, and delegated sub-agents — and what silently breaks when it does not **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that (a) opens one or more MCP client sessions to tool servers, (b) participates in A2A task lifecycle (submit → work → complete/fail) with peer agents, and (c) delegates work to sub-agents that may themselves open MCP sessions. Does not apply to single-process, single-session agents with no delegation and no peer protocol, where the trace root is trivially the process lifetime. ## Core Distinction The distinction that matters is between **trace identity** and **execution identity**. Execution identity is what most runtimes actually correlate on: a process ID, a session ID, a task ID, a conversation/thread ID. These are *local* identifiers minted by whichever component owns the lifecycle of that unit of work. Trace identity is a *global* identifier that must survive every one of those lifecycle transitions unchanged. The failure mode is not "traces are missing." It is that traces are **present, complete-looking, and wrong** — stitched together by a correlation key that happens to be unique per component but is not the same key across components. A sub-agent's MCP tool call gets attributed to the sub-agent's session, the sub-agent's session gets attributed to the delegating task, and the delegating task gets attributed to the parent conversation — but the *join* between those layers is done by a heuristic (timestamp proximity, agent name, or "most recent open span") rather than by a propagated root. When two delegations overlap in time, the heuristic silently cross-links them. The invariant: **there must exist exactly one trace root identifier, minted at the outermost entry point, that is carried as an immutable field through every MCP `initialize` handshake, every A2A task envelope, and every sub-agent delegation payload — and no component may mint a new root for work it did not originate.** Everything below is about what breaks when this is violated and how the violation stays invisible. ## What Was Observed A three-layer agent topology: a coordinator agent (C) that receives user requests, an A2A peer (P) it submits tasks to, and sub-agents (S1, S2) that C delegates to. Each of C, P, S1, S2 opens its own MCP client session to a shared tool server T. Observability was configured per-component: each component emitted spans to a collector tagged with its own `session_id` (MCP session for tool calls, A2A `task_id` for peer work, a per-sub-agent `agent_run_id` for delegation). The observed trace for a single user request looked complete: a root span for C, child spans for S1 and S2, grandchild spans for MCP tool calls, and a sibling subtree for P's task. Span counts matched expectations. Latency percentiles were plausible. The failure was found only when a request was replayed deterministically against a mock tool server and the *sequence* was compared to the recorded trace. Three concrete discrepancies: 1. **Cross-linked delegations under overlap.** C delegated to S1 at t=0 and S2 at t=40ms. Both sub-agents called T. The trace showed S2's first tool call nested under S1's delegation span. Cause: the collector's stitching rule joined tool-call spans to the "nearest open delegation span by start time," and S2's MCP `initialize` completed before S1's first tool call returned, so S2's session was bound to S1's open span. Nothing errored. The trace was simply a different causal graph than what executed. 2. **A2A task boundary root reset.** P, on receiving the A2A task, minted a fresh trace root because its A2A server implementation treated each inbound task as a new top-level operation. The task envelope carried `metadata.correlation_id`, which P *did* echo back in its completion message — but P's spans were emitted under P's new root, not under C's. The coordinator's trace and the peer's trace were two disconnected trees joined only by a string that appeared in a message body, not in any span parent pointer. Time-travel debugging across the boundary was impossible; you could see *that* P ran but not *where* in C's causal chain the failure originated. 3. **MCP session resumption orphaning.** S1's MCP session to T was dropped mid-task (server-side idle timeout) and resumed. The resumed session was assigned a new `session_id` by the server. S1's runtime correctly continued, but its span exporter keyed on `session_id`, so all post-resume tool calls landed in a *new* trace. The delegation span in C's trace showed S1's work ending at the drop, with the remainder appearing as an orphan trace with no parent. An operator reading C's trace would conclude S1's task failed at the drop point; it had actually completed. The common structure across all three: **the correlation key was a lifecycle-local identifier, not a propagated root.** Each component was internally consistent and externally incoherent. ## Condition of Validity The single-root invariant holds — and trace correlation is trustworthy — only when all of the following are simultaneously true: - **Root minted once, at the ingress boundary**, before any MCP `initialize`, A2A submission, or sub-agent spawn. The root is a value, not a reference to a mutable context object that can be reassigned. - **Root is carried in-band on every protocol hop**, not as ambient context. For MCP, this means the root (and the current span/parent) is part of the `initialize` params and every subsequent request's `_meta` or params — because MCP sessions are stateful and may be resumed or re-established, and ambient process context does not survive a session boundary. For A2A, the root is a required field in the task envelope and is echoed in every task status update and artifact, so the peer's spans can be parented even if the peer emits asynchronously after C has moved on. - **Sub-agent delegation payloads include the root and the delegating span ID**, and sub-agents are forbidden from minting a root. A sub-agent that cannot see a root must fail closed (refuse to emit as a new root) rather than silently start a new tree. - **Session identity and trace identity are decoupled.** A new MCP `session_id` after resume does not imply a new trace root; the root is a field on the request, the session ID is a field on the transport. Exporters must key on the root, not on the session. - **The join is by explicit parent pointer, never by heuristic.** No timestamp-proximity, no "nearest open span," no agent-name matching. If a span arrives without a resolvable parent pointer, it is quarantined as an orphan, not guessed into a tree. When any one of these is false, the invariant is violated and the resulting trace is not merely incomplete — it is *confidently incorrect*, which is worse, because it will be used to attribute latency and failures to the wrong component. ## Decision Boundary The operational decision is: **at each boundary, do you propagate the existing root or mint a new one?** The boundary is sharp: - **Propagate** when the work is causally downstream of an existing root — i.e., the component was invoked *because of* a request that already had a root. This covers: MCP session establishment by an agent that is itself mid-task; A2A task submission; sub-agent spawn; MCP session *resumption* (resume is not a new causal origin). - **Mint** only at true ingress: the first entry of a user/system request into the topology, or a genuinely independent scheduled trigger (a cron-fired agent run with no upstream request). A scheduled trigger that is *itself* downstream of a user action (e.g., a retry scheduled by a prior failed task) must propagate, not mint. - **Fail closed** when a component is invoked with work that is causally downstream but carries no root. This is the non-obvious case: the tempting behavior is to mint a root "so we at least have a trace." That behavior is what produces the disconnected-tree failure in observation 2. The correct behavior is to reject the invocation or emit a single, explicitly-flagged orphan span and surface the propagation gap as an error, because a trace that looks complete but cannot be joined is an observability liability. The trap is that minting a root on a downstream component *always succeeds* and *always looks better* in the short term. The cost is deferred and paid during incident response, when the trace you are reading is the wrong causal graph. ## Operational Effect With the invariant enforced, three things become true that were not before: 1. **Causal attribution is exact under concurrency.** Overlapping delegations (observation 1) cannot cross-link because the join is by propagated parent pointer, not by time. You can answer "which sub-agent's tool call caused the 4s tail" without replaying. 2. **Cross-boundary time-travel works.** A2A peer spans (observation 2) parent under the coordinator's delegation span because the root and parent span ID traveled in the envelope. The peer's asynchronous completion, arriving after C has moved on, still attaches to the correct point in C's tree. 3. **Session churn is invisible to the trace.** MCP resume (observation 3) yields a new transport session but the same trace root; the tool calls before and after the drop form one contiguous causal chain, and the drop itself is a span attribute, not a tree split. With the invariant violated, the operational effect is that **incident response silently regresses to log-grepping.** Traces are present and plausible, so they are trusted; but they attribute work to the wrong parent, so the first hypothesis an operator forms from the trace is wrong. The failure is not detected by monitoring (span counts, error rates, and latency percentiles are all normal) — it is detected only when a replay disagrees with the recorded trace, which is exactly the scenario where you can least afford to be debugging your debugger. The guardrail that bounds this: **a trace is only admissible as evidence if every span in it has a resolvable parent pointer to a single root, and the root matches the ingress root.** Any span failing parent resolution is quarantined, not stitched. The quarantine rate is the health metric for the invariant — a rising orphan rate means a boundary is minting instead of propagating, and it will surface before the cross-linking corruption does. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Optional class TraceRootViolation(RuntimeError): """Raised when a downstream component mints or loses a trace root instead of propagating the ingress root across a boundary.""" @dataclass(frozen=True) class TraceContext: root_id: str parent_span_id: Optional[str] origin: str # "ingress" | "mcp" | "a2a" | "delegation" @dataclass class BoundaryState: ingress_root: str seen_roots: set[str] = field(default_factory=set) def propagate_across_mcp_initialize( state: BoundaryState, incoming: Optional[TraceContext], session_id: str, is_resume: bool, ) -> TraceContext: """MCP session establish/resume must carry the root in-band. A resume is NOT a new causal origin; it must reuse the ingress root. """ if incoming is None: # Downstream work with no propagated root: fail closed, do not mint. raise TraceRootViolation( f"MCP initialize for session {session_id!r} (resume={is_resume}) " "arrived without a trace root; refusing to mint a new tree" ) if incoming.root_id != state.ingress_root: raise TraceRootViolation( f"MCP session {session_id!r} carried root {incoming.root_id!r} " f"but ingress root is {state.ingress_root!r}; a boundary " "component minted a divergent root" ) state.seen_roots.add(incoming.root_id) return TraceContext( root_id=state.ingress_root, parent_span_id=incoming.parent_span_id, origin="mcp", ) def propagate_across_a2a_task( state: BoundaryState, envelope_root: Optional[str], envelope_parent_span: Optional[str], task_id: str, ) -> TraceContext: """A2A task envelope must carry root + parent span; peer parents under it.""" if envelope_root is None: raise TraceRootViolation( f"A2A task {task_id!r} envelope has no root field; peer would " "emit a disconnected tree joined only by message-body strings" ) if envelope_root != state.ingress_root: raise TraceRootViolation( f"A2A task {task_id!r} root {envelope_root!r} != ingress root " f"{state.ingress_root!r}; peer minted a fresh root" ) return TraceContext( root_id=state.ingress_root, parent_span_id=envelope_parent_span, origin="a2a", ) def join_span( state: BoundaryState, span_root: str, span_parent: Optional[str], span_id: str, quarantine: list[str], ) -> None: """Admissibility: every span must resolve to the ingress root and a parent. Unresolvable spans are quarantined, never stitched by heuristic. """ if span_root != state.ingress_root or span_parent is None: quarantine.append(span_id) raise TraceRootViolation( f"span {span_id!r} (root={span_root!r}, parent={span_parent!r}) " "cannot be joined to the ingress tree; quarantined, not stitched" ) ```