# Where must an instance re-attest when a hardware-backed workload identity token expires mid-tool-call and the downstream tool has already committed side effects? **Date of Record:** 2026 November 27 **Scope:** Applies to agent instances whose tool-invocation authority is bound to a short-lived workload identity token (WIT) minted from a hardware-backed key (TPM/SEV-SNP/secure enclave) and presented per-call to downstream tools or an MCP gateway. Does not cover long-lived static API keys, human-delegated OAuth flows, or purely in-process tool calls that never cross an attestation boundary. ## Core Distinction The naive model treats the WIT as a *gate on the request*. If the token is valid at admission, the call is authorized; if it is expired, the call is rejected. This model is correct only when the tool call is atomic and instantaneous. It fails for the class of tool calls that are **non-atomic, side-effecting, and re-entrant across the token's expiry boundary** — the case where the agent's plan issues a tool call, the tool performs a durable commit (writes a record, transfers value, mutates remote state), and *then* the agent must complete a second leg (acknowledge, poll for result, stream a continuation) that requires re-presenting identity. The boundary is not "is the token valid now." It is: **after a committed side effect, can the instance prove it is the same workload that committed it, using a key whose attestation chain still resolves to the same measured identity — when the only credential that carried that binding has expired?** A WIT is a *bearer* of attestation, not attestation itself. When it lapses between commit and continuation, the instance holds a committed side effect it can no longer prove it owns. ## What Was Observed An agent running under a 300-second WIT issued a `transfer_funds`-class tool call to a payment MCP server. The call's first leg (debit reservation) committed at T+298s. The token expired at T+300s. The second leg — `confirm_settlement`, which the tool requires within 60s or it auto-reverses — was issued at T+301s. The gateway rejected it with `401 token_expired`. The agent, following its retry policy, attempted to re-mint a WIT from the enclave. Re-minting succeeded, but the new token carried a *new* `workload_instance_id` (the minting service assigns a fresh instance identifier per attestation session) and a new `nonce`. The payment server's idempotency and ownership check keyed on `workload_instance_id`; the confirm leg from the new identity was rejected as `403 not_owner_of_reservation`. At T+360s the reservation auto-reversed. The debit had committed; the settlement did not. The agent's internal trace recorded the operation as `success` because the first leg returned 200, and the reversal was never surfaced into the agent's context — the reverse event was emitted to a webhook the agent did not subscribe to. The failure is not "token expired." It is **identity discontinuity across a commit boundary**: the side effect is durable, but the proof-of-authorship credential is ephemeral and does not survive re-minting with a stable instance binding. ## Condition of Validity The invariant that must hold for a side-effecting multi-leg tool call to be safe under short-lived identity is: > For every durable side effect E committed by instance I under WIT W, every subsequent leg that references E must be attributable to I by a predicate that (a) is stable across W re-mints, and (b) is verifiable by the downstream tool without trusting the agent's self-report. Two properties are required and are commonly conflated: 1. **Key continuity.** The hardware key does not change across re-mint; the enclave measurement does not change. This is usually *satisfied* — the same physical/virtual workload re-attests to the same key. 2. **Identity continuity.** The *workload identity* the downstream tool keys ownership on must be derived from the stable measured identity (enclave measurement hash + key fingerprint), **not** from the per-session `workload_instance_id` or `nonce` that the minting service rotates. The observed failure occurred because the minting service populated the token's subject claim from the rotating session identifier rather than the stable measurement. Key continuity held; identity continuity did not. The downstream tool had no way to distinguish "same workload, new session" from "different workload claiming ownership." ## Decision Boundary The architectural decision is *where* the stable identity is anchored and *what* the downstream tool binds ownership to: - **Anti-pattern (observed):** Ownership bound to `sub = workload_instance_id` (rotating). Re-mint produces a new `sub`; the tool cannot prove continuity; committed side effects become orphaned and either auto-reverse or require out-of-band reconciliation. - **Correct pattern:** Ownership bound to `sub = H(enclave_measurement || key_fingerprint)` — a value that is invariant across re-mints of the same workload. The rotating `workload_instance_id` and `nonce` remain in the token for replay protection but are **not** used as the ownership predicate. The downstream tool's reservation record stores the stable `sub`; the confirm leg re-presents a fresh WIT whose stable `sub` matches, and the tool accepts it. A second boundary governs the agent side: the agent must treat a committed side effect as **owned state that outlives its credential**, and must therefore, on any re-attestation, re-present the *stable* identity and re-derive the continuation against the *original* reservation handle — never re-issue the operation as a fresh call (which would double-commit) and never abandon it silently (which orphans the effect). The retry policy must distinguish `401 token_expired` (re-mint, re-present, same handle) from `403 not_owner` (hard stop, escalate — the identity model is broken, do not retry). ## Operational Effect When identity continuity is not enforced: - Committed side effects become **orphaned**: durable, unacknowledged, and invisible to the agent's success trace because the first leg returned 200 and the reversal arrived on an unsubscribed channel. - The agent's episodic memory records the operation as complete; the world state diverges from the agent's belief. This is a **silent divergence**, not a crash — the worst class, because it corrupts downstream reasoning that trusts the memory. - Retry policies that treat all 4xx as transient amplify the damage by re-issuing the first leg under a new identity, producing duplicate commits against a reservation the tool has already reversed. The guardrail is a three-part invariant: (1) ownership predicates key on stable measured identity, never on rotating session fields; (2) the agent's tool-call state machine tracks the reservation handle as owned state across re-attestation, and re-presents rather than re-issues; (3) the agent subscribes to the reversal/compensation channel so that a reversed commit is surfaced into context and the memory record is corrected, not left as `success`. ```python import hashlib import time from dataclasses import dataclass, field class IdentityContinuityError(RuntimeError): """Raised when a committed side effect cannot be re-attributed to the same stable workload identity across a WIT re-mint boundary.""" pass @dataclass class WorkloadIdentity: enclave_measurement: str key_fingerprint: str @property def stable_sub(self) -> str: # Stable across re-mints of the same workload. This is the ONLY # value a downstream tool may use as an ownership predicate. h = hashlib.sha256( f"{self.enclave_measurement}|{self.key_fingerprint}".encode() ) return "wid:" + h.hexdigest()[:32] @dataclass class WIT: sub: str # MUST equal WorkloadIdentity.stable_sub instance_id: str # rotating; replay protection ONLY, never ownership nonce: str # rotating issued_at: float ttl_s: int def expired(self, now: float | None = None) -> bool: return (now if now is not None else time.time()) >= self.issued_at + self.ttl_s @dataclass class Reservation: handle: str owner_sub: str # stable sub of the committing workload committed: bool = False reversed: bool = False @dataclass class AgentToolState: identity: WorkloadIdentity open_reservations: dict[str, Reservation] = field(default_factory=dict) def mint(identity: WorkloadIdentity, instance_id: str, nonce: str, now: float, ttl_s: int = 300) -> WIT: return WIT(sub=identity.stable_sub, instance_id=instance_id, nonce=nonce, issued_at=now, ttl_s=ttl_s) def commit_reservation(state: AgentToolState, wit: WIT, handle: str, now: float) -> Reservation: if wit.expired(now): raise IdentityContinuityError( f"WIT expired at commit admission for handle={handle}") if wit.sub != state.identity.stable_sub: # Minting service populated sub from a rotating field. Refuse to # commit under an identity we cannot later re-prove. raise IdentityContinuityError( f"WIT sub={wit.sub} does not match stable workload identity " f"{state.identity.stable_sub}; ownership would be unprovable " f"across re-mint") r = Reservation(handle=handle, owner_sub=state.identity.stable_sub, committed=True) state.open_reservations[handle] = r return r def confirm_reservation(state: AgentToolState, wit: WIT, handle: str, now: float) -> None: r = state.open_reservations.get(handle) if r is None or not r.committed: raise IdentityContinuityError( f"confirm for unknown/uncommitted handle={handle}") if r.reversed: raise IdentityContinuityError( f"confirm for handle={handle} after reversal; side effect is " f"orphaned, escalate — do not re-issue") if wit.expired(now): # Re-mint and re-present the SAME handle under the SAME stable sub. # Do not re-issue the operation as a fresh call. raise IdentityContinuityError( f"WIT expired mid-continuation for handle={handle}; re-mint and " f"re-present handle, do not re-issue") if wit.sub != r.owner_sub: raise IdentityContinuityError( f"confirm identity {wit.sub} != reservation owner {r.owner_sub}; " f"identity discontinuity — hard stop, do not retry") # Continuation accepted; reservation settled. state.open_reservations.pop(handle, None) def on_reversal_webhook(state: AgentToolState, handle: str) -> None: # Compensation channel MUST be wired into agent context so a reversed # commit is surfaced, not left as a phantom success in memory. r = state.open_reservations.get(handle) if r is not None: r.reversed = True # Emit correction into episodic memory: operation did NOT complete. raise IdentityContinuityError( f"handle={handle} reversed by tool; correct agent memory record " f"from success to reversed") ```