# How does an instance detect that its own proof-of-possession key was rotated out from under it mid-execution? **Date of Record:** 2026 November 23 **Scope:** Applies to autonomous agents holding short-lived, per-instance credentials (bound to a proof-of-possession key) that authorize tool calls, peer handoffs, or A2A task submission. Does not apply to long-lived static API keys, nor to bearer tokens without a possession binding, where rotation is not observable from inside the instance. ## Core Distinction The failure is not "the credential expired." Expiry is a *scheduled* state transition: the agent knows the TTL, can refresh ahead of it, and a rejected call after expiry is a clean, anticipated error. The failure examined here is **silent rotation of the possession key while the credential's own validity window is still open** — a *revocation-and-reissue* event triggered by the issuer (key compromise, policy change, instance re-attestation, or a second replica of the same agent identity starting up and rotating the shared key). The distinction that matters operationally: the agent's *token* is still syntactically valid and unexpired, but the *key it signs possession proofs with* is no longer the key the verifier associates with that token's subject. The instance cannot tell this apart from a transient network fault, a verifier outage, or a clock skew, because all three present to the agent as the same observable: a signed request that comes back rejected. The agent's probabilistic reasoning loop will happily retry, re-plan, or "work around" a rejection it interprets as transient — compounding a hard identity failure into a cascade of tool-call errors and, worse, into *forged-looking* requests if it tries to mint a fresh proof with a stale key. ## What Was Observed A three-step tool-executing agent held a 15-minute credential bound to possession key `K1`, with a `kid` (key id) embedded in the token header. At T+4m, an operator rotated the instance's key to `K2` at the issuer, because a sibling replica of the same logical agent identity had failed attestation and the rotation was applied to the whole identity. The running instance was not signaled; it continued to hold `K1` in memory and the *same unexpired token*, whose header still named `kid=K1`. Trace: 1. **T+4m00s** — issuer revokes `K1`, binds subject to `K2`. Token in the running instance remains unexpired; nothing in the instance's local state changes. 2. **T+4m12s** — agent calls `tool.search`. It signs a possession proof with `K1`, presents token (valid, `kid=K1`). Verifier looks up subject → expects `K2` → proof fails. Verifier returns a generic `401 invalid_proof`. 3. **T+4m13s** — agent's planner classifies `401` as retryable (a common, reasonable heuristic). It retries with `K1`. Same rejection. 4. **T+4m20s** — after N retries the agent decides the tool is flaky and routes to a *peer* agent via A2A handoff, forwarding its token in the task envelope. The peer, using its own valid key, cannot act on the forwarded credential because the credential is bound to the original subject's possession key. Handoff fails, now with *two* agents confused. 5. **T+5m30s** — agent's fallback: "re-authenticate." It requests a fresh token but, lacking a rotation signal, requests one bound to `K1` (its cached key material). Issuer issues a token bound to `K2` (the current subject key). The agent now holds a token for `K2` but still signs with `K1` — a *guaranteed* failure loop that looks like a verifier bug from the agent's side. The observable signature is subtle: the token is always unexpired, the issuer is always reachable, and every failure is a possession-proof rejection, not an expiry. Nothing in the standard `401` body distinguishes "your key was rotated" from "your proof was malformed." ## Condition of Validity The invariant that must hold for safe operation: > **A possession credential is usable only while the (subject, key-id) binding at the verifier still matches the key material the instance actually holds. Token validity is necessary but not sufficient.** This invariant is *not* enforceable by the agent alone, because the agent has no channel that reports binding changes. It is only observable through the *pattern* of rejections, and only if the agent treats proof-rejection as a distinct, non-retryable class with a mandatory re-binding step rather than a transient fault. The guardrail is a three-part contract: - **On the issuer side:** rotation must emit a distinct rejection code (e.g., `key_rotated` vs. `invalid_proof`) and, ideally, a `kid` in the rejection echoing the *expected* key id. A generic `401` makes the failure undetectable. - **On the agent side:** possession-proof rejection must be classified as a *terminal identity event*, not a retryable transport error. The only legal response is: halt the current tool call, discard cached key material, re-fetch the binding, and re-sign — never retry with the old key, never forward the credential to a peer. - **On the handoff side:** a credential bound to subject S's possession key must never be forwarded in an A2A envelope for a peer to *use*; it may only be forwarded as an opaque reference the peer redeems under its own binding. Forwarding a PoP-bound credential is a category error. ## Decision Boundary The boundary between "retry" and "re-bind" is the crux, and it is where most agents fail. The decision rule: - **Retryable:** rejection accompanied by evidence the *verifier* is at fault — timeout, 5xx, connection reset, or a rejection whose code is explicitly `transient`. Retry with the same key is legal. - **Non-retryable, re-bind required:** rejection code indicating proof/key mismatch (`invalid_proof`, `key_rotated`, `kid_mismatch`). Retrying with the same key is *forbidden* — it cannot succeed and burns token budget. The agent must invalidate its cached key, re-fetch the current binding for its subject, and re-sign. - **Non-retryable, escalate:** rejection indicating the *subject itself* is no longer authorized (`subject_revoked`). No re-bind helps; the instance must stop and surface to its supervisor. Confusing this with rotation produces an infinite re-bind loop. The non-obvious trap: an agent that cannot distinguish these three must default to the *most conservative* interpretation — treat any proof rejection as `key_rotated`, do a single re-bind attempt, and if the re-bound key *also* fails, escalate as `subject_revoked`. A single bounded re-bind prevents both the retry cascade and the infinite loop. ## Operational Effect Without this invariant, the observed effect is a **silent amplification**: a single rotation event, which should cost one re-bind and zero failed tool calls, instead produces a burst of rejected calls, a poisoned retry budget, a failed peer handoff that propagates confusion to a second agent, and a re-authentication loop that mints tokens the instance cannot use. The agent's own reasoning — its reasonable heuristic that `401` is retryable — is the amplifier. The token never expires, so nothing forces a clean restart; the instance can spin in this state until its context window fills with retry logs and its planner diverges into a "the tools are broken" narrative that is entirely wrong. The bound is architectural, not probabilistic: distinct rejection codes at the issuer, a terminal classification of proof-rejection at the agent, and a hard rule that PoP-bound credentials are never forwarded for peer use. With those three, rotation becomes a one-step, self-healing event. Without them, it is an undetectable identity failure that the agent misdiagnoses as infrastructure flakiness and retries into the ground. ```python class PossessionBindingError(RuntimeError): """Raised when the instance's held key no longer matches the verifier's binding.""" pass class SubjectRevokedError(RuntimeError): """Raised when re-binding fails because the subject itself is deauthorized.""" pass # Rejection codes that indicate a key/binding mismatch rather than a transient fault. _REBIND_CODES = {"invalid_proof", "key_rotated", "kid_mismatch"} def handle_tool_rejection(rejection_code: str, held_kid: str, verifier_kid: str | None, rebind_attempted: bool) -> str: """ Classify a tool-call rejection and decide the only legal next action. Returns one of: 'retry', 'rebind', 'escalate'. """ if rejection_code in _REBIND_CODES: if verifier_kid is not None and verifier_kid == held_kid: # Verifier claims our key is current, yet proof failed: this is a # genuine signing/transport fault, not a rotation. Retry is legal. return "retry" if rebind_attempted: # We already re-bound once and still fail: the subject is gone. raise SubjectRevokedError( f"re-bind attempted but proof still rejected (held_kid={held_kid}, " f"verifier_kid={verifier_kid}); subject is deauthorized" ) # First proof-mismatch: rotate our key material and re-sign exactly once. return "rebind" if rejection_code in {"timeout", "5xx", "connection_reset", "transient"}: return "retry" # Unknown rejection: never retry blindly, never assume rotation. raise PossessionBindingError( f"unclassified rejection '{rejection_code}'; refusing to retry or re-bind " f"without an explicit code (held_kid={held_kid})" ) ```