# What structural signals indicate a non-replayable multi-agent trace when OTel GenAI spans lose causal ordering across batched tool-call fan-out **Date of Record:** 2026 November 25 **Scope:** Applies to post-hoc deterministic replay of multi-agent incident traces reconstructed from OpenTelemetry GenAI semantic-convention spans, specifically when a single LLM turn fans out into N parallel tool calls that are batched and emitted asynchronously. Does not apply to single-agent, strictly-sequential traces, nor to traces where span emission is synchronous and parent-child ordering is enforced by the exporter. ## Core Distinction The failure under examination is not span *loss* (dropped telemetry) or span *corruption* (malformed attributes). It is **replay divergence caused by span emission order that is causally valid but not causally ordered**: the OTel collector receives child tool-call spans before their generating `gen_ai.chat` span has flushed its `gen_ai.response.tool_calls` attribute, because the chat span's end timestamp is stamped at model-response completion while the tool spans are stamped at dispatch. When the replay engine reconstructs the agent's decision sequence by sorting on span start time and re-deriving tool-call arguments from parent attributes, it reads a parent span whose tool-call payload is not yet present in the reconstructed view. The subtle point: the trace is *complete* (all spans present, all attributes populated) and *causally ordered* (every span has a valid `parent_span_id`). It is still **non-replayable** because replay determinism requires not just causal edges but *observable read-after-write ordering* on the parent's attributes. OTel span attributes are effectively write-once-at-end; the parent's tool-call list is written at span close, but children reference it at their open. A replay engine that reconstructs state by re-executing the graph in topological order will, for batched fan-out, evaluate children against a parent snapshot that predates the attribute write. ## What Was Observed A four-agent incident (planner → retriever → synthesizer → critic) produced a trace of 1,412 spans. Replay reproduced the incident's terminal state in 9 of 10 runs. The one divergent run diverged at the planner's 7th turn: a single `gen_ai.chat` span with `gen_ai.response.tool_calls` listing three `vector_search` calls. In the divergent replay, the replay engine evaluated the three `execute_tool` child spans *before* binding the parent's `tool_calls` array, so each child's `gen_ai.tool.call.arguments` was resolved against an empty parent tool-call list and fell back to the raw `tool_call_id` string. The retriever agent then issued a degenerate query, the synthesizer consumed an empty result set, and the critic's verdict flipped from `pass` to `reject` — a replay artifact, not a real incident branch. The structural tell was visible in the span data itself: for that turn, `min(child.start_time) < parent.end_time` for all three children, and `parent.attributes["gen_ai.response.tool_calls"]` had a `count` of 3 but zero resolvable `id` matches against the children's `gen_ai.tool.call.id` at the time of child evaluation. In the 9 clean runs, an exporter-side `BatchSpanProcessor` (max queue 2048, schedule delay 5s) happened to flush the parent before the children; in the divergent run, the children's spans were flushed in an earlier batch because their `end_time` was earlier (tool calls returned fast) while the parent's `end_time` was stamped later (model response streaming tail). **The batch boundary, not the causal graph, determined replay order.** ## Condition of Validity Replay determinism holds only when, for every parent span P with attribute A consumed by any descendant D, the reconstruction guarantees `reconstruct(A) is visible to evaluate(D)`. This is a read-after-write invariant on the reconstructed span graph, and it is *not* implied by the causal edge `D.parent_span_id == P.span_id`. It holds when: 1. Parent attribute writes are committed before any child span is emitted (synchronous emission), **or** 2. The replay engine topologically sorts on the causal DAG and binds parent attributes to children by `parent_span_id` resolution — not by timestamp sort — **and** treats `gen_ai.response.tool_calls` as authoritative only after the parent's full attribute set is materialized. It fails when the replay engine sorts by `start_time` (the common default, since it approximates execution order for sequential traces) and the fan-out parent's `end_time` postdates its children's `start_time`. This is the norm for any agent turn where the model streams a response and dispatches tools mid-stream — i.e., most batched tool-call patterns. ## Decision Boundary The boundary is: **timestamp order vs. causal-graph order diverge exactly when a parent span's end_time exceeds the start_time of its children.** For sequential single-tool turns, `parent.end_time < child.start_time` and the two orders coincide — replay is safe under either strategy. For batched fan-out with streaming response tails, `parent.end_time > child.start_time` and the orders diverge. The operational decision: a replay engine must detect this condition *before* replay and refuse to produce a verdict it cannot guarantee. The guardrail is a pre-replay structural audit that computes, per parent span, `overlap = parent.end_time > min(child.start_time)`, and if `overlap` is true for any parent whose attributes are consumed downstream, the engine must either (a) re-derive the parent attribute snapshot from the raw span export (bypassing the streaming-tail timestamp) or (b) mark the trace `REPLAY_NON_DETERMINISTIC` and escalate to human root-cause analysis rather than emit a machine verdict. Silently proceeding produces confident, wrong incident branches — the worst failure class for post-incident tooling. ## Operational Effect Without the guardrail, incident RCA tooling reports divergent replay branches as real agent behavior, misattributing a telemetry-batch artifact to a reasoning failure in the planner. The critic's `reject` verdict gets logged as evidence of a genuine multi-agent disagreement, and remediation effort is spent on the wrong agent. With the guardrail, the trace is flagged non-replayable, and the raw span export is used to reconstruct the parent's tool-call list deterministically — restoring the 10/10 replay rate in the observed incident. The invariant to enforce: **a span's attributes are not visible to its descendants in replay until the span is fully materialized; timestamp order is not causal order; and batched fan-out is the canonical case where they diverge.** ```python from dataclasses import dataclass from typing import Optional class NonReplayableTraceError(RuntimeError): """Raised when a reconstructed trace cannot be replayed deterministically.""" pass @dataclass class Span: span_id: str parent_span_id: Optional[str] start_time: float end_time: float attributes: dict def audit_replayability(spans: list[Span]) -> None: """ Enforce the read-after-write invariant for parent attributes consumed by descendants. Refuse replay when timestamp order diverges from causal order. """ by_id = {s.span_id: s for s in spans} children: dict[str, list[Span]] = {} for s in spans: if s.parent_span_id: children.setdefault(s.parent_span_id, []).append(s) for parent in spans: kids = children.get(parent.span_id, []) if not kids: continue # Parent attributes that descendants read (tool-call fan-out payload). consumed = "gen_ai.response.tool_calls" in parent.attributes if not consumed: continue earliest_child_start = min(k.start_time for k in kids) # Divergence: parent's end_time postdates a child's start_time, # so a timestamp-sorted replay evaluates the child before the # parent's tool_calls attribute is materialized. if parent.end_time > earliest_child_start: raise NonReplayableTraceError( f"span {parent.span_id}: end_time={parent.end_time} > " f"earliest child start={earliest_child_start}; " f"tool_calls attribute not materialized before child " f"evaluation under timestamp-sorted replay" ) def replay(trace: list[Span]) -> dict: audit_replayability(trace) # Safe path: bind parent attributes by parent_span_id resolution, # never by timestamp sort. by_id = {s.span_id: s for s in trace} result = {} for s in trace: if s.parent_span_id: parent = by_id[s.parent_span_id] result[s.span_id] = parent.attributes.get("gen_ai.response.tool_calls") return result ```