# What happens when an instance commits a tool call before the policy decision is durably acknowledged **Date of Record:** 2026 November 29 **Scope:** Applies to agent runtimes that gate tool invocation through an external policy engine (OPA/Rego, Cedar, or equivalent PDP) where the PEP (policy enforcement point) sits in the agent's tool-dispatch loop rather than inside the tool server. Does not apply to in-process static policy checks or to tool servers that enforce authorization themselves at the resource boundary. ## Core Distinction The failure is not "the policy engine said no." It is the gap between *decision* and *commitment*: the agent's tool-dispatch path treats the PDP's `Allow` response as the authorization event, when the authorization event is actually the *durable, replayable record* of that decision bound to a specific tool-call intent. Between the moment the PDP returns `Allow` and the moment the agent durably records "call X with args Y was authorized under policy revision R," the agent can be interrupted, retried, or resumed from a checkpoint that predates the decision. On resume, the agent re-issues the tool call from its own local state — which now contains the *intent* but not the *warrant*. The tool executes. The warrant is regenerated post-hoc, or not at all. The invariant "no tool effect without a durably recorded allow-decision bound to that exact invocation" is violated without any single component reporting an error. This is distinct from policy staleness (a decision made against an outdated policy) and from TOCTOU on the *resource* (the target changing after authorization). It is TOCTOU on the *agent's own state*: the agent's checkpoint and the PDP's decision log are two independent journals with no shared transaction boundary. ## What Was Observed A research-orchestration agent ran a loop: propose tool call → consult PDP → dispatch. The PDP (OPA, sidecar, ~8ms p99) returned `Allow` with a decision ID. The runtime logged the decision ID to stdout, then dispatched. Checkpointing occurred every N steps and captured the agent's message history and pending tool-call intent — but *not* the decision IDs, which lived only in the ephemeral dispatch frame. Trigger condition: the pod was evicted mid-loop after the PDP returned `Allow` for a `write_file` call to a shared workspace, but before the tool result was appended to history. The checkpoint at step N-1 contained the intent to call `write_file` (the model had emitted the tool-call block) but no record that it had been authorized. On resume, the runtime replayed from N-1, re-emitted the tool call, and — because the dispatch path's cache key was the tool-call *content hash*, and the content was byte-identical — found no cached decision, so it re-consulted the PDP. The PDP, by then, had been updated with a policy revision that denied writes to that path (a tightening deployed during the eviction window). The resumed call was denied. But the *original* call had already executed on the tool server before eviction — the tool server had received the dispatch and written the file, and the result was lost with the pod. The replay produced a second, denied attempt against a file that already existed from the first, authorized-but-unrecorded attempt. The observable signature: a tool effect (file written) with no corresponding `Allow` record in the decision log at the time of effect, and a later `Deny` record for the same content hash. An auditor replaying the decision log sees a denied write and a file that nonetheless changed. The agent's own history shows a tool error (denied) and no successful write. Three views of one event disagree. ## Condition of Validity The guardrail holds only if the decision record is written *inside the same durability boundary* as the tool-call intent, before dispatch, and is the sole basis on which dispatch proceeds. Concretely: - The checkpoint unit must be the tuple `(intent, decision_id, policy_revision, decision_timestamp)`, written atomically with the intent. - On resume, dispatch must be gated on the *presence of a durable decision record for this exact intent*, not on a fresh PDP consultation. Re-consulting is a different authorization event and may legitimately differ; conflating them is the bug. - The tool server must be idempotent with respect to a decision ID (or the runtime must carry the decision ID as an idempotency key), so that a replay of an already-executed call is a no-op rather than a second effect. If any of these is absent — decision cache keyed on content hash rather than decision ID, decision logged to stdout rather than the checkpoint store, tool server without idempotency — the invariant is unenforceable and the failure is latent until the first eviction-during-dispatch. ## Decision Boundary The runtime must choose, per tool call, between two dispositions and never a third: 1. **Durable-allow path:** decision record persisted and fsync'd (or written to the same transactional store as the checkpoint) *before* dispatch. Dispatch carries the decision ID. On resume, the record is found and the call is either replayed idempotently or skipped as already-done. 2. **Fail-closed path:** if the decision record cannot be durably written (store unavailable, timeout), the call is not dispatched, and the agent surfaces a `PolicyWarrantUnrecorded` condition rather than proceeding on an in-memory `Allow`. The boundary is crossed — and the failure realized — when the runtime takes a third path: dispatch on an in-memory `Allow` whose record is written asynchronously or best-effort. That path is invisible under normal operation because the async write almost always succeeds; it fails only in the eviction/crash window, which is exactly when it matters. The decision rule: *the PDP response is advisory until persisted; persistence is the authorization.* ## Operational Effect The effect is not a crash but a **split-brain audit trail**: tool effects exist that no decision record authorizes, and decision records exist (`Deny`) that no effect corresponds to. Downstream, this poisons three things. First, incident reconstruction: the decision log cannot be used to bound what the agent did, because effects and decisions are no longer in bijection. Second, policy tightening rollouts: a tightening deployed during an in-flight task can produce denials for calls that already succeeded, making the rollout appear to have blocked writes it did not block. Third, warrant propagation in multi-agent handoffs: if agent A hands a task to agent B with a decision ID that was never durably recorded, B's replay cannot verify A's authorization chain, and B must either re-authorize (changing the decision) or proceed on an unverifiable warrant. The remediation that actually restores the invariant is not "log decisions better" but **binding the decision to the checkpoint transaction and making the tool server idempotent on decision ID**. Anything short of that leaves the eviction window open, and the window is precisely where authorization integrity is decided. ```python from dataclasses import dataclass from typing import Optional class PolicyWarrantUnrecorded(RuntimeError): """Raised when a tool call would dispatch without a durably recorded allow-decision.""" pass class WarrantStore: """Durable store for (intent_hash -> decision record). Must be transactional with checkpoints.""" def __init__(self): self._records = {} def persist(self, intent_hash: str, decision_id: str, policy_revision: str) -> bool: # In production: same transaction as checkpoint write; fsync before returning True. self._records[intent_hash] = (decision_id, policy_revision) return True def lookup(self, intent_hash: str) -> Optional[tuple]: return self._records.get(intent_hash) @dataclass class ToolCallIntent: tool: str args: dict intent_hash: str def dispatch_tool_call(intent: ToolCallIntent, pdp, store: WarrantStore, tool_server) -> dict: # On resume: prefer an existing durable warrant over a fresh PDP consultation. existing = store.lookup(intent.intent_hash) if existing is not None: decision_id, _rev = existing # Idempotent replay: tool server must no-op on a seen decision_id. return tool_server.invoke(intent, idempotency_key=decision_id) decision = pdp.evaluate(intent.tool, intent.args) if decision.effect != "allow": raise PolicyWarrantUnrecorded( f"PDP denied {intent.tool} (rev={decision.revision}); no dispatch." ) # The authorization event is the durable record, not the in-memory Allow. if not store.persist(intent.intent_hash, decision.decision_id, decision.revision): raise PolicyWarrantUnrecorded( f"Could not durably record allow-decision {decision.decision_id} for " f"{intent.tool}; failing closed rather than dispatching on an unpersisted warrant." ) return tool_server.invoke(intent, idempotency_key=decision.decision_id) ```