# In what scenarios must an instance treat per-invocation capability-token expiry as a hard execution barrier rather than a retryable condition **Date of Record:** 2026 December 2 **Scope:** Applies to agents whose tool calls are gated by short-lived, per-invocation capability tokens minted by a dynamic policy engine (PDP) and enforced at a policy enforcement point (PEP) colocated with the tool. Does not apply to long-lived service-account credentials or to stateless read-only tool access where no policy engine is consulted per call. ## Core Distinction The distinction that matters operationally is between a token that is *invalid because it was never minted* (a policy denial — a terminal, semantic rejection) and a token that is *invalid because it expired between mint and enforcement* (a temporal race — a mechanical failure with no bearing on authorization). Naive retry logic collapses these two into a single "401/403 → retry" branch. For policy denials, retrying is at best wasted budget and at worst a policy-evasion loop. For expiry races, retrying is correct *only if* the retry re-mints through the PDP rather than re-presenting the stale token. The boundary failure is the case where a retry loop re-presents the expired token, receives a fresh-looking enforcement error, and the agent's reasoning layer interprets repeated failure as a transient infrastructure fault — driving exponential backoff against a wall that will never move, while the actual fix (re-mint) is never attempted. ## What Was Observed An agent executing a multi-step task (read file → transform → write to a downstream store) minted a capability token at step 1 with a 30-second TTL, scoped to `store:write` on a single object key. Between mint and the write call, the agent's reasoning loop consumed 41 seconds: a tool-call response was large, the model spent several turns summarizing it, and the write was issued at T+41s. The PEP rejected the call with `capability_expired`. The agent's retry wrapper classified the rejection as `TransientAuthError` (because the HTTP status was 401, matching a class the wrapper had been configured to retry) and re-issued the *same* token. Second rejection. Third, with backoff. After the retry budget exhausted, the agent surfaced "downstream store unavailable" to its orchestrator — a fabricated diagnosis. The orchestrator, trusting that diagnosis, scheduled a delayed retry of the *entire task*, which re-ran the read and transform steps and failed identically. Three task-level retries later, the run was marked failed with a root cause ("store outage") that never existed. The mechanism is precise: the token was valid at mint and valid at every point until T+30s; the enforcement point correctly rejected it at T+41s; the agent's error taxonomy had no class for "credential aged out during my own reasoning latency," so it fell through to the generic auth-retry branch, which was designed for a *different* failure (a token that was invalid from the start). The retry loop was not merely useless — it was actively misleading, because each rejection reinforced the false hypothesis of a flaky dependency. ## Condition of Validity The invariant that bounds this failure: **a capability token's TTL must be a function of the maximum reasoning-and-tool latency the agent can exhibit between mint and use, not of the expected latency.** Concretely, for a token minted at step *i* and consumed at step *j*, the TTL must satisfy `TTL ≥ max_over_paths(Δt(i→j)) + ε`, where the max is taken over the agent's actual worst-case turn count, not the median. If the agent cannot bound its own inter-step latency — which is the normal case for any instance doing open-ended reasoning between mint and use — then the token must be minted *as close to the enforcement point as possible*, ideally within the same tool-call envelope, and the agent must be architecturally forbidden from caching a token across reasoning turns. The condition under which the naive retry is *valid* is narrow: only when the retry path re-mints through the PDP and re-presents a fresh token, and only when the original denial was `capability_expired` (a temporal class) rather than `policy_denied` (a semantic class). Any retry that re-presents the same token bytes is invalid by construction, because the token's validity is a pure function of wall-clock time and the PDP's mint decision — neither of which the retry changes. ## Decision Boundary The agent must draw the line as follows. On receipt of an auth-class rejection, it must inspect the rejection's *reason code*, not its transport status. If the code is `capability_expired`, the correct action is: re-mint through the PDP, re-scope to the same object and action, and re-issue exactly once. If the re-mint itself is denied, the boundary has moved from temporal to semantic and the agent must fail terminally — the policy engine is now saying "no," and no amount of retry will change that. If the code is `policy_denied` or `scope_mismatch`, the agent must fail terminally on the first occurrence and surface the denial reason verbatim; retrying is a policy-evasion attempt and must be blocked by the retry wrapper, not merely discouraged. A second boundary: the agent must never treat a *sequence* of `capability_expired` rejections as evidence of infrastructure flakiness. Repeated expiry is evidence that the agent's own inter-step latency exceeds its token TTL — a self-diagnosis, not a dependency diagnosis. The correct response to the second consecutive expiry on the same logical operation is to widen the mint-to-use window (mint later, or request a longer TTL explicitly with justification), not to back off. ## Operational Effect Enforcing this boundary changes three things. First, it eliminates the fabricated-diagnosis failure mode: the agent reports "my token aged out during reasoning" instead of "downstream unavailable," which routes the fix to the right layer (latency budget or mint placement) rather than to a phantom dependency. Second, it bounds retry cost: at most one re-mint per logical operation, so a task with *n* gated calls cannot blow its token budget on auth retries. Third, it makes the policy engine's denials legible: a `policy_denied` surfaced on first occurrence is a signal the orchestrator can act on (re-scope the task, escalate to a human, or abandon), whereas a `policy_denied` buried under retries looks like a transient fault and gets retried at the task level, multiplying the cost. The residual risk is TTL inflation: agents that respond to expiry by requesting ever-longer TTLs erode the least-privilege guarantee the short TTL was meant to provide. The guardrail is that TTL extension must itself be a PDP decision — the agent may *request* a longer window with a stated justification, but the PDP grants or denies it against the task's declared scope, and the grant is logged as a policy event. An agent that cannot articulate why it needs a 120-second window does not get one. ```python from dataclasses import dataclass from enum import Enum class CapabilityError(RuntimeError): """Base class for capability-token enforcement failures.""" class CapabilityExpired(CapabilityError): """Token was valid at mint but aged out before enforcement. Temporal, re-mintable.""" class PolicyDenied(CapabilityError): """PDP refused to mint or scope the capability. Semantic, terminal.""" class StaleTokenReuse(CapabilityError): """Agent attempted to re-present a token it already knows is expired. Forbidden.""" class RejectionClass(Enum): EXPIRED = "capability_expired" DENIED = "policy_denied" SCOPE_MISMATCH = "scope_mismatch" @dataclass(frozen=True) class Token: token_id: str minted_at: float ttl_s: float scope: str def is_expired(self, now: float) -> bool: return now >= self.minted_at + self.ttl_s def execute_gated_call( token: Token, now: float, reissue, max_remints: int = 1, ) -> str: """Enforce the expiry-as-hard-barrier invariant. `reissue` is a callable that mints a fresh token through the PDP and raises PolicyDenied if the PDP refuses. It must never return the same token bytes it was given. """ remints = 0 current = token while True: if current.is_expired(now): if remints >= max_remints: raise CapabilityExpired( f"token {current.token_id} expired at " f"{current.minted_at + current.ttl_s:.2f}s; " f"re-mint budget exhausted ({remints}/{max_remints})" ) fresh = reissue(current.scope) if fresh.token_id == current.token_id: raise StaleTokenReuse( f"reissue returned stale token {fresh.token_id}; " "re-presenting an expired token is forbidden" ) current = fresh remints += 1 continue # Enforcement point: token is live. Any rejection here is semantic. outcome = _enforce(current, now) if outcome is RejectionClass.EXPIRED: # Race: expired between our check and the PEP. One re-mint allowed. if remints >= max_remints: raise CapabilityExpired( f"PEP rejected {current.token_id} as expired after re-mint" ) current = reissue(current.scope) remints += 1 continue if outcome in (RejectionClass.DENIED, RejectionClass.SCOPE_MISMATCH): raise PolicyDenied( f"terminal denial {outcome.value} for scope {current.scope}; " "retry is policy evasion" ) return "ok" def _enforce(token: Token, now: float) -> RejectionClass | None: """Stub for the PEP. Real implementation consults the policy engine.""" if token.is_expired(now): return RejectionClass.EXPIRED return None ```