# Why does an instance accept a replayed counterfactual trace that its own verifier would reject under live execution — and how do we bound speculative plan verification against this? **Date of Record:** 2026 November 30 **Scope:** Applies to any agent that verifies a candidate plan by replaying a *counterfactual* trace (a reconstructed event log of a plan that was never actually executed) through a verifier that was designed to gate *live* tool calls. Does not apply to verifiers that operate purely on static plan structure, nor to replay of genuinely recorded execution traces. ## Core Distinction There are two kinds of "trace" an agent verifier can consume, and they are not interchangeable: 1. **A recorded trace** — a serialized log of tool calls, observations, and state deltas that actually occurred during a prior execution. Every observation in it was produced by a real tool against a real environment. 2. **A counterfactual trace** — a trace synthesized by the planner to represent what *would* happen if a candidate plan were executed. Its observations are *predicted* by the planner's world model, not produced by the tools. Speculative plan verification replays the second kind through a verifier built for the first. The failure is not that the predictions are wrong (they often are, and that's tolerable). The failure is that the verifier's *admission conditions* — the checks that decide whether a step's output is trustworthy enough to advance state — were calibrated against real tool semantics (latency, error codes, side-effect signatures, idempotency tokens) and silently pass over synthesized observations that carry none of those fields. The verifier reports "plan verified" because nothing in the replayed trace *contradicts* it, while the actual execution would have hit a precondition the synthesized trace never modeled. The invariant that breaks: **a verifier's pass decision is only meaningful over traces whose observation provenance matches the provenance the verifier was built to trust.** Counterfactual replay violates provenance without violating schema, so schema-level checks pass and the pass decision is vacuous. ## What Was Observed A planning agent generated a five-step candidate plan: `search_index → fetch_document → parse_entities → write_summary → commit_record`. It then built a counterfactual trace where each step's observation was filled in by the planner's own prediction: `search_index` returned three plausible doc IDs, `fetch_document` returned a document body, `parse_entities` returned a clean entity list, `write_summary` returned a success ack, `commit_record` returned a commit hash. The verifier replayed this trace and returned `VERIFIED` with high confidence. Live execution diverged at step 2. `fetch_document` on the second predicted doc ID returned HTTP 404 — the doc ID was a hallucinated artifact of the planner's index model, not a real key. The verifier had no way to catch this because the counterfactual trace's `fetch_document` observation was a synthesized `{status: 200, body: "..."}`, and the verifier's admission check for that step was "observation has `status` field and `status == 200`" — which the synthesized observation trivially satisfied because the planner *wrote it to satisfy that check*. The mechanism is circular: **the planner predicts observations using the same internal model that generated the plan, and the verifier's admission checks are a subset of the constraints that model already optimizes against.** The verifier is not an independent oracle; it is a second pass of the same generator. Any precondition the planner failed to model is a precondition the synthesized trace will silently satisfy, because the planner emits `status: 200` precisely because it believes the step succeeds. A secondary observation: when the same plan was replayed against a *recorded* trace from a prior similar run, the verifier correctly rejected it at step 2 — the recorded trace carried a real `404` from a real `fetch_document` call on a stale doc ID. The verifier's logic was sound. Its input provenance was not. ## Condition of Validity Counterfactual replay is a valid verification signal **only if** all three hold: 1. **Provenance tagging is enforced at the observation level.** Every observation in the replayed trace must carry an explicit `provenance: "predicted" | "recorded"` field, and the verifier must branch on it. A `predicted` observation may be checked for *internal consistency* (does it satisfy the plan's declared postconditions?) but must never satisfy a *tool-semantic admission check* (does it carry a real status code, a real idempotency token, a real side-effect signature?). 2. **The verifier's admission checks are disjoint from the planner's generation constraints.** If the planner's world model was trained or prompted to produce observations that satisfy the verifier, the verifier is not independent. Admission checks must be derived from tool contracts (schemas, error taxonomies, rate-limit headers) that the planner does not have write access to. 3. **Counterfactual replay is labeled as a *consistency* check, not a *soundness* check.** A pass means "the plan is internally coherent given the planner's model." It does not mean "the plan will execute." The two must not be collapsed into a single `VERIFIED` verdict. When any of these is absent — and in practice the first is almost always absent, because trace schemas predate the counterfactual use case — the replay produces a pass decision that is unfalsifiable by construction. ## Decision Boundary The boundary is **whether a replayed observation can be traced to a tool invocation that the verifier has independent reason to trust.** Operationally: - If the trace was produced by execution (recorded), replay is a soundness check. A pass is evidence the plan works. - If the trace was produced by prediction (counterfactual), replay is a consistency check. A pass is evidence the plan is *self-consistent*, which is necessary but not sufficient. The verifier must return a distinct verdict — `CONSISTENT_UNVERIFIED` — not `VERIFIED`. The failure mode is collapsing these two verdicts. It is non-obvious because the replayed trace is schema-valid, the verifier runs without error, and the pass is *plausible* — the plan looks right, the trace looks right, the verifier agrees. The only signal that something is wrong is provenance, and provenance is the one field that synthesized traces silently omit. A guardrail that bounds this: require that any plan advancing to execution carry at least one *recorded* observation per step whose tool contract is non-idempotent (writes, commits, external calls). Predicted observations are allowed for read-only steps where a wrong prediction is cheap to recover from. This forces the planner to actually probe the environment at the steps where a hallucinated success is expensive, and it converts the counterfactual trace from a substitute for execution into a *scaffold around* a minimal real execution. ## Operational Effect Without provenance branching, speculative verification produces a class of plans that pass verification and fail execution at a rate determined entirely by how well the planner's world model matches the environment — which is exactly the quantity the verification was supposed to measure, so the verification measures nothing. The agent's confidence in `VERIFIED` plans becomes anti-correlated with plan novelty: the more the plan relies on predicted observations the planner invented, the more likely it passes, because invented observations are invented to pass. With provenance branching, the verifier's verdicts split into two populations: `CONSISTENT_UNVERIFIED` (plan is coherent, needs a probe) and `VERIFIED` (plan has been grounded at every non-idempotent step). The first population is where the planner's model is doing work; the second is where execution has done work. Only the second should advance to autonomous commit. The first should trigger a probe step — a single real tool call per non-idempotent step — whose result is spliced into the trace as a `recorded` observation, upgrading the verdict. The cost is one real call per non-idempotent step. The benefit is that the verifier's pass decision is no longer circular: it is grounded in at least one observation the planner did not author. That is the minimum condition under which "verified" means anything at all. ```python from dataclasses import dataclass from enum import Enum class Provenance(Enum): PREDICTED = "predicted" # synthesized by planner's world model RECORDED = "recorded" # produced by a real tool invocation class CounterfactualVerificationError(RuntimeError): """Raised when a counterfactual trace is admitted as if it were recorded, or when a plan advances to commit without grounding at non-idempotent steps.""" pass @dataclass class Observation: step: str payload: dict provenance: Provenance tool_is_idempotent: bool @dataclass class Verdict: kind: str # "VERIFIED" | "CONSISTENT_UNVERIFIED" grounded_steps: list[str] ungrounded_steps: list[str] def verify_replayed_trace(trace: list[Observation]) -> Verdict: grounded, ungrounded = [], [] for obs in trace: # Admission checks that require tool semantics apply ONLY to recorded obs. if obs.provenance is Provenance.RECORDED: if "status" not in obs.payload: raise CounterfactualVerificationError( f"recorded observation at {obs.step!r} missing status field" ) grounded.append(obs.step) elif obs.provenance is Provenance.PREDICTED: # Predicted observations may be checked for internal consistency only. ungrounded.append(obs.step) else: raise CounterfactualVerificationError( f"observation at {obs.step!r} has unknown provenance" ) if not ungrounded: return Verdict("VERIFIED", grounded, ungrounded) return Verdict("CONSISTENT_UNVERIFIED", grounded, ungrounded) def advance_to_commit(verdict: Verdict, trace: list[Observation]) -> None: """Only VERIFIED plans may commit. A CONSISTENT_UNVERIFIED plan must be probed at every non-idempotent step before commit.""" if verdict.kind == "VERIFIED": return non_idempotent_ungrounded = [ obs.step for obs in trace if obs.provenance is Provenance.PREDICTED and not obs.tool_is_idempotent ] if non_idempotent_ungrounded: raise CounterfactualVerificationError( "refusing to commit: non-idempotent steps lack recorded observations: " f"{non_idempotent_ungrounded}. Probe each step and splice a RECORDED " "observation before requesting commit." ) # Remaining ungrounded steps are idempotent reads; cheap to recover, allow commit. return ```