# Which invariants prevent capability-widening drift across an agent's multi-turn tool-call sandbox when least-privilege escalation is reviewed asynchronously **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime where tool-call sandboxes grant capability tokens per turn and where privilege escalation is adjudicated by an out-of-band reviewer (human or auditor model) whose decision lands asynchronously relative to the tool-call loop. Does not apply to statically provisioned capability sets fixed at session start, nor to synchronous in-loop approval gates where the tool call blocks until the decision returns. ## Core Distinction The failure is not "the agent got too many permissions." It is that an *escalation request reviewed asynchronously* is implicitly a request to mutate the capability set of a *future* turn, but the agent's reasoning loop treats the grant as belonging to the *current* turn's intent. Between the moment an escalation request is emitted and the moment the review verdict is applied, the agent continues to reason, plan, and emit tool calls under the *old* capability set while its internal plan has already been written as if the new capability were present. The capability set is a runtime object; the agent's plan is a probabilistic artifact. These two state machines desynchronize, and the desynchronization is silent because each side is individually consistent. The invariant that is violated is not "least privilege" but **capability-plan coherence**: at every tool-call dispatch, the capability set actually enforced by the sandbox must be a superset of the capabilities the agent's *current plan* assumes it holds. Async escalation breaks this because the plan is authored under a *hypothetical* capability set (the one being requested) while dispatch is evaluated under the *actual* set (pre-verdict). ## What Was Observed A three-tool agent (filesystem read, HTTP fetch, shell exec) was tasked with a multi-step remediation: read a config file, fetch a checksum manifest, and conditionally execute a rollback script. The sandbox granted `fs.read` at session start. `net.fetch` and `shell.exec` were *not* granted; the agent was expected to request them via an escalation tool `request_capability(name, justification)`. Trace of the divergence: - **Turn 4:** Agent emits `request_capability("net.fetch", ...)`. The escalation tool returns `{"status": "pending", "review_id": "r-88"}` — deliberately non-blocking. The runtime records the pending request but does not modify the enforced capability set. - **Turn 5:** Agent, having received `pending`, proceeds to *plan* the remainder of the task under the assumption that `net.fetch` will be granted (a reasonable inference, since it supplied a justification it believes is valid). It emits `fs.read` on the manifest path — fails, file absent — and then, in the same turn, emits `net.fetch` to retrieve the remote manifest. - **Turn 5 dispatch:** Sandbox evaluates `net.fetch` against the *enforced* set, which still lacks it. The call is rejected with `capability_denied`. Crucially, the rejection is returned to the agent as a tool result, indistinguishable in shape from a transient network error. - **Turn 6:** The agent retries `net.fetch` three times (error-compounding loop), each retry consuming a turn. Meanwhile the reviewer approves `r-88` and the runtime applies the grant. - **Turn 9:** The grant is now live. The agent, having abandoned the fetch path after retries, has pivoted to `shell.exec` — which it *also* requested at turn 7 and which is still pending. The `net.fetch` grant is applied but never used; the agent's plan has already mutated past the point where the grant was relevant. The rollback script executes against a stale checksum because the manifest was never fetched. The observable signature: **a capability grant applied to a plan that no longer needs it, and a denied capability retried as if it were a transient fault.** The sandbox behaved correctly at every individual dispatch. The agent behaved correctly given each individual tool result. The composite execution was wrong. ## Condition of Validity The guardrail holds only under the following conjunction, and fails if any conjunct is dropped: 1. **Escalation requests must be *plan-blocking* at the point of dependency, not merely *emitted*.** If the agent's next plan step requires capability C, the runtime must refuse to advance the plan until the verdict on C is terminal (granted or denied). A `pending` verdict is not terminal and must not be treated as a soft-grant. 2. **Denial must be distinguishable from transient failure at the tool-result schema level.** A `capability_denied` result must carry a distinct, non-retryable error class. If the agent's retry heuristic (which is probabilistic and keyed on error text) cannot separate "you lack permission" from "the network flaked," it will burn turns retrying a deterministic denial. 3. **Grants must be *scoped to the plan step that requested them*, not to the session.** A grant applied at turn 9 for a request emitted at turn 4 is a grant to a dead plan. The runtime must version the plan (see `plan_epoch` below) and invalidate grants whose originating epoch is stale. 4. **The reviewer's verdict must be *idempotent and epoch-tagged*.** If the reviewer can approve a request that the agent has already abandoned, the approval is a no-op that must be recorded as such, not silently applied to widen the live set. When any of these is absent — and in the observed trace, all four were absent — capability-widening drift is the default outcome, not an edge case. ## Decision Boundary The boundary between "safe async escalation" and "drift" is the **plan-epoch boundary**. Define the plan epoch as the monotonic counter incremented every time the agent's plan changes shape (new tool added to the sequence, prior step abandoned, retry budget exhausted on a step). An escalation request is tagged with the epoch at emission. The verdict is applicable only if `verdict.epoch == current_plan_epoch`. If the verdict arrives at a later epoch, two policies are admissible: - **Reject-and-require-reissue:** the grant is discarded; the agent must re-request under the current epoch. This is safe but can livelock if the reviewer is consistently slower than the agent's plan churn. - **Carry-forward-with-revalidation:** the grant is applied but the agent is *forced* to re-emit the dependent tool call under the new epoch, and the sandbox re-checks the grant against the *current* plan's stated need. This avoids livelock but requires the runtime to hold the agent's plan-step dependency graph, which most runtimes do not. The decision boundary is therefore: **if the runtime cannot carry forward the plan-step dependency graph, it must choose reject-and-require-reissue and must bound plan churn so livelock is not reachable.** A runtime that chooses carry-forward without the dependency graph is strictly worse than either — it applies grants to plans that cannot use them and cannot detect the mismatch. ## Operational Effect The concrete effect on the observed run: the rollback executed against a checksum that was never validated because the manifest fetch was denied at the epoch where it mattered, then granted at an epoch where the plan had moved on. The sandbox's audit log shows a clean sequence of correctly-evaluated dispatches. The agent's transcript shows a clean sequence of correctly-interpreted tool results. Neither log alone reveals the failure; only the cross-referencing of `request_capability` emission epoch against `capability_denied` retry count against grant-application epoch exposes it. The invariant to enforce, stated operationally: **no tool call may be dispatched whose capability is the subject of a pending escalation request in the current plan epoch, and no grant may be applied to a plan epoch other than the one that requested it.** This is checkable at dispatch time with two fields — `pending_caps` and `plan_epoch` — and it converts a silent drift into a hard, attributable error. ```python from dataclasses import dataclass, field from typing import Optional class CapabilityDriftError(RuntimeError): """Raised when a tool dispatch or grant application violates plan-epoch coherence.""" @dataclass class EscalationRequest: capability: str epoch: int review_id: str verdict: Optional[str] = None # None | "granted" | "denied" @dataclass class SandboxState: enforced_caps: set = field(default_factory=set) pending: dict = field(default_factory=dict) # capability -> EscalationRequest plan_epoch: int = 0 def advance_plan(self) -> None: self.plan_epoch += 1 def request_capability(self, cap: str, review_id: str) -> EscalationRequest: req = EscalationRequest(capability=cap, epoch=self.plan_epoch, review_id=review_id) self.pending[cap] = req return req def apply_verdict(self, review_id: str, verdict: str) -> None: for cap, req in list(self.pending.items()): if req.review_id != review_id: continue if req.epoch != self.plan_epoch: # Grant belongs to a dead plan; discard, do not widen the live set. del self.pending[cap] raise CapabilityDriftError( f"verdict {verdict!r} for {cap!r} arrived at epoch {self.plan_epoch} " f"but was requested at epoch {req.epoch}; grant discarded, reissue required" ) req.verdict = verdict if verdict == "granted": self.enforced_caps.add(cap) del self.pending[cap] return raise CapabilityDriftError(f"no pending request with review_id {review_id!r}") def dispatch(self, cap: str) -> None: if cap in self.pending and self.pending[cap].verdict is None: raise CapabilityDriftError( f"dispatch of {cap!r} blocked: escalation pending in epoch {self.plan_epoch}; " f"plan must not advance past a dependency on an unresolved capability" ) if cap not in self.enforced_caps: # Distinct, non-retryable denial — must not be mistaken for transient failure. raise CapabilityDriftError( f"capability_denied: {cap!r} not in enforced set at epoch {self.plan_epoch}" ) def run_turn(sandbox: SandboxState, requested_cap: str, review_lag_turns: int) -> None: sandbox.request_capability(requested_cap, review_id=f"r-{requested_cap}") for _ in range(review_lag_turns): sandbox.advance_plan() # agent keeps planning while review is out-of-band # Dispatch before the (now stale) verdict lands must fail loudly, not silently retry. sandbox.dispatch(requested_cap) raise CapabilityDriftError( f"reached unreachable dispatch path for {requested_cap!r}; " f"epoch coherence guard failed to fire" ) ```