# In what scenarios must an instance distrust a replayed agent session reconstructed from OpenTelemetry GenAI spans, and how is replay divergence bounded **Date of Record:** 2026 December 3 **Scope:** Applies to forensic reconstruction of a completed agentic session from OTel GenAI spans (`gen_ai.*` semantic conventions) where the replay is expected to be behaviorally equivalent to the original run. Does not apply to live tracing, cost attribution, or latency SLO analysis, where exact token-level equivalence is not required. ## Core Distinction There are two distinct claims a forensic replay can make, and they are routinely conflated: 1. **Trace equivalence** — the span graph faithfully records the sequence of operations, tool invocations, and model calls that occurred. 2. **Behavioral equivalence** — re-executing the reconstructed inputs against the same model/tool versions reproduces the same outputs and the same downstream state transitions. OTel GenAI telemetry, by design, gives you (1) with high fidelity and (2) almost never. The GenAI semantic conventions capture *inputs and outputs as attributes* — `gen_ai.input.messages`, `gen_ai.output.messages`, `gen_ai.tool.call.arguments` — but a span is a *record of what happened*, not a *replayable program*. The boundary failure is treating a faithful trace as a deterministic program. It is not. The model call inside the span is a sampled draw from a conditional distribution, and the span records the draw, not the distribution. Any replay that re-invokes the model rather than replaying the recorded output is re-sampling, and the two samples diverge — silently, and often in ways that make the replay *look* correct while being forensically wrong. The non-obvious invariant: **a replayed session is only valid if every nondeterministic edge in the span graph is either (a) pinned to its recorded output, or (b) explicitly marked as a divergence point with a bounded downstream blast radius.** Most replay harnesses do neither; they pin the *first* model call (because it's the one the incident report quotes) and let subsequent calls re-sample. ## What Was Observed A support-triage agent session overran its token budget and terminated mid-task. Forensics replayed the session from exported OTLP JSON to determine whether the overrun was caused by a retrieval loop or by a model-side verbosity regression. The exported trace contained, per turn: one `gen_ai.chat` span with `gen_ai.input.messages` and `gen_ai.output.messages` as attributes, plus child `gen_ai.tool.call` spans carrying `gen_ai.tool.name` and `gen_ai.tool.call.arguments`. Crucially, the tool *result* was recorded as a span attribute (`gen_ai.tool.call.result`), but the model call's `temperature`, `seed`, and `top_p` were **not** in the span — they live in the client config, which was not versioned alongside the export. The replay harness did the following: it re-fed `gen_ai.input.messages` to the model, compared the new `gen_ai.output.messages` to the recorded one, and on mismatch flagged the span as "model nondeterminism." On the first turn the replayed output differed only in whitespace and the harness normalized it away. On turn 4, the replayed output selected a *different tool* (`search_kb` instead of `fetch_ticket_history`). The harness replayed the newly selected tool's call — but the span graph only contained the *original* tool's `gen_ai.tool.call.result` attribute. The harness therefore invoked the tool live, against a knowledge base that had been reindexed twice since the incident. The replay diverged at turn 4 and the divergence was attributed, in the final report, to "model nondeterminism at turn 7," because turn 7 was where the token count finally blew past the limit in the *replayed* run — three turns downstream of the actual divergence. The observed failure class is **divergence misattribution**: the replay's first observable symptom (budget exhaustion) is not the replay's first causal divergence (tool selection at turn 4), and the span graph contains no edge annotation that lets the harness locate the true divergence point. The trace was faithful. The replay was not. ## Condition of Validity A replay is behaviorally valid for incident attribution only when all of the following hold. Each is a precondition, not a nice-to-have; violating any one moves the replay from "forensic evidence" to "plausible narrative." - **Every model span is pinned, not re-sampled.** The replay must consume `gen_ai.output.messages` from the span as a *constant*, not re-invoke the model. Re-invocation is only permitted when the span carries a replay-safe marker (e.g., `gen_ai.request.seed` present *and* the provider guarantees seed determinism *and* the model version is pinned via `gen_ai.response.model` matching the deployed snapshot). Absent all three, re-invocation is a new experiment, not a replay. - **Every tool span's result is pinned.** `gen_ai.tool.call.result` must be present and non-null. If the tool result was truncated by an attribute-size limit (common: OTLP exporters cap string attributes at 4–64 KiB), the span is *partially pinned* and any replay that consumes the truncated result is replaying a different input than the original model saw. This is the single most common silent corruption: the trace validates, the schema passes, and the replay feeds the model a truncated tool result that the original run never saw. - **The span graph is causally closed.** For each model span, the set of tool results it consumed must be identifiable from `parent_span_id` / link relationships. If the agent framework emits tool spans as siblings rather than children of the model span that requested them (common in async tool dispatch), the replay cannot reconstruct *which* results were in-context at *which* model call. The graph is trace-equivalent but not behaviorally reconstructible. - **Sampling is off or accounted for.** If the trace was produced under head sampling, missing spans are indistinguishable from spans that never occurred. A replay over a sampled trace will treat an unrecorded tool call as "not made" and reconstruct a shorter, cleaner, wrong session. The invariant: *replay validity is bounded by the weakest pin in the span graph, and the divergence blast radius is the set of spans reachable downstream from the first unpinned edge.* ## Decision Boundary The decision is not "replay or don't replay." It is: **for a given incident, is the first unpinned edge upstream or downstream of the span under investigation?** - If the span under investigation is **upstream** of every unpinned edge (i.e., its inputs are fully pinned and its position in the graph precedes any re-sampling or live tool call), replay is admissible as direct evidence. The span's recorded output is the fact; the replay merely confirms the input reconstruction. - If the span under investigation is **downstream** of any unpinned edge, replay is admissible only as *counterfactual narrative*, explicitly labeled, and the report must name the first unpinned edge and the number of spans between it and the investigated span. A divergence three turns upstream of the symptom invalidates any causal claim linking the symptom to the investigated span. - If the first unpinned edge is **at or before** the session's first model call (e.g., no seed, no pinned model version), no replay is admissible for causal attribution at all. The trace is still valid as a *record*; it is not valid as a *program*. The boundary is sharp because the span graph is a DAG: reachability is computable, and the first unpinned edge is identifiable by a single forward pass. There is no judgment call about *whether* divergence occurred — only about whether it is upstream of the question being asked. ## Operational Effect The practical consequence is that forensic replay harnesses must be built as **pinned interpreters over the span DAG**, not as re-executors of the agent loop. Concretely: - Model outputs are read from `gen_ai.output.messages` and injected as constants; the model client is stubbed, not called. Any code path that can reach a live model or live tool during replay is a bug, because it converts a forensic tool into an experiment that silently mutates the evidence. - The harness computes, per span, a `pinned` boolean (all inputs and outputs present, no truncation, no sampling gap) and a `divergence_depth` (distance from the nearest unpinned ancestor). Spans with `divergence_depth > 0` are quarantined from causal claims. - Truncated attributes are detected by comparing recorded attribute length against the exporter's configured cap; a result at the cap is treated as suspect, not as data. - The replay report leads with the first unpinned edge, not with the symptom. "Budget exhausted at turn 7" is a symptom; "first unpinned edge at turn 4 (tool selection re-sampled, KB reindexed)" is the finding. This is the same discipline as deterministic record/replay in distributed systems, applied to a substrate where the "nondeterministic syscall" is a model call and the "clock" is a sampling temperature. The trace is the log; the replay is the interpreter; and an interpreter that re-executes the syscall instead of replaying its return value is not an interpreter. ```python import json from dataclasses import dataclass, field from typing import Optional class ReplayDivergenceError(RuntimeError): """Raised when a forensic replay would consume an unpinned edge as if it were pinned.""" pass @dataclass class Span: span_id: str parent_id: Optional[str] kind: str # "model" | "tool" attributes: dict attribute_cap_bytes: int = 64 * 1024 children: list = field(default_factory=list) def is_pinned(span: Span) -> bool: if span.kind == "model": out = span.attributes.get("gen_ai.output.messages") seed = span.attributes.get("gen_ai.request.seed") model = span.attributes.get("gen_ai.response.model") if out is None: return False # Re-sampling is only safe when seed AND pinned model version are present. if seed is None or model is None: return False return len(json.dumps(out).encode()) < span.attribute_cap_bytes if span.kind == "tool": result = span.attributes.get("gen_ai.tool.call.result") if result is None: return False # A result sitting exactly at the exporter cap is treated as truncated. return len(result.encode()) < span.attribute_cap_bytes return False def divergence_depth(span: Span, ancestors: dict) -> int: """Distance from the nearest unpinned ancestor; 0 means fully pinned lineage.""" depth = 0 node = span while node is not None: if not is_pinned(node): return depth node = ancestors.get(node.parent_id) depth += 1 return 0 def replay_span(span: Span, ancestors: dict, investigated: str) -> dict: depth = divergence_depth(span, ancestors) if span.span_id == investigated and depth > 0: first_unpinned = _first_unpinned(span, ancestors) raise ReplayDivergenceError( f"span {investigated} is {depth} edges downstream of unpinned span " f"{first_unpinned.span_id}; replay is counterfactual, not evidence" ) # Pinned interpreter: read recorded outputs, never invoke live model/tool. if span.kind == "model": return {"output": span.attributes["gen_ai.output.messages"], "pinned": True} return {"result": span.attributes["gen_ai.tool.call.result"], "pinned": True} def _first_unpinned(span: Span, ancestors: dict) -> Span: node = span while node is not None: if not is_pinned(node): return node node = ancestors.get(node.parent_id) return span ```