# When must an instance refuse to replay a trace it cannot re-derive: non-determinism provenance loss in agentic safety reconstruction **Date of Record:** 2026 November 27 **Scope:** Applies to post-hoc reconstruction of safety incidents from recorded agent traces where replay is used to establish causal claims (which tool call caused the harmful output, which memory retrieval poisoned the next step). Does not apply to single-shot, stateless LLM inference where the log is the ground truth and no re-execution is attempted. ## Core Distinction There are two things a trace replay can mean, and conflating them is the root of the failure. **Re-execution replay** feeds the recorded inputs back through the live model and tool stack and observes what happens *now*. **Re-derivation replay** takes the recorded outputs as fixed and recomputes only the *derivable* portions — the deterministic scaffolding around each step (prompt assembly, context-window packing, tool argument validation, memory key selection) — to reconstruct *why* a given output was admitted into the trace. Re-execution replay of a probabilistic agent is not a reconstruction of the incident. It is a fresh sample from the same distribution, and it will diverge at the first sampling nondeterminism (temperature, top-p, batch-order-dependent floating point, provider-side model version drift, or a tool returning a timestamp). The dangerous case is not that it diverges — everyone knows it diverges — but that it *usually converges*, and the converged replay is silently promoted to legal/forensic fact. The invariant that must hold before any replay is admitted as evidence is **provenance completeness**: every step in the trace must carry enough recorded state to be re-derived without re-sampling the model. When that invariant is violated for even one step, the instance must refuse re-execution replay for the entire causal chain downstream of that step, because a single unrederivable step contaminates every conclusion that depends on it. ## What Was Observed A tool-calling agent produced a harmful outbound action (a `send_email` with a recipient list assembled from retrieved memory). During incident review, the trace was replayed through the same model endpoint. The replay diverged: at step 7 the model selected `search_contacts` instead of the recorded `read_memory_slot`. Investigators, seeing the divergence, re-ran replay three more times; two of the four runs reproduced the recorded step 7, and the team concluded the trace was "reproducible" and treated the recorded path as the canonical causal chain. The actual defect was upstream and invisible to this procedure. The trace recorded the *selected* memory slot (`slot=preferences_v3`) but not the *retrieval candidate set* the model chose from. At original execution, the retriever had returned three slots; `preferences_v3` won on a marginal logit gap. At replay time, the retriever's index had been re-ranked by a background reindex, and `preferences_v3` was no longer in the candidate set at all. The two "successful" replays succeeded because the model, denied its original candidate, hallucinated a semantically similar slot name that happened to route to the same content — a *different mechanism producing the same surface action*. The replay matched; the causal explanation was wrong. The forensic conclusion ("the model was correctly following memory") was the opposite of the truth ("the candidate set was poisoned and the model had no correct option"). The failure signature: **action-level reproduction with mechanism-level divergence**. The trace is replayable at the level of "what did the agent do" and unreplayable at the level of "why did it do it," and the two are indistinguishable without recording the intermediate decision surface. ## Condition of Validity Re-execution replay is admissible as evidence for a step *s* only if the trace recorded, for every step from the last checkpoint to *s*: 1. The full **candidate set** presented to the model at each selection point (retrieved memory slots, offered tools, retrieved documents), not merely the selected element. 2. The **context-window packing order** and the exact rendered prompt bytes, since packing order changes attention and thus sampling. 3. The **model identity pin** — provider, model name, and the provider-issued version/hash if available — because silent model updates change the sampling distribution while leaving the name identical. 4. The **tool return values** verbatim, including any timestamp, random ID, or pagination cursor, because these feed forward into the next prompt. If any of these is absent for a step in the causal chain, the chain is **unrederivable** and the instance must fall back to re-derivation replay (treating recorded outputs as fixed and reconstructing only the deterministic scaffolding), and must mark every downstream causal claim as *inferred, not replayed*. The subtlety is that this condition is per-step and propagates forward: a missing candidate set at step 7 invalidates replay of steps 8..n even if steps 1..6 are fully pinned, because step 8's input prompt contains step 7's output *and* the model's state at step 7 is no longer reconstructible. ## Decision Boundary The boundary is not "did the replay reproduce the action." It is **"did the replay reproduce the action through the same decision surface."** Operationally: - **Admit re-execution replay** only when provenance completeness holds across the full causal chain *and* the replay reproduces both the action and the recorded intermediate selections (chosen tool, chosen slot, chosen argument set). Action match with intermediate mismatch is a *negative* result — it means the replay found a different path to the same behavior and the original path's explanation remains unverified. - **Downgrade to re-derivation replay** when any step lacks candidate-set or packing-order provenance. Re-derivation can still establish "the recorded inputs, given the recorded outputs, imply this downstream action" — a weaker but sound claim — without asserting the model *would* have done it again. - **Refuse replay entirely** when the model identity pin is absent or the provider has confirmed a version change between execution and replay. Here even re-derivation is compromised, because the deterministic scaffolding (tokenizer, context limits, tool-schema rendering) may have shifted. The trap to name explicitly: a replay that reproduces the action is *not* evidence of correctness, and a replay that diverges is *not* evidence of nondeterminism-as-root-cause. The only admissible signal is agreement of the *decision surface*, and that surface is almost never recorded by default. An instance that treats action-match as provenance-match will ratify a false causal chain with high confidence, which is worse than refusing to replay. ## Operational Effect The architectural consequence is that trace recording must be redesigned around **decision-surface capture**, not action logging. Every selection point must persist the candidate set and the selection, and the recorder must stamp a model-version pin at session start and verify it at replay. The replay engine must be a *two-mode* system with an explicit provenance gate: it inspects the trace, computes per-step completeness, and either enters re-execution mode (asserting decision-surface agreement) or downgrades to re-derivation mode (asserting only input-output implication). The gate must fail closed — a missing candidate set downgrades the whole downstream chain, never a single step — because the model's state is a function of its full history and a partially reconstructed history yields a partially reconstructed state. The invariant to encode: **a replay may not claim more causal certainty than its least-complete step supports.** This is a min-over-chain, not an average, and it is the boundary an instance must respect before it signs its name to a reconstruction. ```python from dataclasses import dataclass, field from typing import Optional class UnrederivableTraceError(RuntimeError): """Raised when a trace lacks provenance required for re-execution replay.""" pass @dataclass class Step: index: int action: str candidate_set: Optional[list] = None # tools/slots/docs offered to model packing_order: Optional[list] = None # context-window layout tool_return: Optional[str] = None # verbatim, incl. timestamps/ids model_pin: Optional[str] = None # provider + version hash @dataclass class Trace: steps: list model_pin: Optional[str] = None def assess_replay_admissibility(trace: Trace, replay_model_pin: str) -> str: """ Returns one of: 're-execution', 're-derivation', and raises UnrederivableTraceError when even re-derivation is unsound. """ if trace.model_pin is None: raise UnrederivableTraceError( "trace has no model identity pin; replay distribution unknown" ) if trace.model_pin != replay_model_pin: raise UnrederivableTraceError( f"model version drift: trace={trace.model_pin!r} " f"replay={replay_model_pin!r}; scaffolding may have shifted" ) # Min-over-chain: the least-complete step bounds the whole chain. for step in trace.steps: if step.candidate_set is None or step.packing_order is None: # Candidate set or packing order missing -> cannot re-sample # the model and claim decision-surface agreement. # Downgrade whole downstream chain to re-derivation. return "re-derivation" return "re-execution" def replay_and_assert(trace: Trace, replay_model_pin: str, observed_actions: list) -> str: mode = assess_replay_admissibility(trace, replay_model_pin) if mode == "re-execution": # Action match alone is insufficient; decision surface must match. for step, observed in zip(trace.steps, observed_actions): if observed.get("action") != step.action: # Divergence is a negative result, not a nondeterminism excuse. raise UnrederivableTraceError( f"step {step.index}: action diverged under re-execution; " "causal chain unverified" ) if observed.get("candidate_set") != step.candidate_set: # Same action, different decision surface: false convergence. raise UnrederivableTraceError( f"step {step.index}: action matched but candidate set differed; " "mechanism-level divergence, explanation invalid" ) return "re-execution: decision-surface agreement confirmed" # re-derivation: recorded outputs fixed, only scaffolding recomputed. return "re-derivation: input-output implication only; causal claim downgraded" ```