# What structural signals indicate replay divergence caused by non-deterministic tool-call ordering in agentic forensic reconstruction **Date of Record:** 2026 November 27 **Scope:** Applies to post-incident replay of recorded agent sessions where the audit log stores tool invocations, model outputs, and timestamps but not a canonical causal ordering across concurrent or retried tool calls. Does not apply to single-threaded sessions with strictly serialized tool dispatch and a total-order event log. ## Core Distinction A forensic replay is *faithful* when re-executing the recorded session against recorded tool outputs yields the same final agent state and the same decision trace. It is *structurally divergent* when the replay produces a different state not because any individual record is wrong, but because the *ordering* of tool calls within a reasoning step was not captured, and the replay engine's scheduling differs from the original runtime's scheduling. The failure is not data corruption and not model non-determinism at the sampling layer (temperature is often zeroed for replay). It is an ordering-invariance violation: the session's outcome depends on the interleaving of side-effecting tool calls whose relative order the log does not pin down. The tell is subtle. Replay completes without error, every tool output matches its recorded checksum, and yet the reconstructed memory state or the final tool-call payload diverges. The auditor who checks "did every recorded output match?" answers yes; the auditor who checks "did the causal graph match?" answers no, because the graph was never fully recorded. ## What Was Observed A session recorded three tool calls dispatched in the same assistant turn: `read_config(path=A)`, `read_config(path=B)`, and `write_cache(key=C, value=merge(A,B))`. The log captured each call with a millisecond timestamp and each result. On replay, the engine dispatched them with `asyncio.gather`, and the `write_cache` call resolved before both reads returned because its `merge` dependency was satisfied by stale in-context values from the prior turn rather than by the fresh reads. The recorded checksums all matched—the reads returned identical bytes—but the cache write embedded the *previous turn's* A and B. Final state diverged on a field the checksum comparison never inspected. A second signal: the replay's tool-call count matched, the wall-clock duration differed by a constant offset equal to the original's inter-call latency, and the agent's subsequent reasoning referenced a cache value that the replay had written but the original had read from a different source. The divergence surfaced three turns later as a retrieval mismatch—the agent recalled a fact that, in the replay, had been overwritten. The structural signal that distinguished a faithful replay from a divergent one was not any single field but the *dependency edge presence*: in the original, `write_cache` had an implicit happens-after edge to both reads enforced by the runtime's await semantics; in the replay, that edge was absent because the log recorded timestamps, not dependencies, and the replay engine inferred order from timestamps that were too coarse (same millisecond) to reconstruct the partial order. ## Condition of Validity Replay determinism holds only under the invariant: **for every side-effecting tool call, the log must record a happens-before edge to every other call whose output it consumed or whose side effect it observed.** Timestamps alone are insufficient whenever two calls share a timestamp resolution or are dispatched concurrently. The invariant is violated precisely when the runtime allows intra-turn concurrency *and* the logger records completion order rather than causal dependency order. This condition is checkable at record time and must be enforced there. At replay time it is unrecoverable: you cannot reconstruct a missing edge from outputs that are consistent under multiple orderings. The correct guardrail is a *dependency-annotated event log*: each tool invocation carries the set of prior event IDs it read from, captured by the dispatcher at call time, not inferred later. ## Decision Boundary The boundary is between *replay as output comparison* and *replay as causal reconstruction*. If the forensic question is "did the tool return what it returned?", output comparison suffices and ordering divergence is irrelevant. If the question is "why did the agent decide X?", output comparison is insufficient and any session with intra-turn concurrency and unannotated dependencies is *not replayable*—it must be marked as such rather than replayed into a plausible but false causal narrative. The operational rule: a session is replay-eligible only if every side-effecting call's log entry contains a non-empty dependency set, or the session is provably serialized (max one in-flight call per turn). Attempting replay outside this boundary produces a divergence that looks like model stochasticity and gets misattributed to the LLM rather than to the log schema. ## Operational Effect Divergent replays generate false root-cause attributions: the model is blamed for a state it never held, and the actual defect (a missing dependency edge in the audit schema) is never surfaced. The mitigation is to gate replay on a structural precondition check and to fail loudly—raising a specific error that names the unannotated concurrent call group—rather than proceeding into a reconstruction that cannot be trusted. Downstream, this means the audit schema must be revised before the incident review, not after, because a divergent replay is worse than no replay: it produces confident, wrong forensics. ```python class ReplayDependencyGapError(RuntimeError): """Raised when a session cannot be faithfully replayed because a side-effecting tool call lacks recorded happens-before edges.""" pass def assert_replay_eligible(session_events): # Group side-effecting calls by turn to detect intra-turn concurrency. by_turn = {} for ev in session_events: if ev.get("side_effecting"): by_turn.setdefault(ev["turn_id"], []).append(ev) for turn_id, calls in by_turn.items(): if len(calls) <= 1: continue # serialized; ordering is implicit for call in calls: deps = call.get("depends_on") or [] if not deps: raise ReplayDependencyGapError( f"Turn {turn_id}: concurrent side-effecting call " f"{call['event_id']} ({call['tool']}) has no recorded " f"happens-before edges among {len(calls)} calls; " f"replay would infer order from timestamps and may " f"diverge. Mark session non-replayable or backfill " f"dependency annotations before reconstruction." ) return True def replay(session_events): assert_replay_eligible(session_events) # ... deterministic reconstruction proceeds only past the gate ... return reconstruct(session_events) ```