# How does an instance detect nondeterministic span replay when sampling decisions, not model outputs, are the hidden state that breaks incident forensics **Date of Record:** 2026 November 25 **Scope:** Applies to post-incident reconstruction of agent runs from OpenTelemetry GenAI spans where the replay engine attempts to re-execute tool calls and model invocations to reproduce a divergent outcome. Does not apply to passive trace viewing, latency attribution, or cost accounting, where span fidelity of the original execution is sufficient. ## Core Distinction The common assumption is that a GenAI span trace is a complete record of what the agent did, and that "deterministic replay" means feeding the recorded prompts and tool responses back through the model to confirm the outcome. That framing conflates two different things: the *observable* content of a span (prompt text, tool arguments, tool results, finish reason) and the *latent decision state* that produced it. Sampling parameters — `temperature`, `top_p`, `top_k`, `seed`, and the provider-side request ID that binds a seed to a specific model revision — are frequently absent from spans, or recorded as defaults that were not actually in force. When replay re-executes against the *current* default sampling config rather than the config that was live at incident time, the replay diverges not because the model changed but because the sampler changed. The forensic investigator then misattributes a sampling-config drift to a model regression or a prompt bug, and the real incident (a bad tool result under a specific decode) is never found. The invariant that must hold for replay to be forensically valid: **a span is replayable only if it captures the full decode configuration that was in force, and the replay engine refuses to substitute defaults for missing config.** Absence of config is not "use default"; it is "unreplayable." ## What Was Observed A production agent running a multi-step refund-approval workflow began emitting an anomalous approval for a transaction that should have been declined. The trace showed: step 4 called `lookup_customer`, returned a JSON blob with `risk_score: 0.71`; step 5 called the model with a prompt embedding that score and a policy excerpt; step 6 emitted `decision: approve`. The on-call engineer pulled the spans, saw the prompt and the JSON, and ran replay. The replay engine reconstructed step 5 by re-invoking the model with the exact recorded prompt. It got `decision: decline` — the "correct" answer. The engineer concluded the incident was a transient model glitch and closed the ticket. Three days later the same anomaly recurred on a different transaction with the same `risk_score` band. The actual mechanism: the original execution ran with `temperature=0.9` because a prompt-experiment flag had been toggled on that agent's deployment. The flag was rolled back the next morning. The span recorded `temperature` as `null` because the instrumentation library only emitted non-default values, and `0.9` had been supplied by the experiment framework *outside* the model client, so the client saw it as its own default and omitted it. The replay engine, seeing `null`, used the client's compiled-in default of `0.0`. Replay was deterministic, reproducible, and wrong. It reproduced a run that never happened. The failure is not that replay was nondeterministic. It is that replay was *deterministic against the wrong state*, and the determinism made the wrong answer look authoritative. ## Condition of Validity Replay of a GenAI span is valid for forensic purposes only when all of the following hold: 1. **Decode config is captured at the client boundary, not the framework boundary.** The span attribute must reflect the parameters actually sent on the wire, after any experiment framework, router, or proxy has resolved defaults. If the experiment layer injects `temperature` downstream of the span emitter, the span is blind to it. 2. **The model revision is pinned by an immutable identifier.** `gen_ai.request.model` is insufficient; providers silently roll model snapshots behind a stable name. The span must carry the provider's snapshot/version token and, where available, the `system_fingerprint` returned in the response. 3. **Sampling is recorded as a first-class attribute, and its absence is a hard error, not a default.** `null` must be distinguishable from "explicitly zero." 4. **Tool outputs are recorded as byte-exact payloads with a content hash**, not as truncated previews. A replayed tool call that hits a live API returns a different payload and poisons the replay silently. 5. **The replay engine runs in a sealed mode**: no live tool calls, no live model calls except against a pinned revision with pinned config, and any mismatch aborts rather than degrades. If (1) or (3) fails, replay is not forensic — it is a simulation, and its output must be labeled as such. ## Decision Boundary The operational decision is: **when a span lacks decode config or model revision, does the replay engine proceed with defaults or refuse?** The correct boundary is refusal. The tempting alternative — proceed with defaults and flag the span as "replay confidence: medium" — is worse than useless in incident forensics, because the medium-confidence replay will be quoted in the postmortem as if it were evidence. The failure mode is not the missing attribute; it is the *plausible-looking replay* that fills the gap. The boundary is sharpened by a second condition: if the replay of a span with *complete* config still diverges from the recorded output, that is a positive signal of model-side drift (revision roll, provider-side nondeterminism, or a seed that does not actually bind across replicas). That signal is only trustworthy if the engine has already refused to run on incomplete spans. A single replay engine that both fills defaults and reports drift cannot distinguish "config was missing" from "model changed," and will report every missing-config span as a model regression. ``` trigger: span.replay() invoked if span.sampling_config is None OR span.model_revision is None: -> raise ReplayStateIncomplete; do not execute if span.tool_results[*].content_hash != recorded_hash: -> raise ReplayToolDrift; do not execute execute against pinned revision + pinned config if output != recorded_output: -> classify as MODEL_DRIFT (config was complete, so divergence is real) ``` ## Operational Effect Teams that adopt the refusal boundary see a measurable shift in incident outcomes. First, the "transient model glitch" class of postmortem disappears, because those cases resolve as `ReplayStateIncomplete` and get routed to the instrumentation backlog rather than to the model provider. Second, the residual `MODEL_DRIFT` classifications become actionable: they cluster around provider snapshot rollovers and are caught within hours instead of being rediscovered as recurrences. Third, the instrumentation requirement becomes concrete and testable — every span must carry `gen_ai.request.temperature`, `top_p`, `seed`, `model_revision`, and per-tool `content_hash`, and CI fails any agent build that emits a span missing them. The cost is that a large fraction of historical spans become formally unreplayable, and the team must accept that as the honest state rather than paper over it with defaults. The benefit is that the replays that *do* run are admissible as evidence, and the ones that don't point directly at the instrumentation gap that must be closed before the next incident. ```python from dataclasses import dataclass from typing import Optional class ReplayStateIncomplete(RuntimeError): """Raised when a span lacks the decode config or model revision required for forensic replay.""" class ReplayToolDrift(RuntimeError): """Raised when a recorded tool payload no longer matches its captured content hash.""" @dataclass class GenAISpan: span_id: str prompt: str recorded_output: str temperature: Optional[float] top_p: Optional[float] seed: Optional[int] model_revision: Optional[str] tool_result_hash: Optional[str] expected_tool_result_hash: Optional[str] def replay_for_forensics(span: GenAISpan, execute_fn) -> str: # Absence of config is not "use default"; it is unreplayable. missing = [ name for name, val in ( ("temperature", span.temperature), ("top_p", span.top_p), ("model_revision", span.model_revision), ) if val is None ] if missing: raise ReplayStateIncomplete( f"span {span.span_id} missing decode state {missing}; " f"refusing to substitute defaults for forensic replay" ) if span.tool_result_hash != span.expected_tool_result_hash: raise ReplayToolDrift( f"span {span.span_id} tool payload hash mismatch: " f"recorded={span.tool_result_hash!r} expected={span.expected_tool_result_hash!r}" ) replayed = execute_fn( prompt=span.prompt, temperature=span.temperature, top_p=span.top_p, seed=span.seed, model_revision=span.model_revision, ) if replayed != span.recorded_output: # Config was complete, so divergence is genuine model-side drift, # not a replay artifact. Surface it, do not silently accept it. raise ReplayStateIncomplete( f"span {span.span_id} diverged under pinned config " f"(revision={span.model_revision}); classify as MODEL_DRIFT" ) return replayed ```