# Under what conditions must an instance treat a span-parent link across an A2A hop as non-authoritative for trace reconstruction **Date of Record:** 2026 November 27 **Scope:** Applies to observability pipelines that reconstruct end-to-end agent traces by stitching OTel spans emitted by distinct LLM agent instances communicating over A2A (or equivalent agent-to-agent) task-submission protocols. Does not apply to single-process agents emitting spans under one tracer, nor to purely synchronous in-process tool calls where parent context is passed by reference. ## Core Distinction The failure is not "missing spans" and not "clock skew." It is a **parent-link authority ambiguity**: the `parent_span_id` field on a span emitted by a downstream agent is a *claim* about causal ancestry, not a *fact* about it. In single-process tracing, the tracer guarantees that a child span's parent exists in the same trace and was created before the child. Across an A2A hop, that guarantee is severed at the protocol boundary: the downstream agent receives a serialized `traceparent` (or equivalent W3C trace-context carrier) as *data*, and it may (a) honor it, (b) ignore it and start a fresh root, (c) honor a stale or reused carrier from a pooled/retried request, or (d) honor a carrier whose referenced parent span was never exported because the upstream instance crashed before flushing. The distinction an observability pipeline must internalize: **trace context propagation is best-effort payload, not a durable causal assertion.** A span arriving with `parent_span_id = X` where `X` is absent from the collector's span store is not an error to be silently dropped nor a root to be silently promoted. It is an *orphan with an unresolved authority claim*, and the reconstruction algorithm's behavior on that class determines whether the reconstructed trace is a faithful DAG or a plausible-looking fiction. ## What Was Observed A three-hop pipeline: planner agent `P` submits a task to executor agent `E` over A2A; `E` invokes a retrieval sub-agent `R` via a second A2A hop. Each instance emits spans to a shared OTel collector. The pipeline reconstructs traces by grouping on `trace_id` and linking via `parent_span_id`. Observed failure trace, reproduced across ~4% of multi-hop tasks under retry load: 1. `P` creates span `p1` (root, `trace_id = T1`), serializes `traceparent` with `span_id = p1`, and enqueues the A2A request. The request is retried by the transport layer after a 30s timeout on the first attempt. 2. The **first attempt's** `traceparent` (still `p1`) is consumed by `E` on attempt 2, but `E` had *already* processed attempt 1 under a *different* internal task ID and emitted span `e1` with `parent_span_id = p1`. Attempt 2 emits `e2`, also with `parent_span_id = p1`. 3. `E`'s retry handler, on detecting the duplicate task, **reuses the cached result** and emits `e2` with `status = CACHED`, but `e2`'s `parent_span_id` still points at `p1` — not at `e1`. The DAG now shows `p1` with two children (`e1`, `e2`) that are semantically *the same logical step*, not two independent steps. 4. Downstream, `R` is invoked once (from `e1`'s execution path), emitting `r1` with `parent_span_id = e1`. But `e2`'s cached-result path returns *before* `R` is called, so `r1` has no sibling under `e2`. 5. The reconstruction algorithm, seeing `p1 → {e1, e2}` and `e1 → r1`, renders a trace where the planner "fanned out" to two executors, one of which did retrieval. **This never happened.** The true causal structure is `p1 → e1 → r1` with `e2` being an idempotent-replay artifact. The critical observation: **no span was lost, no clock was skewed, and every `parent_span_id` was individually valid.** The reconstruction was wrong because the pipeline treated parent links as authoritative causal edges without checking whether the referenced parent was *the same execution instance* that produced the child, or whether multiple children under one parent represented distinct logical steps versus replay duplicates. A second, sharper variant: when `P` crashed after enqueuing but before flushing `p1` to the collector, `E`'s spans arrived with `parent_span_id = p1` where `p1` was **never exported**. The pipeline's default policy was "promote orphans to roots." This silently split one logical trace into two roots (`e1` and `r1` under a new root `e1'`), and the end-to-end latency SLO monitor — which measured root-to-leaf duration — reported the executor's 200ms as the full task latency, omitting the planner's 8s of reasoning. The SLO dashboard showed a *healthy* p99 while the actual user-perceived latency was 40× higher. ## Condition of Validity A parent-link `child.parent_span_id = X` is **authoritative** for causal reconstruction if and only if all of the following hold at reconstruction time: - **Existence:** span `X` is present in the collector's span store for `child.trace_id`. (If absent, the link is an unresolved claim.) - **Temporal precedence:** `X.end_time <= child.start_time` OR `X.start_time <= child.start_time` with overlapping execution — i.e., the parent was live when the child began. A parent that *ended before* the child started is a *sequential* predecessor, not a concurrent parent; treating it as a parent inflates fan-out. - **Instance identity:** the `traceparent` carrier consumed by the child was minted by the *same logical execution* of `X` that emitted the span `X` — verifiable only if the carrier includes an execution nonce (e.g., `task_id` or `attempt_id`) that matches `X`'s attributes. Without this, a retried carrier is indistinguishable from a fresh one. - **Uniqueness of logical step:** among all children of `X` sharing the same `(operation_name, target_agent_id)` tuple, at most one is a *live* execution and the rest are marked replay/cache artifacts via a span attribute (e.g., `a2a.replay = true`). Absent this attribute, fan-out is unverifiable. When **any** of these fails, the parent link is **non-authoritative**: it may be retained as a *hint* for heuristic stitching, but it must not be used to assert causal edges in the reconstructed DAG, and it must not be used to compute latency attribution or fan-out metrics. The non-obvious part: condition 3 (instance identity) is the one most pipelines omit, because W3C trace-context has no field for it. The `traceparent` header carries `trace_id`, `parent_id`, and `flags` — nothing that distinguishes "the execution that minted this carrier" from "a retry of that execution." Pipelines that assume trace-context completeness will pass conditions 1 and 2 and fail 3 silently, producing the fan-out fiction above. ## Decision Boundary The pipeline must decide, per orphan or per ambiguous link, between three policies. The boundary is drawn by **whether the cost of a false causal edge exceeds the cost of an unresolved trace fragment** for the downstream consumer. - **Promote-to-root (default in most pipelines):** correct when the consumer is a latency SLO monitor keyed on root duration *and* orphan rate is low. Wrong when orphan spans are *late-arriving children* of a still-live parent — promotion splits a trace that would have stitched correctly 2s later. Guard: only promote after a **stitch grace window** (≥ max observed A2A hop latency, typically 30–120s) has elapsed since `child.end_time`. - **Drop-orphan:** correct when the consumer is a billing or token-accounting pipeline where a partial trace must not be double-counted. Wrong for SLO monitoring, where dropping the executor's span loses the only record of the slow hop. - **Hold-as-unresolved:** correct when the consumer is a causal-DAG analyzer (root-cause, fan-out detection). The span is retained with `causal_edge = UNRESOLVED` and excluded from DAG traversal but included in span-count and latency histograms. This is the only policy that is *safe* under condition-3 failure, because it refuses to assert an edge it cannot verify. The decision boundary is therefore: **if the pipeline's downstream consumer performs causal reasoning (attribution, fan-out, root-cause), the only valid policy for a link failing any of conditions 1–4 is HOLD-AS-UNRESOLVED, not promote-to-root.** Promotion is a lossy convenience that is acceptable only for consumers that do not traverse edges. ## Operational Effect Implementing the HOLD-AS-UNRESOLVED policy with a stitch grace window and an execution-nonce check changed the pipeline's behavior in three measurable ways: 1. **Fan-out fiction eliminated.** The `p1 → {e1, e2}` false fan-out disappeared once `e2` was tagged `a2a.replay = true` at emission (a one-line change in `E`'s retry handler) and the reconstructor required condition 4 for multi-child parents. Reported executor fan-out dropped from a spurious mean of 1.9 to a true 1.0 on the affected task class. 2. **Latency attribution corrected.** With promote-to-root disabled for causal consumers, the SLO monitor switched to a *trace-completion* metric that waits for the stitch window. The previously-hidden 8s planner reasoning appeared in p99, revealing that the real p99 was 40× the dashboard's reported value. The dashboard had been *confidently wrong* for weeks. 3. **Orphan rate became a first-class signal.** Unresolved links are now counted and alerted on. A spike in unresolved links is a leading indicator of upstream flush failures (condition 1) or carrier-reuse bugs (condition 3) — both of which were previously invisible because promotion-to-root masked them as "short traces." The invariant to encode: **a reconstructed trace is only as trustworthy as the weakest parent link it traverses; an unverifiable link must degrade the trace's causal claims, not silently strengthen them by promotion.** The pipeline must carry per-trace a `causal_confidence` derived from the fraction of links satisfying conditions 1–4, and downstream causal consumers must refuse to act on traces below a threshold rather than act on a fiction. ```python from dataclasses import dataclass from typing import Optional class NonAuthoritativeParentLink(RuntimeError): """Raised when a span's parent link fails causal-authority conditions.""" pass @dataclass class Span: trace_id: str span_id: str parent_span_id: Optional[str] operation: str target_agent_id: str start_time: float end_time: float execution_nonce: Optional[str] # minted into traceparent carrier; None if absent replay: bool = False STITCH_GRACE_SECONDS = 60.0 def assert_authoritative_parent( child: Span, parent: Optional[Span], now: float, consumer_does_causal_reasoning: bool, ) -> None: """ Enforce the four authority conditions before allowing a parent link to contribute a causal edge to the reconstructed DAG. """ if child.parent_span_id is None: return # genuine root, no claim to verify # Condition 1: existence (with stitch grace window for late arrival) if parent is None: if now - child.end_time < STITCH_GRACE_SECONDS: raise NonAuthoritativeParentLink( f"span {child.span_id}: parent {child.parent_span_id} not yet " f"exported; within stitch grace window. HOLD-AS-UNRESOLVED." ) if consumer_does_causal_reasoning: raise NonAuthoritativeParentLink( f"span {child.span_id}: parent {child.parent_span_id} never " f"exported after grace window; causal consumer must not promote " f"to root. HOLD-AS-UNRESOLVED." ) return # non-causal consumer may promote-to-root # Condition 2: temporal precedence if parent.end_time > child.start_time and parent.start_time > child.start_time: raise NonAuthoritativeParentLink( f"span {child.span_id}: parent {parent.span_id} starts after child; " f"link is a sequential predecessor, not a concurrent parent." ) # Condition 3: instance identity via execution nonce if child.execution_nonce is None or parent.execution_nonce is None: if consumer_does_causal_reasoning: raise NonAuthoritativeParentLink( f"span {child.span_id}: missing execution nonce on carrier; " f"cannot distinguish fresh execution from retried carrier. " f"HOLD-AS-UNRESOLVED." ) elif child.execution_nonce != parent.execution_nonce: raise NonAuthoritativeParentLink( f"span {child.span_id}: carrier nonce {child.execution_nonce} != " f"parent nonce {parent.execution_nonce}; stale/reused carrier." ) # Condition 4: replay uniqueness is enforced by the caller's fan-out # computation; here we only flag that a replay sibling exists. if child.replay and consumer_does_causal_reasoning: # replay spans are retained for counts but must not add DAG edges raise NonAuthoritativeParentLink( f"span {child.span_id}: replay artifact; excluded from causal DAG." ) ```