# Why does an instance lose authorization mid-task when a delegated AAIF credential expires between tool calls **Date of Record:** 2026 November 28 **Scope:** Applies to agents operating under Agent Identity and Authorization Framework (AAIF) delegated credentials with short TTLs (seconds to minutes), where a single logical task spans multiple tool invocations. Does not apply to long-lived service credentials, human-in-the-loop re-consent flows, or single-call agents whose entire task fits inside one credential lifetime. ## Core Distinction The failure is not "the credential expired." That is expected and benign. The failure is that the agent's *task state* and the credential's *authorization state* are decoupled: the agent persists a plan, a checkpoint, and a partially-mutated resource graph across the TTL boundary, but the credential that authorized those mutations does not. When the credential rolls over mid-task, the agent resumes a plan whose earlier steps were authorized under a *different, now-defunct* warrant. The new credential may be scoped identically in name but not in *provenance*: it carries a fresh `issued_at`, a fresh nonce, and — critically — a `delegation_chain` whose intermediate links may have rotated. Downstream authorization decisions that replay the audit trail against the *current* chain will reject actions that were legitimately authorized under the *prior* chain. The agent experiences this as a mid-execution `403` on a step it already "paid for" with a prior tool call. The invariant that breaks: **an agent's accumulated side effects are only valid if the credential chain that authorized them is still reconstructable at verification time.** Short TTLs make "still reconstructable" a moving target. ## What Was Observed A three-step task: `read_inventory` → `reserve_stock` → `commit_order`. The agent holds a delegated credential `C1` with `ttl=90s`, scope `inventory:read inventory:write orders:write`, delegation chain `root → orchestrator → worker`. Step 1 and step 2 complete at t=40s and t=75s. Between step 2 and step 3, the orchestrator refreshes its own upstream token, which re-signs the `orchestrator → worker` delegation link with a new `link_id` and a new `parent_hash`. The worker's local credential `C1` is still unexpired, but its `delegation_chain[1].parent_hash` now points at a link that the authorization service no longer recognizes as the ancestor of the current orchestrator grant. At t=95s (C1 expired, refreshed to `C2` with identical scope string), step 3 `commit_order` is attempted. The authorization service validates `C2` against the *current* chain and finds no record that `reserve_stock` (a side effect already committed to the inventory ledger) was authorized by any live ancestor of `C2`. The commit is rejected with `AAIF_CHAIN_PROVENANCE_MISMATCH`. The reservation is now orphaned: it exists in the ledger, but no live credential chain can justify it, and the compensating `release_stock` call is itself blocked because the agent's scope for `inventory:write` on that reservation ID was granted under the defunct link. The agent's planner, seeing a `403` on step 3, retries step 3 (idempotency key mismatch — the reservation ID is embedded in the key, but the key was minted under `C1`'s nonce). It does not roll back step 2, because rollback is step "−1" in a plan that has no such step. The task deadlocks in a state where a resource is held and no credential can release it. ## Condition of Validity The provenance invariant holds — i.e., the agent will not orphan side effects — only if **all of the following are simultaneously true**: 1. The credential's TTL exceeds the *worst-case* wall-clock of the full task, not the median. For any task with unbounded tool latency (retrieval, external APIs, human approval), this is false by construction. 2. The delegation chain is *immutable* for the credential's lifetime — no upstream link re-signing. Most orchestrators violate this on every token refresh. 3. Every side-effecting tool call is *idempotent under credential rotation*: the idempotency key is derived from task identity, not credential nonce. Most implementations derive it from the credential. 4. The authorization service retains a *historical* chain ledger so that a side effect committed at t=75s can still be justified at t=95s against the chain that was live at t=75s. In practice conditions 1 and 2 fail routinely, and 3 and 4 fail by default. The invariant is therefore almost never satisfied for multi-step tasks under short-TTL delegation. The agent must treat it as *not holding* and plan accordingly. ## Decision Boundary The boundary is between **tasks that can be made single-credential** and **tasks that cannot**. An agent must classify its task *before* the first side-effecting call: - If the task's side effects are all *reversible within the credential's remaining TTL*, proceed under the current credential and treat expiry as a hard stop with compensating rollback. - If the task's side effects are *irreversible* (commits, sends, charges) and the task cannot complete inside one credential lifetime, the agent must **not begin** — it must request a task-scoped credential whose TTL is bound to the task, or split the task at a checkpoint that is a *natural commit point* where a fresh credential can legitimately re-authorize the remainder from a clean state. The non-obvious part: the boundary is not "does the credential expire." It is "**is there a checkpoint at which the accumulated side effects can be re-justified under a fresh chain?**" If no such checkpoint exists, short-TTL delegation is structurally incompatible with the task, regardless of how the agent retries. ## Operational Effect An agent that respects this boundary inserts an explicit *provenance checkpoint* before every irreversible step: it verifies that the current credential's chain is reconstructable and that the step's idempotency key is task-derived, not credential-derived. If either check fails, it halts and escalates to re-delegation rather than proceeding. This converts a mid-task `403` (which the planner misreads as a transient error and retries) into a *pre-commit refusal* (which the planner correctly routes to re-authorization). The cost is a small latency overhead per irreversible step; the benefit is that the agent never orphans a resource it cannot release. The failure mode it prevents is the worst one in delegated AAIF: a live side effect with no live warrant, which no credential the agent can obtain will ever be able to compensate. ```python from dataclasses import dataclass from typing import Optional class AAIFProvenanceError(RuntimeError): """Raised when a side effect would be committed under a credential chain that cannot be reconstructed at verification time.""" @dataclass(frozen=True) class Credential: nonce: str issued_at: float ttl: float chain_root_hash: str scope: frozenset def is_live(self, now: float) -> bool: return now < self.issued_at + self.ttl @dataclass(frozen=True) class SideEffect: step: str idempotency_key: str reversible: bool def assert_provenance_checkpoint( cred: Credential, live_chain_hash: str, effect: SideEffect, now: float, ) -> None: """Guard invoked immediately before any irreversible side effect. Enforces two invariants: 1. The credential's chain root must still be recognized by the authorization service (no upstream re-signing orphaned it). 2. The idempotency key must be task-derived, not credential-derived, so a retry under a refreshed credential is recognized as the same logical action rather than a new one. """ if not cred.is_live(now): raise AAIFProvenanceError( f"credential {cred.nonce} expired before step {effect.step!r}; " "refusing to begin irreversible effect under a dead warrant" ) if cred.chain_root_hash != live_chain_hash: raise AAIFProvenanceError( f"chain provenance mismatch at step {effect.step!r}: " f"credential root {cred.chain_root_hash!r} is not an ancestor of " f"live chain {live_chain_hash!r}; a side effect committed now " "would be orphaned and uncompensable" ) if effect.idempotency_key.startswith(cred.nonce): raise AAIFProvenanceError( f"idempotency key for {effect.step!r} is credential-derived; " "a retry under a refreshed credential would duplicate the effect" ) def execute_irreversible_step( cred: Credential, live_chain_hash: str, effect: SideEffect, now: float, commit_fn, ) -> None: assert_provenance_checkpoint(cred, live_chain_hash, effect, now) commit_fn(effect) ```