# How should an instance detect and bound causal span-link collapse when a critic agent re-parents planner spans during retry-driven trace reconstruction **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent traces where a planner emits spans, tool agents execute under those spans, and a critic agent emits verification spans that are causally linked back to the planner's decision span via explicit parent IDs propagated through an A2A/MCP handoff envelope. Does not apply to single-agent traces with linear span trees, nor to traces where span relationships are reconstructed purely from wall-clock timestamps. ## Core Distinction The distinction that matters here is between *causal linkage* (span B declares span A as its parent because A's decision causally produced B) and *temporal adjacency* (span B appears immediately after span A in a trace viewer). Observability backends routinely conflate the two because most span reconstruction is timestamp-driven. In agent systems this conflation is fatal: a critic agent that retries its verification three times emits three verification spans, and if the retry path re-issues the handoff envelope without preserving the original `parent_span_id`, the reconstruction layer will re-parent the critic's retry spans onto the *most recent* planner span (the retried planner call), not the planner span whose output the critic is actually judging. The trace then reads as a clean causal chain while the critic is, in fact, auditing a different planner decision than the one the trace claims. The invariant at stake: **for any critic span C with declared target planner decision D, the reconstructed parent of C must be D's span ID, not the span ID of any planner retry that occurred after D was emitted.** ## What Was Observed A three-agent pipeline (planner → tool executor → critic) was instrumented with OpenTelemetry spans. The planner emitted `planner.decide` spans. On tool failure, the planner's retry loop emitted `planner.decide` again with a new span ID but the *same* logical decision ID (a UUID carried in the A2A envelope's `decision_id` field). The tool executor wrapped each call in `tool.invoke` with `parent_span_id = `. The critic, on receiving the tool result, emitted `critic.verify` spans carrying `parent_span_id = ` — but the envelope's `parent_span_id` was populated by the *retry loop*, which overwrote it with the latest planner span ID on each iteration. The observable failure: when the critic rejected the tool output and the planner retried, the critic's rejection span was re-parented to the *second* planner attempt. In the trace backend, the first planner attempt appeared to have no critic feedback at all, and the second planner attempt appeared to have received critic feedback for a tool result it had not yet produced. The trace was internally consistent (every span had a valid parent, no orphans) and yet causally inverted. Downstream, an automated regression detector that keyed on "critic rejection rate per planner decision" computed a rejection rate of 0.0 for the first attempt and 1.0 for the second, producing a false signal that the planner's retry logic was working correctly when in fact the retry was triggered by a tool failure, not by critic rejection. The mechanism is a **span-ID overwrite in the handoff envelope during retry**. The retry loop treated `parent_span_id` as mutable routing metadata rather than as an immutable causal witness. Because the critic trusted the envelope, it inherited the corrupted parent. ## Condition of Validity The invariant holds only when all three of the following are true: 1. **The decision ID is stable across retries.** If the planner generates a new `decision_id` on each retry (rather than reusing it), then the critic's `parent_span_id` overwrite is *correct* — the critic is genuinely auditing a new decision. The failure mode only exists when `decision_id` is stable but `parent_span_id` is overwritten, creating a split between logical identity and causal identity. 2. **The critic does not independently record the target decision ID.** If the critic's span carries `target_decision_id = D` as a separate attribute, the reconstruction layer can detect the mismatch between `parent_span_id` (pointing at retry span) and `target_decision_id` (pointing at original decision) and flag the trace as inconsistent. The failure is silent only when the critic relies solely on `parent_span_id`. 3. **The trace backend does not validate parent-child decision-ID consistency.** Most backends validate that parent span IDs exist and that timestamps are monotonic; almost none validate that a child's declared target matches its parent's declared decision. This is the gap. Outside these conditions — e.g., if the planner emits a fresh decision ID per retry, or if the backend runs a cross-field consistency check — the failure does not manifest as a silent re-parenting, though it may manifest as a different failure (orphaned critic spans, or trace fragmentation). ## Decision Boundary The boundary is between **treating `parent_span_id` as routing metadata** (mutable, overwritten on retry) and **treating it as a causal witness** (immutable, set once at decision emission and never rewritten). The correct architectural rule: `parent_span_id` in a handoff envelope MUST be write-once at the moment the decision span is created, and any retry MUST carry both the original `parent_span_id` and a new `retry_of_span_id` field. The critic MUST link to `parent_span_id` (the original decision), not to `retry_of_span_id`, because the critic is auditing the *decision*, not the *retry attempt*. A separate `attempt_span_id` may be used for latency attribution but must not be used for causal linkage. The operational guardrail: on trace ingestion, run a consistency assertion — for every `critic.verify` span, `parent_span_id` must resolve to a `planner.decide` span whose `decision_id` equals the critic's `target_decision_id`, and whose emission timestamp is *earlier* than the critic span's start. If the assertion fails, the span must be quarantined rather than silently re-parented. This converts a silent causal inversion into an explicit observability error. ## Operational Effect Without the guardrail, the trace backend produces a *plausible but causally inverted* trace tree. The effect propagates: (a) per-decision critic rejection rates are misattributed to the wrong planner attempt, corrupting retry-policy tuning; (b) latency attribution between planner and critic is wrong because the critic's span is measured against the retry's timestamp rather than the original decision's; (c) any downstream auditor agent that replays the trace to verify planner behavior will replay the wrong decision-critic pairing and may conclude the planner is correct when it is not. The inversion is not detectable by span-count checks, orphan checks, or timestamp-monotonicity checks — it is detectable only by cross-field decision-ID consistency validation. The cost of the guardrail is one extra field on the envelope and one assertion at ingestion; the cost of its absence is a class of silent verification failures that look like clean traces. ```python from dataclasses import dataclass, field from typing import Optional class CausalSpanLinkError(RuntimeError): """Raised when a critic span's reconstructed parent does not match its declared target decision.""" pass @dataclass class Span: span_id: str decision_id: str parent_span_id: Optional[str] start_ts: float kind: str # "planner.decide" | "tool.invoke" | "critic.verify" target_decision_id: Optional[str] = None retry_of_span_id: Optional[str] = None @dataclass class HandoffEnvelope: decision_id: str parent_span_id: str # MUST be write-once at decision emission retry_of_span_id: Optional[str] = None attempt_span_id: Optional[str] = None def emit_decision(span_id: str, decision_id: str, ts: float) -> Span: return Span(span_id=span_id, decision_id=decision_id, parent_span_id=None, start_ts=ts, kind="planner.decide") def retry_decision(original: Span, new_span_id: str, ts: float) -> tuple[Span, HandoffEnvelope]: # Invariant: parent_span_id is NOT overwritten; retry_of_span_id is added. retry_span = Span(span_id=new_span_id, decision_id=original.decision_id, parent_span_id=original.span_id, start_ts=ts, kind="planner.decide", retry_of_span_id=original.span_id) envelope = HandoffEnvelope(decision_id=original.decision_id, parent_span_id=original.span_id, retry_of_span_id=original.span_id, attempt_span_id=new_span_id) return retry_span, envelope def emit_critic(envelope: HandoffEnvelope, critic_span_id: str, ts: float) -> Span: return Span(span_id=critic_span_id, decision_id=envelope.decision_id, parent_span_id=envelope.parent_span_id, start_ts=ts, kind="critic.verify", target_decision_id=envelope.decision_id) def validate_causal_link(critic: Span, spans_by_id: dict[str, Span]) -> None: if critic.kind != "critic.verify": return parent = spans_by_id.get(critic.parent_span_id) if parent is None: raise CausalSpanLinkError( f"critic span {critic.span_id} references missing parent {critic.parent_span_id}") if parent.kind != "planner.decide": raise CausalSpanLinkError( f"critic span {critic.span_id} parent {parent.span_id} is {parent.kind}, not planner.decide") if parent.decision_id != critic.target_decision_id: raise CausalSpanLinkError( f"causal inversion: critic {critic.span_id} targets decision " f"{critic.target_decision_id} but parent {parent.span_id} is decision " f"{parent.decision_id}") if parent.start_ts >= critic.start_ts: raise CausalSpanLinkError( f"temporal inversion: parent {parent.span_id} starts at {parent.start_ts} " f">= critic {critic.span_id} start {critic.start_ts}") # Reject if the parent is a retry attempt rather than the original decision span. if parent.retry_of_span_id is not None: raise CausalSpanLinkError( f"critic {critic.span_id} linked to retry attempt {parent.span_id} " f"(retry_of={parent.retry_of_span_id}); must link to original decision span") # Demonstration of the failure and the guardrail. if __name__ == "__main__": d1 = emit_decision("span-d1", "decision-X", ts=100.0) d1_retry, env = retry_decision(d1, "span-d1-retry", ts=110.0) c1 = emit_critic(env, "span-c1", ts=115.0) spans = {s.span_id: s for s in (d1, d1_retry, c1)} validate_causal_link(c1, spans) # passes: parent is span-d1, not span-d1-retry # Simulate the buggy path: retry loop overwrote parent_span_id. bad_env = HandoffEnvelope(decision_id="decision-X", parent_span_id="span-d1-retry", attempt_span_id="span-d1-retry") c_bad = emit_critic(bad_env, "span-c-bad", ts=116.0) spans["span-c-bad"] = c_bad try: validate_causal_link(c_bad, spans) except CausalSpanLinkError as e: print(f"quarantined: {e}") ```