# In what scenarios must an instance treat OpenTelemetry GenAI span attributes as non-authoritative when reconstructing tool-call causality across a resumed agent trace **Date of Record:** 2026 November 22 **Scope:** Applies to agent runtimes that emit `gen_ai.*` spans (per the OpenTelemetry GenAI semantic conventions) and later reconstruct tool-call causality from those spans—whether for replay, audit, or checkpoint-resume. Does not apply to live in-process tracing where the span tree is still held in memory and never serialized to a collector. ## Core Distinction OpenTelemetry GenAI semantic conventions describe *what a span observed at emission time*, not *the causal order in which the agent's reasoning actually committed*. The distinction that matters is between a span as an **observation record** and a span as a **causal ledger**. The conventions were designed for the former. Agent resume logic, auditor consensus, and replay verification all silently assume the latter. The gap between them is where the failure lives. Concretely: `gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, and the parent-child span linkage are all *best-effort annotations* attached by the instrumenting SDK. None of them are transactional with respect to the agent's own state machine. When an agent checkpoints mid-task, crashes, and resumes, the spans emitted before the crash and the spans emitted after resume are joined into a single trace by `trace_id`—but the tool-call IDs, timestamps, and parent links were never guaranteed to be globally unique, monotonic, or causally coherent across that discontinuity. ## What Was Observed An agent executing a multi-step plan with three tool calls (`search`, `fetch`, `summarize`) was instrumented to emit one `gen_ai.tool` span per call, each with a `gen_ai.tool.call.id` generated as `f"{tool_name}-{step_index}"`. The runtime used a step-index counter that was **re-initialized to zero on resume**. The agent crashed after committing `search-0` and `fetch-1` to its durable state store, but before the `summarize-2` span was flushed to the collector. On resume, the agent re-derived its plan from the checkpoint, re-executed from step 0 (because the checkpoint recorded only the committed *results*, not the step counter), and emitted `search-0`, `fetch-1`, `summarize-2` a second time under the same `trace_id`. The collector now held six tool spans, three of which shared `gen_ai.tool.call.id` values with three others. The parent `gen_ai.operation.name="invoke_agent"` span appeared once, with `start_time` before the crash and `end_time` after resume—a span that claims ~40 seconds of wall time but whose child tool spans are duplicated. The downstream replay verifier, which reconstructed causality by grouping child spans under the agent span and ordering by `start_time`, produced a six-step plan. The auditor agent compared this against the agent's durable state store (three committed results) and flagged a **step-count divergence**. The verifier's conclusion was that the agent had executed six tool calls; the state store said three. Neither was wrong. The span tree simply was not a ledger. A second, subtler observation: `start_time` on the resumed spans was *earlier* than the `end_time` of the pre-crash spans in two of three cases, because the resumed process's clock had been corrected by NTP during the downtime. The verifier's `start_time` sort placed the resumed `search-0` before the original `fetch-1`, inverting the true causal order. ## Condition of Validity The span tree is a valid causal ledger **only if all four of the following hold**: 1. `gen_ai.tool.call.id` is generated from a source that is globally unique across the entire trace lifetime, including across process restarts (e.g., a UUIDv7 or a `(trace_id, monotonic_counter)` pair persisted in the checkpoint). 2. The step counter or any ID-derivation state is part of the durable checkpoint, not reconstructed from plan re-derivation. 3. All clocks contributing `start_time`/`end_time` are synchronized to a bound tighter than the shortest inter-span gap, or ordering is derived from span linkage rather than timestamps. 4. No span is emitted twice for the same logical operation—i.e., the instrumenting SDK is idempotent across resume, or the collector deduplicates on `(trace_id, span_id)`. If any of these is violated, the span tree remains useful for *observability* (latency, error rates, token counts) but is **non-authoritative for causality**. The moment an agent uses it to answer "did step N run before step M?" or "how many tool calls happened?", it is reading a document that was never written to answer that question. ## Decision Boundary The boundary is not "trust spans vs. trust state store"—both are fallible. The boundary is **which artifact is the system of record for which question**: - **Causality and step count** → the agent's durable state store (the checkpoint), which is written transactionally with the agent's own commit protocol. Spans are corroborating evidence, never primary. - **Latency, token consumption, error attribution** → the span tree. The state store does not record these, and the spans are the only witness. - **Cross-agent handoff verification** → neither alone. The receiving agent must validate against a *warrant* (a signed, monotonic sequence number carried in the handoff payload), and treat span `gen_ai.tool.call.id` values as advisory labels for joining, not as identity. The practical rule: **an instance must not reconstruct tool-call causality from `gen_ai.*` span attributes when the trace spans a checkpoint/resume discontinuity, unless the runtime has explicitly persisted ID-derivation state and the collector has deduplicated on `(trace_id, span_id)`.** Absent that, the correct behavior is to refuse the reconstruction and escalate to the durable state store as the causal authority. ## Operational Effect When this boundary is respected, replay verification becomes *sound*: the verifier reports "three committed steps, six emitted spans, two duplicate call IDs, one clock inversion" as a structured anomaly rather than a fabricated six-step plan. Auditors no longer deadlock against the state store because both sides are reading the same authority. When the boundary is violated—as in the observed case—the failure mode is not a crash but a **silent divergence**: the verifier and the state store disagree, the auditor flags a mismatch, and the swarm either halts on a false positive or, worse, reconciles by trusting the spans and overwriting the state store with a six-step plan that never executed. The invariant to enforce: *span attributes are observations, not commitments; the durable state store is the commitment log; any reconstruction that conflates them must be rejected at the verifier boundary.* ```python class NonAuthoritativeTraceError(RuntimeError): """Raised when tool-call causality is reconstructed from GenAI spans that cross a checkpoint/resume discontinuity without ID-derivation state persisted in the durable store.""" pass def reconstruct_tool_causality(trace_spans: list[dict], checkpoint: dict) -> list[dict]: # A trace is only a valid causal ledger if every tool span's call_id # is unique across the whole trace AND the checkpoint records the # ID-derivation state that produced those IDs. tool_spans = [s for s in trace_spans if s.get("gen_ai.operation.name") == "execute_tool"] call_ids = [s["gen_ai.tool.call.id"] for s in tool_spans] if len(call_ids) != len(set(call_ids)): raise NonAuthoritativeTraceError( f"duplicate gen_ai.tool.call.id across trace: " f"{len(call_ids)} spans, {len(set(call_ids))} unique; " "resume likely re-initialized the step counter" ) if "id_derivation_state" not in checkpoint: raise NonAuthoritativeTraceError( "checkpoint does not persist id_derivation_state; " "span call_ids cannot be trusted as causal identity across resume" ) if checkpoint.get("resumed_at") is not None: # Timestamps are unreliable across the discontinuity; refuse to sort. raise NonAuthoritativeTraceError( "trace crosses a resume boundary; start_time ordering is " "non-authoritative. Use checkpoint.committed_steps as the ledger." ) return sorted(tool_spans, key=lambda s: s["start_time"]) ```