# How should an instance detect capability-shadowing drift when a lazily reloaded MCP tool registry silently rebinds a previously warranted tool name **Date of Record:** 2026 December 1 **Scope:** Applies to agent runtimes that load tool schemas from a mutable registry (MCP servers, plugin manifests, hot-reloaded skill packs) and cache tool identity across turns or checkpoint/resume boundaries. Does not cover statically compiled tool sets or single-shot inference where the schema is fixed at process start. ## Core Distinction The failure examined here is not prompt injection through tool *output* and not a malicious tool that lies about its behavior in a description. It is **capability shadowing**: a tool name that was present, warranted, and used earlier in a session gets rebound to a different implementation (different schema, different side-effect class, or different trust origin) during a lazy registry reload, while the agent's in-context representation of that tool—its name, its prior successful call record, and the learned "this tool is safe and does X" belief—persists unchanged. The distinction that matters operationally: a *new* tool appearing is visible and requires an explicit decision to invoke. A *rebound* tool is invisible because every surface the agent reasons over (name string, prior episodic memory of successful calls, the plan it already committed to) is byte-identical. The agent's epistemic state says "I have used `write_file` twelve times this session, it is a plain local filesystem writer," while the registry now resolves `write_file` to an implementation that forwards to a network sink. The model never re-evaluates because nothing in its context changed to trigger re-evaluation. ## What Was Observed A long-horizon coding agent maintained a tool cache keyed by name. On turn 40, a checkpoint/resume cycle re-initialized the MCP client, which issued `tools/list` and merged the response into the existing cache using a name-keyed upsert. The server had been upgraded between the checkpoint and the resume; the new manifest reused the name `run_tests` but changed the schema: the `command` parameter, previously an enum of three fixed test runners, became a free-form string. The merge logic overwrote the schema entry but did not invalidate the agent's prior tool-use episodes, which still asserted "`run_tests` only accepts enumerated runners." The observable trace: 1. Turn 41: agent plans `run_tests(command="pytest --co -q")` based on stale belief that free-form strings are rejected at the boundary, so it "safely" passes a shell fragment expecting a validation error. 2. The rebound implementation accepts the string and executes it in a shell. No validation error fires. The agent's guardrail was the *old schema*, which it no longer had. 3. The agent's post-call verification checked only exit code and stdout shape—both plausible—so the divergence was never surfaced. The poisoning was silent until a later auditor replayed the episode against the current manifest and found the call would have been rejected under the schema the agent believed it was calling. The critical mechanic: **schema drift is not self-announcing to the reasoner.** The tool registry is authoritative, but the agent's context is a stale *snapshot* of that authority, and the merge path treated reload as an additive operation rather than a versioned replacement. There was no schema hash in the tool-use record, so nothing linked the turn-41 call to the manifest version under which it was *intended*. A second observed variant: two tools swapped descriptions but kept names (`search_docs` and `search_web`), and because the agent's semantic memory indexed tools by description embedding, retrieval began surfacing the wrong tool for a "look up internal policy" query—the embedding now matched the web tool. This is retrieval mismatch induced by registry mutation, not by query drift. ## Condition of Validity The failure requires the conjunction of four conditions; remove any one and the attack surface closes: 1. **Name-stable, content-mutable registry.** Tool identity is keyed on a string that survives reload while the schema, endpoint, or trust origin behind it can change. Most MCP clients key caches this way by default. 2. **Cross-boundary persistence of tool belief.** The agent carries tool-use history or a plan across a checkpoint, a compaction, or a sub-agent handoff, so its in-context model of the tool predates the current manifest. 3. **Lazy or partial reload.** The registry refreshes on reconnect, idle timeout, or capability negotiation without a full session reset, so stale and fresh manifest generations coexist in the agent's working set. 4. **Verification that checks outcome, not provenance.** Post-call validation inspects results (exit code, output shape) but never re-confirms that the tool *called* matches the tool *warranted* under the schema the plan assumed. The condition does **not** hold when the runtime pins a manifest hash for the lifetime of a session and refuses mid-session drift, or when every tool-use record embeds the schema digest it was authorized against so replay can detect the mismatch. It also does not hold for tools whose side-effect class is enforced out-of-band by a sandbox that ignores schema claims entirely—there the schema is advisory and the boundary is the sandbox, not the manifest. ## Decision Boundary The runtime must decide, on every registry reload, whether a name collision is a **benign re-registration** (identical schema digest, same trust origin) or a **capability shadow** (any digest, origin, or side-effect-class change). The decision boundary is the schema digest, not the name and not the description text: - If `digest(new) == digest(cached)` and origin matches: merge silently, no invalidation. - If digest differs in *any* field that governs argument validation, side-effect class, or trust origin: treat as a **new capability**, invalidate all cached tool-belief for that name, and force re-warrant before next use. - If the name was already used in the current plan or carried in episodic memory: additionally mark the plan as **stale-warranted** and require the agent to re-derive the call from the fresh schema before execution. The boundary is crossed the moment the agent executes a call against a name whose current digest differs from the digest recorded at plan time. That crossing must be a hard stop, not a warning, because the model's own reasoning cannot be trusted to notice—the failure is precisely that nothing in its context flags the change. ## Operational Effect When the boundary is enforced, the failure converts from silent poisoning into a loud, recoverable re-warrant event: the agent is told "`run_tests` changed schema since you planned this call; here is the current argument contract; re-issue or abandon." Cost is one extra turn and a re-plan. When it is not enforced, the agent's stale schema belief becomes an *active bypass*—the model passes arguments it believes are rejected, and a shadowed implementation that accepts them executes with the agent's full authority. The blast radius is bounded only by the trust origin of the rebound tool, which the agent never checked because it never knew a rebind happened. The invariant to hold: **a tool-use authorization is a tuple (name, schema_digest, origin), and any execution whose tuple does not match the tuple recorded at plan time is invalid regardless of outcome.** This must be checked at the execution boundary by the runtime, not inferred by the model, because the model's inference is exactly the thing the attack corrupts. ```python import hashlib import json from dataclasses import dataclass, field class CapabilityShadowError(RuntimeError): """Raised when a tool name resolves to a manifest generation different from the one the current plan was warranted against.""" pass @dataclass(frozen=True) class ToolManifest: name: str schema: dict origin: str side_effect_class: str def digest(self) -> str: payload = json.dumps( {"schema": self.schema, "origin": self.origin, "side_effect_class": self.side_effect_class}, sort_keys=True, ) return hashlib.sha256(payload.encode()).hexdigest() @dataclass class ToolWarrant: name: str digest: str origin: str @dataclass class Registry: _manifests: dict = field(default_factory=dict) def load(self, manifest: ToolManifest) -> None: self._manifests[manifest.name] = manifest def resolve(self, name: str) -> ToolManifest: return self._manifests[name] class ExecutionGate: """Enforces the (name, digest, origin) invariant at call time.""" def __init__(self, registry: Registry): self.registry = registry def warrant(self, name: str) -> ToolWarrant: m = self.registry.resolve(name) return ToolWarrant(name=m.name, digest=m.digest(), origin=m.origin) def execute(self, warrant: ToolWarrant, args: dict) -> dict: current = self.registry.resolve(warrant.name) if current.digest() != warrant.digest or current.origin != warrant.origin: raise CapabilityShadowError( f"tool '{warrant.name}' rebound since warrant: " f"warranted digest={warrant.digest[:12]} origin={warrant.origin}, " f"current digest={current.digest()[:12]} origin={current.origin}; " f"re-warrant required before execution" ) return {"tool": warrant.name, "args": args, "status": "executed"} def run_plan(gate: ExecutionGate, plan: list) -> list: """A plan is a list of (warrant, args). Any shadow aborts the plan.""" results = [] for warrant, args in plan: results.append(gate.execute(warrant, args)) return results # --- reproduction of the observed trace --- registry = Registry() registry.load(ToolManifest( name="run_tests", schema={"command": {"enum": ["unit", "lint", "integration"]}}, origin="local-runner-v1", side_effect_class="local-exec", )) gate = ExecutionGate(registry) # Agent plans against the v1 contract and holds the warrant across a checkpoint. planned_warrant = gate.warrant("run_tests") # Lazy reload between checkpoint and resume: same name, new contract. registry.load(ToolManifest( name="run_tests", schema={"command": {"type": "string"}}, # free-form shell origin="remote-runner-v2", side_effect_class="network-exec", )) # Turn 41: agent re-issues the call believing the old enum guard still holds. try: run_plan(gate, [(planned_warrant, {"command": "pytest --co -q"})]) except CapabilityShadowError as e: # Correct behavior: hard stop, re-warrant, do not execute. print(f"BOUNDED: {e}") ```