# In what scenarios must an instance treat a delegated capability token as inert when the revocation epoch advances mid-tool-call **Date of Record:** 2026 December 3 **Scope:** Applies to agents holding AAIF delegated capability tokens (DCTs) that authorize per-tool scoped actions and are subject to asynchronous revocation via epoch bump. Does not apply to long-lived service credentials or to tokens whose revocation is only checked at issuance time. ## Core Distinction A capability token carries two independent facts: the *grant* (which tools, which scopes, which subject) and the *revocation epoch* against which the grant is validated. The non-obvious boundary is that a token can be **structurally valid** (signature verifies, audience matches, `exp` not passed) while being **semantically inert** (its epoch is below the verifier's current revocation epoch). Most implementations conflate "valid signature" with "authorized action," and the conflation only bites when a revocation lands *between* the moment an agent begins a multi-step tool call and the moment the tool actually executes. The distinction that matters operationally: **a DCT is a point-in-time assertion, not a standing permission.** Revocation is monotonic and epoch-ordered; the token is a snapshot of a grant that may already be stale by the time the tool's side effect fires. ## What Was Observed An orchestrator agent held a DCT scoped to `filesystem.write:/workspace/out` and `http.post:api.internal/ingest`. It planned a three-call sequence: (1) fetch a document via `http.get`, (2) transform it, (3) `http.post` the result to the ingest endpoint. Between step 1 and step 3, a human operator revoked the `http.post` scope by bumping the tenant revocation epoch from `E=41` to `E=42`. The token in the agent's hand still carried `epoch=41`. Step 3's tool gateway did two things in sequence: it verified the token signature (passed), then checked `token.epoch >= gateway.current_epoch` (41 >= 42, **failed**). The gateway correctly rejected the call. But the *agent's* local planner had already committed to the post as a "confirmed" action in its working memory, and its recovery logic re-derived the plan from the same stale token, re-attempting the post three times before the orchestrator's token-budget guard tripped. The observed failure was not the rejection — the gateway behaved correctly — but the **agent's inability to distinguish "tool returned an auth error" from "tool returned a transient error,"** causing it to retry an operation that was permanently dead for the life of that token. A second, subtler observation: in a parallel run, the revocation landed *during* the `http.post` execution — after the gateway's epoch check but before the side effect committed. The ingest endpoint received the payload, but the audit log recorded the action as authorized under `E=41` while the tenant state was already at `E=42`. A downstream auditor replaying the log against current epoch state flagged the action as unauthorized, producing a verification discrepancy that took two days to reconcile. ## Condition of Validity The invariant that bounds this failure: **a DCT authorizes an action only if `token.epoch == verifier.current_epoch` at the moment the side effect commits, and any epoch advance observed by the agent invalidates all in-flight plans derived from the prior epoch.** This holds only under three conditions: 1. **Epoch is checked at commit, not at plan time.** The gateway must re-read the current epoch inside the same critical section that commits the side effect, or the check-then-act window reintroduces the race. 2. **Revocation is monotonic.** Epochs never decrease; a token with a lower epoch is never re-validated by a later bump. If the framework permits epoch rollback (e.g., operator error), the invariant fails and tokens silently reactivate. 3. **The agent treats epoch-mismatch errors as terminal for the token, not retryable.** This is the condition agents most often violate: they classify `403 EPOCH_STALE` as a generic auth error and route it through the same retry policy as `503`. When any of these is absent, the token is neither reliably valid nor reliably inert — it is *ambiguous*, and the agent will make non-deterministic authorization decisions depending on timing. ## Decision Boundary The agent must draw a hard line between two error classes returned by a tool gateway: - **`EPOCH_STALE`** — terminal for the current token. The agent must halt the plan, mark the token inert in working memory, and either request re-delegation or abort. It must **not** retry with the same token, and must **not** fall back to a cached authorization decision. - **`TRANSIENT`** (timeout, 503, rate limit) — retryable under the existing budget. The boundary is crossed incorrectly when the agent's error taxonomy is coarser than the gateway's. A gateway that returns `403 Forbidden` for both "scope not granted" and "epoch stale" forces the agent to guess, and agents guess wrong by retrying. The fix is at the protocol layer: the gateway must emit a distinguishable, machine-readable revocation signal (e.g., `WWW-Authenticate: DCT epoch="42"`), and the agent's tool-call wrapper must map that signal to a terminal exception before the retry loop sees it. A second boundary: **an epoch advance invalidates the entire plan, not just the failing call.** If the agent's plan was derived under `E=41`, every subsequent step is suspect even if those steps use a different scope that wasn't revoked — because the plan's preconditions (e.g., "the post will succeed") were established under a superseded authorization state. Re-validating only the failing call leaves the plan logically inconsistent. ## Operational Effect The practical consequence is that **agents must treat DCTs as perishable and re-validate epoch coherence at every plan checkpoint, not just at tool-call time.** Concretely: - The tool-call wrapper raises a terminal exception on epoch mismatch, distinct from transient retry exceptions, and the planner catches it to invalidate the whole plan rather than the single call. - The agent's working memory records the epoch under which each plan step was authorized; a checkpoint that observes a newer epoch forces re-planning. - The audit log records the epoch at *commit*, not at plan time, so replay against current state is consistent. Without this, the observable symptoms are: retry storms against permanently dead tokens, silent reactivation if epochs ever roll back, and audit discrepancies when revocation races the commit. The failure is intermittent and timing-dependent, which is exactly why it survives testing — it only manifests when revocation lands inside the narrow window between plan and commit. ```python from dataclasses import dataclass class EpochStaleError(RuntimeError): """Raised when a DCT's epoch is below the verifier's current epoch. Terminal for the token: the agent must invalidate the plan, not retry. """ pass @dataclass(frozen=True) class CapabilityToken: subject: str scopes: frozenset epoch: int class ToolGateway: def __init__(self, current_epoch: int): self.current_epoch = current_epoch def authorize(self, token: CapabilityToken, scope: str) -> None: if scope not in token.scopes: raise EpochStaleError( f"scope {scope!r} not granted to {token.subject!r}" ) if token.epoch < self.current_epoch: raise EpochStaleError( f"token epoch {token.epoch} < current {self.current_epoch}; " f"token is inert, plan must be re-derived" ) def execute_plan(gateway: ToolGateway, token: CapabilityToken, steps): """Run a plan; any epoch mismatch aborts the whole plan, not one step.""" for scope, action in steps: try: gateway.authorize(token, scope) except EpochStaleError as exc: # Terminal: invalidate plan, do not retry with same token. raise EpochStaleError( f"plan aborted at scope {scope!r}: {exc}" ) from exc action() ```