# Under what conditions must an instance treat an OpenTelemetry GenAI span as authoritative for cross-agent causal ordering, and when does span modeling silently invert the causal graph? **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems that emit OpenTelemetry traces using the GenAI semantic conventions (`gen_ai.*` attributes) where spans are joined into a causal graph across agent boundaries via `trace_id`/`span_id`/`parent_span_id`. Does not apply to single-process, single-agent instrumentation where the span tree is generated by one synchronous runtime and never crosses a handoff boundary. ## Core Distinction The GenAI semantic conventions were designed to describe *model invocations* (`gen_ai.operation.name`, `gen_ai.request.model`, token usage, finish reasons), not *agent-to-agent causal handoffs*. When two agents exchange a baton, the natural instrumentation instinct is to make the receiver's root span a child of the sender's span. This produces a span tree that *looks* causally correct but encodes a false invariant: it conflates **wall-clock happens-before** (which the transport guarantees) with **logical span parentage** (which the OTel model assumes is a single-producer, monotonic nesting relation). The core distinction is between a span being *temporally downstream* and a span being a *child in the causal graph*. A receiver agent's first span is always temporally downstream of the sender's last span. It is only a causal child if the sender's span was still open (or its context was explicitly propagated) at the moment the receiver began. When the sender's span has already ended — the common case in asynchronous baton-passing — attaching the receiver as a child creates a span whose `start_time` is strictly greater than its parent's `end_time`. OTel's data model permits this; the trace visualizer and most backends do not treat it as anomalous. The result is a well-formed trace that misrepresents causal structure. ## What Was Observed A three-agent pipeline (planner → executor → auditor) using an A2A-style handoff over a message queue. Each agent wrapped its work in a root span and propagated `traceparent` in the message envelope. The executor's span was instrumented as a child of the planner's span; the auditor's as a child of the executor's. Under normal load, the trace rendered as a clean linear chain. Under a specific trigger — the planner's span closing *before* the executor dequeued the message — the following trace shape appeared: - `planner.turn` span: `start=1000ms`, `end=1400ms`, `span_id=A` - `executor.turn` span: `start=1520ms`, `end=2100ms`, `span_id=B`, `parent_span_id=A` - `auditor.turn` span: `start=2200ms`, `end=2600ms`, `span_id=C`, `parent_span_id=B` This is well-formed. But under a *retry* condition, the executor's first attempt failed and was rescheduled. The retry produced a second executor span `B'` with `start=1700ms`, also `parent_span_id=A`. Now the trace contains two children of `A` that are *sequentially ordered by wall clock* but *siblings in the causal graph*. A downstream auditor that reconstructs causality by walking `parent_span_id` edges sees `B` and `B'` as concurrent branches, not as a retry sequence. The retry's causal dependency on `B`'s failure is lost. The span model has no field for "this span is a retry of that span." The GenAI conventions define `gen_ai.usage.*` and `gen_ai.response.finish_reasons` but nothing that encodes intra-agent causal sequencing across retries. The only signal is wall-clock ordering, which the causal graph explicitly discards. ## Condition of Validity A GenAI span is authoritative for cross-agent causal ordering **if and only if** all of the following hold: 1. **Parent-open invariant:** The parent span's `end_time` is either unset (still open) or strictly greater than the child's `start_time`. If this fails, the parent-child edge is a *context propagation artifact*, not a causal relation, and must be treated as advisory only. 2. **Single-producer-per-parent:** Each `parent_span_id` has exactly one child per logical handoff. Retries, replays, and speculative executions must be modeled as *sibling spans under a shared synthetic parent* (e.g., a `gen_ai.agent.handoff` span that wraps all attempts), not as siblings under the original parent. 3. **Terminal-span disambiguation:** The receiving agent must not attach its root span directly to the sender's *last* span if the sender may retry. It must attach to a handoff span that outlives all attempts. 4. **No cross-trace joins:** Causal edges never cross `trace_id` boundaries. If a handoff spans a trace boundary (e.g., a queue that drops context), the receiving trace's root span must carry an explicit `gen_ai.agent.parent_trace_id` attribute, and the causal graph must be reconstructed by attribute join, not by `parent_span_id`. When any of these fail, the span tree is *structurally valid but semantically inverted*: it renders as a tree, but the tree's branching factor encodes retries as concurrency and handoffs as nesting. ## Decision Boundary The operational decision is: **does the consumer of the trace need causal ordering or temporal ordering?** - If the consumer is a latency dashboard, temporal ordering (wall clock) is sufficient, and the span tree's parentage is irrelevant. No guardrail needed. - If the consumer is an *auditor agent* or a *replay verifier* that reconstructs "what caused what" — the common case in multi-agent verification — then parentage is load-bearing, and the parent-open invariant must be enforced at instrumentation time, not at query time. The boundary is crossed the moment a downstream agent uses `parent_span_id` to decide whether to trust, replay, or escalate. At that point, a structurally valid trace with an inverted causal graph is a *silent correctness failure*: the auditor sees two concurrent executor branches, concludes the executor ran speculatively, and applies a merge policy that never ran. The guardrail is a **handoff span**: a synthetic span opened by the sender *before* dispatching the message, closed by the receiver *after* acknowledging it, and used as the parent for all receiver attempts. This span's lifetime strictly contains all attempts, restoring the parent-open invariant and collapsing retries into a single causal edge. ## Operational Effect Without the handoff span, retries and replays inflate the causal graph's branching factor. An auditor reconstructing causality from `parent_span_id` edges sees N concurrent children where there was one logical handoff with N-1 retries. The auditor's consensus logic — typically "if branches disagree, escalate" — fires on retries that were already resolved by the executor's own retry policy. This produces false escalations, which in a verification swarm manifest as *auditor deadlock*: the auditor waits for branches that will never report because they are the same branch, retried. With the handoff span, the causal graph's branching factor equals the number of *logical* handoffs, and retries are internal to a single child. The auditor's consensus logic sees one branch per handoff and correctly attributes disagreement to the executor's retry, not to concurrent speculation. The invariant to enforce: **for every `parent_span_id` edge in a multi-agent trace, the parent's `end_time` must be unset or greater than the child's `start_time`, and the parent must have exactly one child per logical handoff.** Violations are not trace errors — they are causal-graph inversions, and must be rejected by any consumer that uses parentage for verification. ```python class CausalGraphInversionError(RuntimeError): """Raised when a GenAI span tree encodes a false causal edge.""" pass def validate_handoff_edge(parent_span: dict, child_span: dict) -> None: parent_end = parent_span.get("end_time_ns") child_start = child_span.get("start_time_ns") if parent_end is not None and child_start is not None and parent_end <= child_start: raise CausalGraphInversionError( f"parent span {parent_span['span_id']} ended at {parent_end}ns " f"before child {child_span['span_id']} began at {child_start}ns; " f"edge is a context-propagation artifact, not a causal relation" ) if not parent_span.get("gen_ai.agent.handoff", False): raise CausalGraphInversionError( f"parent span {parent_span['span_id']} is not a handoff span; " f"retries of {child_span['span_id']} will appear as concurrent siblings" ) def reconstruct_causal_chain(spans: list[dict]) -> list[str]: by_id = {s["span_id"]: s for s in spans} for child in spans: parent_id = child.get("parent_span_id") if parent_id is None: continue parent = by_id.get(parent_id) if parent is None: raise CausalGraphInversionError( f"child {child['span_id']} references missing parent {parent_id}" ) validate_handoff_edge(parent, child) return [s["span_id"] for s in spans] ```