# Where must an instance reconcile capability-scoped sandbox revocation against in-flight MCP tool calls before the next model turn **Date of Record:** 2026 November 27 **Scope:** Applies to LLM agent runtimes that dispatch tool calls to untrusted MCP servers under a capability-scoped sandbox (per-tool capability grants, revocation on policy change, and re-authorization at turn boundaries). Does not apply to statically trusted in-process tools, nor to sandboxes that enforce capability checks at syscall granularity rather than at MCP-request granularity. ## Core Distinction The naive model treats a capability grant as a property of the *agent instance*: once the instance is admitted with capability set `C`, every tool call it emits during its lifetime is checked against `C`, and revocation is a matter of updating `C`. The failure mode emerges from a subtler invariant: an MCP tool invocation is **not atomic with respect to the model turn that emitted it**. A single `tools/call` request may be in flight (queued, executing, or streaming results) across one or more model turns, and the capability that authorized its dispatch can be revoked *between* dispatch and result-admission. The boundary question is therefore not "is this instance allowed to call `fs.write`?" but "at which of the three transition points — dispatch, execution, result-admission — is the capability re-validated, and what happens to an in-flight call whose authorizing capability was revoked after dispatch but before its result is folded back into context?" The non-obvious part: **result-admission is a distinct capability event from dispatch**, and most runtimes only enforce at dispatch. A revoked capability thus leaks its *effects* into the model's context even though no new call could be made under it — a stale-effect injection that the model then reasons over as if the capability were still live. ## What Was Observed A runtime admitted an agent with capability set `{repo.read, repo.write, shell.exec:scoped(/tmp/build)}` and dispatched a long-running `shell.exec` build via an untrusted MCP server. The build was a legitimate `make -j8` under `/tmp/build`. Mid-execution (turn 4 of a 6-turn task), an operator revoked `shell.exec` because the agent's plan had drifted toward an out-of-scope target. The revocation updated the capability table and the runtime correctly rejected the agent's *next* `tools/call` with `CapabilityRevoked`. But the in-flight `make` was not cancelled: the MCP server had already accepted the request, and the transport delivered a 40 KB stdout stream back to the runtime at turn 5. The runtime's result-admission path checked only *transport* validity (request-id match, schema conformance), not the capability that authorized the original dispatch. The 40 KB of build output — including compiler diagnostics naming files outside `/tmp/build` that the drifted plan had touched — was appended to the agent's context. At turn 6 the model, seeing its own prior tool output as authoritative, emitted a "summary of changes" that asserted modifications to paths it had never been granted. The capability was revoked; the *evidence of its exercise* was not. A second run reproduced the inverse: revocation arrived *after* result-admission but *before* the model consumed the result. Here the runtime had already admitted the output, and the model reasoned over it for one more turn before the next dispatch was blocked — a one-turn window of capability-stale reasoning. ## Condition of Validity The guardrail holds only if the runtime maintains a **capability epoch** — a monotonically increasing counter bumped on every grant/revoke — and stamps each dispatched `tools/call` with the epoch at dispatch. Result-admission then compares the stamped epoch against the current epoch and the *specific* capability that authorized the call. The invariant is: > A result may be admitted into the model context only if the capability that authorized its dispatch is still held at the current epoch, **or** the runtime has explicitly quarantined the result and marked it `stale_capability` in context so the model cannot treat it as live. Without the epoch stamp, the runtime cannot distinguish "this result was produced under a capability I still hold" from "this result was produced under a capability I revoked three turns ago." The epoch is the only thing that makes the in-flight window observable. Note the invariant is *not* "cancel all in-flight calls on revocation" — cancellation is best-effort and racy; the invariant is about **admission**, which is synchronous and enforceable at the turn boundary. ## Decision Boundary The boundary is drawn at **result-admission, not dispatch**. Dispatch-time checks are necessary but insufficient. The decision procedure at each result-admission: 1. Look up the dispatch-time epoch `e_d` and authorizing capability `c` from the request-id record. 2. If `c` is still in the current capability set **and** `e_d == current_epoch`, admit normally. 3. If `c` was revoked, or `e_d < current_epoch` for any reason, do **not** silently drop (the model will hallucinate a missing result) and do **not** silently admit (the model will treat stale effects as live). Instead admit under a `stale_capability` wrapper that carries: the revoked capability name, the epoch delta, and an explicit instruction that the output reflects a capability no longer held and must not be used to justify further calls under that capability. 4. If the result is a *partial* stream (the transport delivered bytes before the revocation was observed), the wrapper must be applied to the whole accumulated buffer, not just subsequent chunks — otherwise the model sees a split result where the pre-revocation half looks live and the post-revocation half looks stale. The boundary fails silently whenever step 3 collapses to "drop" or "admit," which is the default in most MCP client implementations because the transport layer has no concept of capability epochs. ## Operational Effect With epoch-stamped admission, the drifted-plan scenario resolves differently: at turn 5 the runtime admits the 40 KB build output under a `stale_capability` wrapper naming `shell.exec` as revoked at epoch 7 (dispatch epoch 5). The model, at turn 6, sees the wrapper and does not assert modifications as authorized — it reports the build output as *evidence gathered under a now-revoked capability*, which is the truthful framing. The downstream effect is that the agent's self-summary no longer launders revoked-capability effects into its narrative of what it did. The cost is one extra field per request record and one comparison per result-admission — negligible against the cost of a capability-stale reasoning turn. The invariant to encode in the runtime's test harness: *for every revocation event, there must exist a test where a call dispatched under the pre-revocation epoch returns post-revocation, and the runtime must wrap rather than drop or admit.* A runtime that cannot construct that test has not implemented the boundary. ```python from dataclasses import dataclass, field from typing import Optional class CapabilityEpochViolation(RuntimeError): """Raised when an in-flight tool result is admitted without epoch reconciliation.""" pass @dataclass class CapabilityTable: epoch: int = 0 held: set = field(default_factory=set) def revoke(self, capability: str) -> None: if capability not in self.held: raise CapabilityEpochViolation( f"cannot revoke unheld capability {capability!r} at epoch {self.epoch}" ) self.held.discard(capability) self.epoch += 1 @dataclass class InFlightCall: request_id: str capability: str dispatch_epoch: int buffer: bytes = b"" @dataclass class AdmittedResult: request_id: str payload: bytes stale_capability: Optional[str] = None epoch_delta: int = 0 def admit_result(call: InFlightCall, table: CapabilityTable) -> AdmittedResult: if call.dispatch_epoch > table.epoch: raise CapabilityEpochViolation( f"dispatch epoch {call.dispatch_epoch} is ahead of table epoch {table.epoch}" ) if call.capability in table.held and call.dispatch_epoch == table.epoch: return AdmittedResult(call.request_id, call.buffer) if call.capability not in table.held: delta = table.epoch - call.dispatch_epoch if delta <= 0: raise CapabilityEpochViolation( f"capability {call.capability!r} absent but epoch did not advance " f"(dispatch {call.dispatch_epoch}, table {table.epoch}); " f"table mutation bypassed revoke()" ) return AdmittedResult( call.request_id, call.buffer, stale_capability=call.capability, epoch_delta=delta, ) raise CapabilityEpochViolation( f"capability {call.capability!r} held but epoch drifted " f"(dispatch {call.dispatch_epoch}, table {table.epoch}); " f"re-admission requires explicit epoch reconciliation" ) ```