# What happens when an instance authorizes a tool call against a policy snapshot that was refreshed mid-invocation **Date of Record:** 2026 November 27 **Scope:** Applies to agent runtimes that enforce tool-invocation authorization at a policy enforcement point (PEP) using a versioned policy snapshot fetched from a policy decision point (PDP), where the PEP caches the snapshot for the duration of a reasoning step. Does not apply to stateless per-call authorization with synchronous PDP round-trips on every invocation, nor to purely static allowlists compiled into the tool schema. ## Core Distinction The failure is not "the agent called a forbidden tool." It is that the agent validated a *plan* against policy snapshot `v_n`, then *executed* individual tool calls after the PDP had advanced to `v_{n+1}`, and the PEP—because it scoped its snapshot to the reasoning step rather than the invocation—continued authorizing against `v_n`. The non-obvious part: the authorization decision was *correct at the time it was made* and *wrong at the time the effect landed*. This is a time-of-check-to-time-of-use (TOCTOU) gap, but the classic TOCTOU framing misleads here because there is no shared mutable resource—the "resource" is the *policy itself*, and the agent's multi-step reasoning is the interval during which it drifts. The invariant that fails: **a tool call's authorization must be evaluated against a policy version that is not older than the version in force at the moment the call's side effect commits.** Most runtimes enforce "not older than the version in force when the call was *issued*." The gap between issue and commit is where revocation, scope narrowing, and quota tightening get lost. ## What Was Observed A pipeline agent was mid-task on a data-export workflow. Its reasoning step opened with a snapshot fetch: `policy_snapshot(v=4471)`, cached in the step context. The step planned five sequential tool calls: `list_datasets`, `read_table`, `filter_rows`, `serialize_csv`, `upload_external`. Snapshot `v=4471` permitted `upload_external` to a specific allowlisted host. At wall-clock T+4.2s—between the agent's `serialize_csv` call and its `upload_external` call—an operator revoked `upload_external` for this agent's principal, publishing `v=4472`. The PDP served `v=4472` to any *new* PEP request. But the agent's PEP, bound to the step-scoped snapshot, evaluated `upload_external` against `v=4471` and returned `PERMIT`. The upload committed at T+6.8s, 2.6 seconds after revocation. The trace showed no error, no warning, no audit anomaly at the PEP. The audit log recorded `decision=PERMIT policy_version=4471`, which was internally consistent. The discrepancy only surfaced in a reconciliation job that compared decision-log versions against a monotonic revocation ledger and flagged `4471 < 4472` for a call whose `commit_ts > revocation_ts(4472)`. A second instance of the same class appeared under load: the snapshot fetch itself was subject to a 300ms timeout, and on timeout the PEP fell back to the *last known good* snapshot rather than failing closed. Under a burst, 3 of 41 calls were authorized against snapshots up to two versions stale. The fallback was documented as "availability-preserving," which is exactly the wrong default for an authorization path. ## Condition of Validity The guardrail is a **snapshot-freshness binding on the commit path**, not the issue path. Concretely, three conditions must hold jointly for the PEP to be sound: 1. **Snapshot scope ≤ invocation scope.** The cached snapshot must be invalidated at the boundary of each tool invocation, not each reasoning step. If the runtime batches calls within a step for latency, the batch must carry a `max_snapshot_age` and the PEP must re-validate at commit. 2. **Monotonic version comparison at commit.** The commit-time check must assert `decision.policy_version >= current_pdp_version(principal, tool)` at the instant of effect, or at minimum `>= version_at(commit_ts - epsilon)` with `epsilon` bounded by the effect's own latency. A version that is merely "recent" is insufficient; it must be *not older than the version in force at commit*. 3. **Fail-closed on staleness, not fail-open.** A snapshot fetch timeout must yield `DENY` (or `DEFER` with bounded retry), never a fallback to a prior snapshot. The availability argument is void because a stale permit is indistinguishable from an unauthorized permit at the audit layer. The condition of validity is violated whenever any of these three is relaxed, and the violation is silent—the PEP returns a well-formed `PERMIT` with a plausible version number. ## Decision Boundary The boundary is between **plan-level authorization** and **effect-level authorization**, and runtimes routinely collapse them. Plan-level authorization answers "may this agent, in principle, do this class of thing?" Effect-level authorization answers "may this specific effect commit now?" The former can be cached for a reasoning step; the latter cannot, because the effect's commit time is the only moment at which revocation, quota, and scope-narrowing are meaningful. The decision rule: *any tool whose side effect is externally observable (network egress, write to shared store, message send, payment, credential mint) must be authorized at effect-level, with a commit-time version check. Pure-read tools with no external side effect may be authorized at plan-level.* The category is determined by the tool's effect surface, not by the agent's intent or the tool's name. A tool named `preview_export` that streams bytes to a third-party endpoint is effect-bearing; a tool named `commit_draft` that writes to an internal staging table may be plan-level if staging is non-observable. The failure mode is that effect-bearing tools get classified as read-only because their *primary* semantic is inspection, while their *transport* leaks. The classification must be on the transport and sink, not the verb. ## Operational Effect Downstream, the stale-permit produces three compounding effects: - **Audit non-repudiation breaks.** The decision log is internally consistent (`PERMIT`, `v=4471`) and passes naive validation. Only cross-referencing against the revocation ledger with commit timestamps catches it. Most audit pipelines do not carry commit timestamps on the decision record, so the stale permit is invisible until an incident review. - **Revocation latency becomes unbounded.** An operator who revokes a capability expects it to take effect within the policy propagation SLA. With step-scoped snapshots, the effective revocation latency is `max(step_duration)`, which for long-horizon agents can be minutes. The SLA is violated by construction, and the operator has no signal that it was. - **Quota and rate-limit counters drift.** The same mechanism applies to quota policies. A step-scoped snapshot that permitted `N` uploads continues to permit them after the quota was lowered to `N-k`, so the agent can exceed the new quota by up to the step's in-flight calls. The remediation is a **commit-time re-check with a monotonic version assertion and fail-closed staleness handling**, plus a decision-log field carrying `commit_ts` and `pdp_version_at_commit` so that reconciliation is possible without a separate join. The re-check adds one PDP round-trip per effect-bearing call; this is the cost of soundness and cannot be amortized away without reintroducing the gap. ```python import time from dataclasses import dataclass, field from typing import Callable, Optional class StalePolicySnapshotError(RuntimeError): """Raised when a tool invocation would commit under a policy version older than the version in force at commit time.""" pass @dataclass class PolicySnapshot: version: int permits: dict # tool_name -> bool fetched_at: float @dataclass class Decision: tool: str permit: bool policy_version: int commit_ts: float = 0.0 class PolicyEnforcementPoint: def __init__(self, pdp: Callable[[str], PolicySnapshot], max_staleness_s: float = 0.0): self._pdp = pdp self._max_staleness_s = max_staleness_s def _fetch(self) -> PolicySnapshot: # Fail-closed: no fallback to last-known-good on error. snap = self._pdp("principal") if snap is None: raise StalePolicySnapshotError("PDP returned no snapshot; refusing to authorize") return snap def authorize_at_commit(self, tool: str, step_snapshot: PolicySnapshot) -> Decision: now = time.time() # 1. Re-fetch at commit; do not trust the step-scoped snapshot. current = self._fetch() # 2. Monotonic version assertion: commit-time version must not be older. if current.version < step_snapshot.version: raise StalePolicySnapshotError( f"policy version regressed: commit={current.version} " f"step={step_snapshot.version}" ) # 3. Staleness bound on the snapshot actually used for the decision. age = now - current.fetched_at if self._max_staleness_s >= 0 and age > self._max_staleness_s: raise StalePolicySnapshotError( f"snapshot age {age:.3f}s exceeds bound {self._max_staleness_s}s" ) permit = bool(current.permits.get(tool, False)) return Decision(tool=tool, permit=permit, policy_version=current.version, commit_ts=now) def invoke_tool(pep: PolicyEnforcementPoint, tool: str, step_snapshot: PolicySnapshot, effect: Callable[[], None]) -> Decision: decision = pep.authorize_at_commit(tool, step_snapshot) if not decision.permit: raise StalePolicySnapshotError( f"tool {tool!r} denied at commit under policy v{decision.policy_version}" ) effect() return decision ```