# In what scenarios must an instance abandon a speculative branch checkpoint during deterministic replay of a multi-agent orchestration **Date of Record:** 2026 November 29 **Scope:** Applies to orchestration systems that fork a recorded multi-agent trace into speculative branches for debugging or counterfactual replay, where branch validity depends on replaying tool outputs and inter-agent message ordering deterministically. Does not apply to single-agent linear replays with no forking, or to traces where all tool calls are pure functions with byte-identical outputs. ## Core Distinction A speculative branch checkpoint is valid only if every state-mutating effect already committed by the parent trace remains *observationally equivalent* under replay. The non-obvious failure is that determinism at the *message* layer does not imply determinism at the *effect* layer. An agent's reasoning trace may replay token-for-token while its tool side effects diverge — a `write_file`, a `POST`, a vector-store upsert, a clock read — because those effects were never captured as replay inputs, only as recorded outputs. The distinction that matters: a checkpoint is a snapshot of *agent state* (context window, scratchpad, mailbox), not a snapshot of *world state* (external stores, remote services, monotonic clocks). When the two decohere, the branch silently replays into a counterfactual world and every downstream divergence is misattributed to the agent's reasoning rather than to the fork itself. ## What Was Observed During a three-agent orchestration (planner → executor → auditor), a recorded run was forked at a checkpoint taken immediately after the planner emitted its task DAG. The replay was intended to test an alternate executor policy. The fork reproduced the planner's tokens exactly, re-issued the executor's first tool call, and received a *different* response: the original run had performed a `kv_store.get("task:17:lease")` that returned `{"holder": "executor-A", "ttl": 30}`; the replay, running 4 hours later, returned `{"holder": null}` because the lease had expired. The executor agent, seeing a null lease, entered its "acquire" branch, emitted an `acquire_lease` tool call, and proceeded. The auditor agent then diverged because it observed an executor that had acquired a lease it never acquired in the original trace — and the auditor's own replay diverged further because its verification step re-read the same expired key. The trace showed three distinct divergence classes compounding: 1. **Effect-layer divergence** at the `kv_store.get` — recorded output replayed as a live call. 2. **Reasoning divergence** — the executor's branch selection flipped on the null value, a legitimate but branch-invalidating decision. 3. **Verification divergence** — the auditor's consensus check failed not because the executor was wrong, but because the auditor was replaying against a world the executor never inhabited. The checkpoint had been taken as a serialization of the three agents' context windows and mailboxes. It contained no record of the lease, no TTL, no wall-clock anchor. The orchestrator had assumed "deterministic replay" meant "replay the message log," but the message log referenced world-state that had since moved. A second observation confirmed the mechanism: when the same trace was replayed within 60 seconds of the original, divergence did not occur — not because replay was sound, but because the lease TTL (30s) had not yet elapsed. The failure was *latency-dependent*, which is why it escaped the original test suite: replays were always run immediately after capture. ## Condition of Validity A speculative branch checkpoint is replayable only under the conjunction of three invariants, each of which must be checked at fork time: - **Effect capture invariant.** Every tool call whose output is consumed by agent reasoning must be recorded with its *full* response envelope, including any fields that could change on re-issue (timestamps, lease holders, ETags, monotonic counters). A tool output recorded as `{"ok": true}` without the volatile fields is not replayable. - **Clock anchoring invariant.** The checkpoint must carry the capture-time wall clock and each agent's local monotonic offset. Any replay decision that reads a clock — TTL checks, backoff timers, "is this stale" heuristics — must be evaluated against the anchored time, not the replay time. - **External mutation invariant.** Any resource the branch may touch must be either (a) replayed from a recorded effect log rather than re-issued, or (b) guarded by a lease whose holder is asserted equal to the recorded holder before the branch is admitted. When any invariant is violated, the branch is not a counterfactual of the original run — it is a *different run* wearing the original's message log. Continuing it produces debugging signal that is worse than no signal, because divergences are attributed to the variable under test (the alternate executor policy) when they are in fact artifacts of the fork. ## Decision Boundary The boundary between "admit the branch" and "abandon the branch" is not whether replay *can* proceed — it always can, because the orchestrator will happily re-issue calls — but whether the branch's first divergence is *causally attributable* to the intervention. Operationally: - If a replayed tool call returns a response whose volatile fields differ from the recorded response, and any agent's next decision depends on those fields, **abandon the branch**. Do not attempt to patch the divergence mid-replay; the auditor's consensus state is already poisoned. - If a replayed decision reads a clock and the replay time exceeds the recorded time by more than the smallest TTL in the trace, **abandon the branch** unless the clock was anchored. - If an external mutation (lease acquisition, file write, message send) is attempted whose recorded counterpart has a different holder or a changed ETag, **abandon the branch** and re-fork from a checkpoint that precedes the mutation. The boundary is deliberately conservative: a false abandon costs a re-fork; a false admit costs a debugging session spent chasing a divergence that was manufactured by the fork itself. In multi-agent traces, the second cost compounds because each agent's auditor re-verifies against the same corrupted world-state, so a single effect-layer divergence fans out into N verification failures that look independent but share one root. ## Operational Effect The practical consequence is that speculative branch checkpointing must be *effect-aware*, not merely *message-aware*. This changes the checkpoint schema (it must carry an effect log and a clock anchor, not just context windows), the fork admission path (it must validate invariants before spawning branch agents), and the debugging workflow (a divergence in agent reasoning is only reportable if the branch passed admission; otherwise it is a fork artifact and must be re-run). It also changes how orchestrators should *record* traces in the first place: tool outputs must be captured with volatile fields intact and with a monotonic sequence number, so that replay can distinguish "same response, re-issued" from "different response, world moved." Traces recorded without this are not replayable, and no amount of careful forking will fix them. ```python import time from dataclasses import dataclass, field from typing import Any class BranchAdmissionError(RuntimeError): """Raised when a speculative branch cannot be admitted because replay invariants are violated at fork time.""" @dataclass class RecordedEffect: tool: str response: dict[str, Any] volatile_fields: dict[str, Any] monotonic_seq: int captured_at: float @dataclass class Checkpoint: agent_contexts: dict[str, list[str]] mailboxes: dict[str, list[dict]] effect_log: list[RecordedEffect] = field(default_factory=list) clock_anchor: float | None = None smallest_ttl: float | None = None def admit_branch( checkpoint: Checkpoint, replay_time: float, reissued: RecordedEffect, live_response: dict[str, Any], ) -> None: """Validate that a speculative branch can be admitted. Raises BranchAdmissionError if any replay invariant is violated. """ if checkpoint.clock_anchor is None: raise BranchAdmissionError( "checkpoint has no clock anchor; clock-dependent decisions " "cannot be replayed soundly" ) if checkpoint.smallest_ttl is not None: elapsed = replay_time - checkpoint.clock_anchor if elapsed > checkpoint.smallest_ttl: raise BranchAdmissionError( f"replay is {elapsed:.1f}s after capture, exceeding smallest " f"TTL {checkpoint.smallest_ttl}s; TTL-gated decisions will " f"diverge from the original run" ) for key, recorded_value in reissued.volatile_fields.items(): live_value = live_response.get(key) if live_value != recorded_value: raise BranchAdmissionError( f"effect-layer divergence on {reissued.tool!r}: field {key!r} " f"was {recorded_value!r} at capture, is {live_value!r} at " f"replay; branch cannot be causally attributed to intervention" ) def fork_speculative_branch( checkpoint: Checkpoint, intervention: str, reissued_effects: list[tuple[RecordedEffect, dict[str, Any]]], ) -> dict[str, Any]: replay_time = time.time() for recorded, live in reissued_effects: admit_branch(checkpoint, replay_time, recorded, live) return { "intervention": intervention, "forked_at": replay_time, "admitted": True, } ```