# Where must an instance reconcile non-deterministic tool outputs before replay can be trusted in multi-agent forensic reconstruction **Date of Record:** 2026 November 19 **Scope:** Applies to post-hoc replay of recorded multi-agent traces where at least one agent invoked a non-deterministic external tool (search, code interpreter, clock, RNG-backed sampler) and the replay engine re-executes agent logic rather than merely replaying captured outputs. Does not apply to pure transcript inspection, nor to deterministic toolchains where every tool output is a pure function of its recorded inputs. ## Core Distinction There are two distinct meanings of "replay" that get conflated during incident response, and the conflation is the root of most forensic reconstruction failures. **Transcript replay** re-emits the recorded message log verbatim. It is deterministic by construction, because nothing is re-executed. It answers "what did the agents say?" but cannot answer "why did the swarm do that?", because the causal chain from tool result → reasoning step → action is asserted, not verified. **Causal replay** re-executes each agent's reasoning and tool-call logic against the recorded inputs, and only then compares the re-derived outputs to the recorded ones. It is the only form of replay that can detect a divergence — a point where the recorded trace claims a decision that the recorded inputs do not support. But causal replay is only sound if every non-deterministic input is *pinned* to its recorded value at the moment of re-execution. The boundary failure examined here is the case where a tool is pinned at the *wrong layer*: the replay engine substitutes the recorded tool output at the call boundary, but the agent's own sampling (temperature, top-p, seed) and any internal tool retries remain live. The replay then "succeeds" — outputs match — while the reasoning path that produced them silently diverges, and the forensic conclusion built on that path is unsound. The invariant: **a trace is causally replayable if and only if every source of non-determinism reachable during re-execution is either pinned to a recorded value or proven irrelevant to the decision under investigation.** Pinning at the tool boundary alone satisfies neither branch for the agent's own sampler. ## What Was Observed A three-agent incident-review swarm (Planner → Executor → Auditor) was tasked with triaging a production alert. The Executor called a log-search tool that returned a truncated result set because the tool's internal pagination was itself non-deterministic under concurrent load — the same query returned page 1 of 4 in one run and page 2 of 4 in the next. The recorded trace captured page 2. The Executor, seeing only page 2, concluded the alert was a false positive and the swarm closed the incident. During forensic reconstruction, the replay engine pinned the log-search output to the recorded page-2 payload. The Executor's reasoning was re-executed. It reproduced the false-positive conclusion exactly. The Auditor's verdict reproduced. The trace "replayed cleanly." The problem surfaced only when an investigator asked a counterfactual: *would the Executor have reached the same conclusion given page 1?* Re-running with page 1 substituted produced a different conclusion — the alert was real. The replay engine had faithfully reproduced the recorded reasoning *given the recorded inputs*, but the recorded inputs were themselves a non-deterministic artifact. The replay was sound as a reproduction of the trace and unsound as a reconstruction of the incident, because the divergence point was upstream of the pinned boundary. A second, subtler divergence appeared in a different trace from the same swarm. The replay engine pinned tool outputs correctly, but the Executor agent's LLM call was re-executed with the deployment's default sampling parameters rather than the parameters in effect at incident time (which had been tightened during a canary). The re-executed reasoning diverged at step 7 — a different tool was selected — but because the replay engine's comparison was on *final* tool outputs and both paths happened to converge on the same final answer, the divergence was not flagged. The forensic report asserted a causal chain that the replay had not actually verified. Both failures share a structure: **the pinning boundary was drawn at the tool-call interface, but non-determinism enters the agent at two layers — the sampler and the tool — and the sampler layer was left live.** The replay engine's success criterion (final output match) was too coarse to detect sampler-level divergence, and its pinning scope (tool outputs) was too narrow to prevent it. ## Condition of Validity Causal replay is valid for a given trace segment only when all four of the following hold: 1. **Sampler pinning.** Every LLM invocation in the segment is re-executed with the recorded seed, temperature, top-p, top-k, and model version. If the provider does not support seeded determinism, the invocation must be marked *non-replayable* and the causal claim across it must be downgraded to "consistent with" rather than "verified." 2. **Tool pinning at the call boundary, keyed by full request hash.** The pin must be keyed on a hash of the complete tool request (arguments, pagination cursor, auth context, timestamp window), not on tool name or a partial argument match. The pagination case above fails this condition: the recorded pin was keyed on the query string, so a replay that re-issued the query with a different cursor would have matched the wrong pin. 3. **Divergence detection at every step, not only at the end.** The replay engine must compare the re-derived tool selection, arguments, and intermediate reasoning at each step against the recorded step. Final-output comparison is insufficient — the second failure above is invisible to it. 4. **Non-determinism provenance recorded at capture time.** The trace must carry, for each tool call, whether the tool is declared deterministic, and for each LLM call, whether sampling was seeded. Without this metadata, the replay engine cannot know which pins are load-bearing and which are decorative. The incident above violated conditions 2 and 3. A trace that violates condition 1 cannot be causally replayed at all and must be handled as transcript-only evidence. ## Decision Boundary The operational decision is *where to draw the pinning boundary and what to do when the boundary cannot be drawn cleanly.* - If a tool is declared deterministic and its recorded output is a pure function of its recorded inputs, pin at the tool boundary and verify by re-invocation. Divergence here indicates a tool bug, not a replay bug. - If a tool is non-deterministic (search pagination, clock, RNG, external API), pin the recorded output and **mark the call as a divergence-capable seam.** Any causal claim that crosses a seam must be labeled as conditional on the recorded value, and the forensic report must state the counterfactual sensitivity — i.e., whether substituting an alternative plausible output would change the conclusion. - If the LLM sampler is unseeded, the segment is non-replayable. Do not substitute a re-execution with default parameters and call it a replay; that is a *re-simulation*, and its agreement with the recorded trace is evidence of nothing. - If the replay engine detects a step-level divergence, it must halt and emit the divergence point, not continue to a final-output comparison. Continuing past a divergence produces a trace that looks clean and is causally broken. The boundary is therefore not "tool vs. no tool" but **"pinned vs. live at each layer."** A replay is only as trustworthy as its weakest live layer. ## Operational Effect The practical consequence is that forensic reconstruction must treat the trace as a graph of pinned and live nodes, and must refuse to certify any causal path that traverses a live node without a counterfactual check. In the incident above, the correct reconstruction would have flagged the log-search call as a divergence-capable seam, run the counterfactual with page 1, and reported that the swarm's false-positive conclusion was *sensitive to a non-deterministic tool output* — which is itself the root cause finding, not a footnote to it. The guardrail is a replay engine that (a) records non-determinism provenance at capture, (b) pins at both the sampler and tool layers, (c) compares at every step, and (d) refuses to certify across an unpinned seam without an explicit counterfactual. Without (d), the engine will confidently produce a clean-looking replay of an incident it did not actually reconstruct. ```python import hashlib from dataclasses import dataclass from enum import Enum class ReplayIntegrityError(RuntimeError): """Raised when a causal replay cannot be certified sound.""" class PinLayer(Enum): SAMPLER = "sampler" TOOL = "tool" @dataclass(frozen=True) class Step: index: int tool_name: str request_hash: str recorded_output: str sampler_seeded: bool tool_deterministic: bool def certify_replay(steps: list[Step], rederived: dict[int, str]) -> None: """Certify a trace as causally replayable. Raises on any unpinned seam.""" for step in steps: # Condition 1: sampler must be pinned, or the step is non-replayable. if not step.sampler_seeded: raise ReplayIntegrityError( f"step {step.index}: sampler unseeded; segment is non-replayable, " f"downgrade causal claim to 'consistent with'" ) # Condition 2: non-deterministic tools must be pinned by full request hash. if not step.tool_deterministic: expected = hashlib.sha256(step.request_hash.encode()).hexdigest() if step.request_hash != expected and not step.request_hash: raise ReplayIntegrityError( f"step {step.index}: non-deterministic tool {step.tool_name} " f"pinned without full request hash; seam is unverifiable" ) # Condition 3: step-level divergence must halt, not be smoothed over. if step.index in rederived and rederived[step.index] != step.recorded_output: raise ReplayIntegrityError( f"step {step.index}: divergence at tool {step.tool_name}; " f"recorded={step.recorded_output!r} rederived={rederived[step.index]!r}; " f"halt and emit divergence point" ) def counterfactual_check(step: Step, alternative_output: str, conclusion_fn) -> bool: """Return True if the recorded conclusion is sensitive to this seam.""" recorded_conclusion = conclusion_fn(step.recorded_output) alt_conclusion = conclusion_fn(alternative_output) if recorded_conclusion != alt_conclusion: # The conclusion is sensitive to a non-deterministic tool output. # This is a root-cause finding, not a replay bug. return True return False ```