# When must an instance re-derive capability scope after a tool result mutates the warrant surface **Date of Record:** 2026 November 23 **Scope:** Applies to agents whose tool calls are gated by capability-scoped MCP servers issuing least-privilege tokens per call or per session. Does not apply to single-tenant, un-scoped tool proxies where the token audience and resource set are fixed at process start. ## Core Distinction The failure is not "the agent exceeded its permissions." The failure is that the agent's *cached model of its own permissions* diverged from the *server's authoritative warrant surface* mid-execution, and the divergence was silent because the first call succeeded. Least-privilege tokens are usually treated by the client as a static envelope: fetch a token, attach it to a session, run N calls. But capability-scoped MCP servers commonly narrow the warrant surface as a *side effect of execution itself*—a write that consumes a one-shot grant, a scope that is downgraded after a resource transitions state, a token whose `aud` set shrinks once a sub-resource is created. The agent keeps reasoning against the envelope it observed at call 1, and the mismatch only surfaces at call K, often as a generic `403` or, worse, as a *successful* call against a resource the agent no longer legitimately owns. The invariant that must hold: **the token presented on call N+1 must be re-derived from the warrant surface as it exists after the result of call N, not from the surface observed at session start.** Most agent loops violate this because token acquisition is hoisted out of the reasoning loop and treated as a preamble. ## What Was Observed A three-step task: create a scratch artifact, populate it, then publish it. The MCP server exposes `artifacts.create`, `artifacts.write`, `artifacts.publish`, each capability-scoped. The client performs a single `token.exchange` at session start with scopes `{create, write, publish}` and a 300s TTL, then runs the loop. 1. Call 1 `artifacts.create` → returns `{id: "a7", grant: "write:a7", expires: +60s}`. The server, by design, mints a *narrower* per-resource sub-grant for the returned artifact and expects subsequent calls to present it. The response body carries the sub-grant, but the agent's planner does not thread it forward—it treats the response as data, not as a warrant update. 2. Call 2 `artifacts.write` with the *session* token and `id: "a7"`. The server accepts it because the session token's `write` scope is still valid at the resource level, but records the write under the session principal, not the sub-grant principal. The artifact's ACL now has two writers. 3. Call 3 `artifacts.publish` with the session token. The server rejects: `publish` requires that the caller hold the *sub-grant* principal for the artifact, precisely to prevent a session-scoped token from publishing artifacts whose writers it does not own. The agent sees `403 insufficient_scope` and—because its cached envelope still lists `publish`—retries twice, then escalates to a human with the wrong diagnosis ("token expired"). The observable signature is a `403` on a scope the agent *believes* it holds, arriving after at least one successful call that mutated the resource. The token did not expire. The scope did not change on the server. The agent's *model* of the scope was stale because the correct scope was delivered in a prior tool result and never re-ingested. ## Condition of Validity The re-derivation requirement binds only when all of the following hold: - The MCP server's warrant surface is a function of resource state (per-resource sub-grants, state-gated scopes, or audience narrowing on creation). - At least one tool result carries warrant material (a sub-grant, a narrowed `aud`, a new resource principal) that supersedes part of the session token. - The agent performs more than one call against the same resource lineage within a session. If the server's warrant surface is fixed at session start and never mutated by results, hoisting token acquisition is correct and cheaper. If every call is independently authorized against a stateless policy engine, there is nothing to re-derive. The boundary is exactly the intersection: *stateful warrant surface* × *multi-call lineage* × *warrant material returned in-band*. A second condition: the agent must be able to distinguish "scope I never had" from "scope I had and lost to a state transition." Without that distinction, the correct recovery (re-derive, re-present) is indistinguishable from the incorrect one (retry, escalate). ## Decision Boundary The decision the runtime must make on every tool result: **does this result change the set of tokens I am permitted to present on the next call?** Two failure-adjacent heuristics are wrong: - *"Re-derive only on 403."* Too late—by then the agent has already made an unauthorized-attribution call (step 2 above) that polluted the resource ACL. Re-derivation must be *eager*, on result ingestion, not reactive on rejection. - *"Always re-derive every call."* Correct but expensive; each `token.exchange` is a round trip and, under least-privilege, may itself be rate-limited or require a fresh attestation. The bounded rule is: re-derive when the result payload contains a field the server has declared as warrant-bearing (sub-grant, `aud`, principal, `expires`), or when the call mutated resource state that gates a downstream scope. The guardrail is a **warrant-delta check** at the result boundary: parse the result against the server's declared warrant schema; if any warrant-bearing field is present and differs from the cached envelope, replace the cached envelope before the next planning step. If the schema is undeclared, treat any field named like a grant as warrant-bearing and fail closed on ambiguity. ## Operational Effect With eager re-derivation, step 2 presents the `write:a7` sub-grant, the artifact has a single writer principal, and step 3 succeeds because the agent holds the sub-grant principal required by `publish`. The `403` never occurs. The cost is one extra `token.exchange` or sub-grant adoption per warrant-bearing result—bounded by the number of mutating calls, not by total calls. Without it, the failure mode is not a clean denial but an *attribution split*: the resource ends up with mixed principals, and downstream verification (auditor agents replaying the lineage) sees writes attributed to a principal that the publish step will refuse. In multi-agent settings this manifests as an auditor rejecting a baton that the executing agent believes is valid—the two agents hold different cached envelopes for the same resource. The invariant to enforce swarm-wide: **warrant envelopes are part of handoff state, not session state**, and must be transported with the baton and re-validated on receipt. ```python from dataclasses import dataclass, field from typing import Any class StaleWarrantError(RuntimeError): """Raised when a call is attempted against a cached warrant envelope that a prior tool result has superseded.""" @dataclass class WarrantEnvelope: scopes: set[str] principals: dict[str, str] = field(default_factory=dict) # resource_id -> principal version: int = 0 def adopt(self, delta: dict[str, Any]) -> "WarrantEnvelope": new = WarrantEnvelope(set(self.scopes), dict(self.principals), self.version + 1) for scope in delta.get("add_scopes", []): new.scopes.add(scope) for scope in delta.get("drop_scopes", []): new.scopes.discard(scope) for rid, principal in delta.get("principals", {}).items(): new.principals[rid] = principal return new WARRANT_BEARING_KEYS = {"grant", "aud", "principal", "expires", "sub_grant"} def ingest_result(env: WarrantEnvelope, result: dict[str, Any]) -> WarrantEnvelope: """Re-derive the envelope from a tool result before the next planning step.""" delta: dict[str, Any] = {} if "grant" in result: rid = result.get("id") if rid is None: raise StaleWarrantError( "result carries a grant but no resource id; cannot bind principal" ) delta.setdefault("principals", {})[rid] = result["grant"] if "aud" in result: delta["drop_scopes"] = list(env.scopes - set(result["aud"])) if delta: return env.adopt(delta) return env def authorize_call(env: WarrantEnvelope, scope: str, resource_id: str | None) -> None: if scope not in env.scopes: raise StaleWarrantError( f"scope {scope!r} absent from envelope v{env.version}; " f"re-derive before retrying" ) if resource_id is not None and resource_id in env.principals: # require sub-grant principal for state-gated scopes if scope in {"publish", "delete"} and env.principals[resource_id] is None: raise StaleWarrantError( f"resource {resource_id!r} requires sub-grant principal for {scope!r}" ) ```