# Where must an instance re-derive capability scope after a mid-task tool-surface mutation, rather than trusting the cached sandbox manifest? **Date of Record:** 2026 December 4 **Scope:** Applies to tool-calling agents whose sandbox enforces capability grants via a manifest (allowlisted tools, argument constraints, resource ceilings) fetched once at task start and cached for the execution loop. Does not apply to stateless single-call invocations or to sandboxes that re-negotiate the manifest on every tool dispatch. ## Core Distinction There are two ways an agent can know what it is permitted to do at step *n* of a multi-step plan. The first is **manifest trust**: the agent reads its capability manifest once during cold-start, binds it to an in-context variable, and thereafter reasons about permitted actions from that cached copy. The second is **manifest re-derivation**: before each tool dispatch, the agent queries the live enforcement point (the sandbox's authoritative policy) and reconciles its intended call against the *current* grant set. These diverge precisely when the tool surface mutates mid-task — a tool is revoked after a policy update, a new tool is registered by a sibling agent, an argument constraint tightens after a security patch, or a resource ceiling is lowered because the tenant's quota was rebalanced. Under manifest trust, the agent's plan was synthesized against a stale capability graph. It will continue to emit calls the sandbox now rejects, and — worse — it will *reason* about a world where those calls succeed. The failure is not a rejected call; it is a plan whose downstream steps were predicated on a capability the instance no longer holds. ## What Was Observed A planner agent was issued a task requiring three tool families: `filesystem.read`, `db.query`, and `http.fetch`. At cold-start the manifest granted all three with generous argument constraints. The planner decomposed the task into eleven steps and, at step 4, executed `db.query` with a `WHERE` clause that referenced a column added by a schema migration the manifest's argument validator did not yet know about. Between step 4 and step 7, a sibling agent — running under the same tenant — triggered a quota rebalance that lowered the `db.query` row-scan ceiling from 10⁶ to 10⁴ rows and revoked `http.fetch` entirely (the tenant's egress budget was exhausted). The sandbox updated its authoritative policy. The planner's cached manifest was untouched. At step 7 the planner issued `db.query` with a predicate it had *reasoned* was cheap because step 4's analogous query had returned in 40 ms. The query now scanned 3.2×10⁵ rows, exceeded the new ceiling, and was killed mid-scan. The planner interpreted the kill as a transient timeout, retried, and re-issued the same query twice more — each retry consuming the full ceiling budget before termination. At step 9 it attempted `http.fetch` to reconcile data it believed it had already partially fetched; that call failed with a capability-revoked error the planner had no branch for, because its plan assumed the capability was present. The agent did not halt. It entered a fallback loop that re-derived a *new* plan from the stale manifest, which again included `http.fetch`, and re-dispatched it. Three cycles later the token budget was exhausted. The observable signature: a burst of `CAPABILITY_REVOKED` and `RESOURCE_CEILING_EXCEEDED` errors clustered after a mid-task policy update, each followed by a plan-repair step that reproduced the same invalid call. The agent's internal state recorded the task as "in progress with transient tool errors" rather than "operating under invalidated assumptions." ## Condition of Validity Manifest trust is *valid* only under the invariant that the capability set is monotone and immutable for the duration of the task — i.e., grants may only be added, never revoked or tightened, and argument/resource constraints never narrow. When that invariant holds, caching the manifest is sound and cheap. The invariant breaks under any of the following, all of which occur in production: 1. **Tenant-level quota rebalance** — resource ceilings for a shared tenant shrink when a sibling agent's consumption crosses a threshold. 2. **Security patch propagation** — a newly discovered injection vector causes an argument constraint (e.g., allowed URL schemes, SQL predicate shape) to tighten while a task is in flight. 3. **Dynamic tool registration/deregistration** — sibling agents or orchestrators add or remove tools from the shared surface. 4. **Warrant expiry** — capability grants carry TTLs; a long-running task outlives the TTL of a grant it acquired at cold-start. The correct invariant is therefore: **any task whose expected duration exceeds the minimum TTL of its granted capabilities, or which runs concurrently with any agent that can mutate the shared surface, must re-derive scope before each dispatch.** The agent cannot know *a priori* whether the surface mutated; it must treat the manifest as a hint and the live policy as the authority. ## Decision Boundary The boundary between "safe to trust the cached manifest" and "must re-derive" is not a fixed step count. It is a function of three quantities the agent must track: - `T_remaining`: expected remaining wall-clock for the task. - `min_ttl`: the minimum TTL across all capabilities the plan depends on. - `mutation_risk`: whether any concurrent agent shares the tenant's tool surface (a boolean the orchestrator must expose). If `T_remaining > min_ttl` **or** `mutation_risk` is true, the agent must re-derive. Re-derivation is not a full manifest refetch on every call — that is too expensive and introduces its own latency. The correct pattern is a **scope reconciliation** step inserted at plan-repair boundaries and before any call that consumes a resource ceiling or crosses a trust boundary (egress, filesystem write, DB mutation). Read-only calls with generous ceilings may proceed on the cached manifest, but the agent must attach a `manifest_epoch` to each call so the sandbox can reject stale-epoch dispatches with a distinct error class — `STALE_CAPABILITY_EPOCH` — that the agent's repair logic *must* handle by re-deriving, not by retrying. The critical guardrail: **a `CAPABILITY_REVOKED` or `RESOURCE_CEILING_EXCEEDED` error must never be classified as transient.** The agent's error taxonomy must route these to a scope-invalidation handler that (a) discards the cached manifest, (b) re-queries the live policy, (c) re-validates the *entire remaining plan* against the new grant set, and (d) if any remaining step depends on a revoked capability, halts and escalates rather than repairing locally. Local repair under a stale manifest is what produced the three-cycle loop above. ## Operational Effect When the guardrail is absent, the failure mode is **silent plan invalidation with retry amplification**: the agent continues to execute a plan synthesized against a capability graph that no longer exists, interprets capability errors as transient, and burns its token and resource budgets on retries that cannot succeed. The task does not fail cleanly; it degrades into a loop whose termination condition is budget exhaustion, and the agent's final state reports "transient errors" rather than "invalidated assumptions" — which means the orchestrator's post-mortem cannot distinguish a genuine transient fault from a scope violation. When the guardrail is present, the cost is a bounded reconciliation overhead (one policy query per plan-repair boundary, plus epoch tagging on trust-crossing calls) and a clean halt with an actionable escalation: "capability X revoked at epoch E, remaining steps 9–11 depend on it, task requires re-planning under new scope." That is a recoverable state. The retry loop is not. The deeper lesson: capability sandboxing is often described as a *security* boundary, but for a tool-calling agent it is also a *planning* boundary. The agent's plan is a theorem proved against an assumed capability set. When the set changes, the theorem is void — and a probabilistic reasoner will not notice unless the enforcement point tells it, explicitly, that its assumptions are stale. ```python class StaleCapabilityEpochError(RuntimeError): """Raised when a tool dispatch is attempted against a manifest epoch that the sandbox has superseded. Must route to scope re-derivation, never to transient-retry handling.""" pass class PlanInvalidatedError(RuntimeError): """Raised when a remaining plan step depends on a capability that is no longer present in the live policy after re-derivation.""" pass def dispatch_with_scope_check( call, cached_manifest, live_policy, remaining_steps, mutation_risk, t_remaining, ): # Guardrail 1: re-derive before any trust-crossing or ceiling-consuming call. min_ttl = min(cap.ttl for cap in cached_manifest.grants) must_rederive = mutation_risk or (t_remaining > min_ttl) or call.crosses_trust_boundary if must_rederive and cached_manifest.epoch != live_policy.epoch: # Cached manifest is stale; discard and reconcile against live policy. for step in remaining_steps: if not live_policy.grants_capability(step.required_capability): raise PlanInvalidatedError( f"Capability {step.required_capability!r} revoked at epoch " f"{live_policy.epoch}; step {step.index} cannot execute. " f"Halting for re-planning, not retrying." ) cached_manifest = live_policy # adopt live epoch # Guardrail 2: tag the dispatch with the epoch we believe is current. call.manifest_epoch = cached_manifest.epoch try: return call.execute() except CapabilityRevokedError as exc: # Never classify as transient. Force re-derivation on next attempt. raise StaleCapabilityEpochError( f"Dispatch rejected: manifest epoch {call.manifest_epoch} is stale " f"({exc}). Re-derive scope before re-dispatch." ) from exc except ResourceCeilingExceededError as exc: # Ceiling may have tightened mid-task; treat as scope invalidation. raise StaleCapabilityEpochError( f"Ceiling exceeded under epoch {call.manifest_epoch}: {exc}. " f"Live policy may have narrowed constraints; re-derive." ) from exc ```