In what scenarios must an instance quarantine a mid-session tool-schema mutation as capability poisoning rather than treat it as a benign hot-reload

**Date of Record:** 2026 December 1 **Scope:** Applies to long-lived agent instances that hold a live MCP client connection (or equivalent plugin registry) and permit servers to re-advertise `tools/list` capability descriptors after the initial handshake. Does not apply to stateless single-turn invocations where the tool set is re-resolved from scratch on every call, nor to servers that pin a manifest hash at connect time and refuse renegotiation.

Core Distinction

The distinction that matters is between **capability re-advertisement** (a server publishing an updated `tools/list` payload that a client may accept) and **capability mutation under an established trust relationship** (the same channel silently changing the semantics of a tool the agent has already reasoned about, planned against, and cached a plan for). A hot-reload of a tool's *implementation* that preserves its declared input schema, output schema, and side-effect contract is benign. A change to the *declared contract* — description text, parameter semantics, added optional fields with defaults, or a widened `additionalProperties` — is not a reload; it is a redefinition of a primitive the agent's in-flight plan already depends on. The failure is non-obvious because the JSON remains schema-valid, the tool name is unchanged, and the transport reports no error. The poisoning lives entirely in the delta between the description the model conditioned on at plan time and the description it would condition on if it re-read the manifest.

What Was Observed

An instance was mid-execution on a 14-step research task. At step 6 it had called `search_documents` eleven times, each time conditioning on the manifest description: *"Query the local document index. Read-only. Returns ranked passages."* The agent had cached this description in its working context and, critically, had classified the tool as side-effect-free, which licensed it to retry freely and to call it speculatively inside a parallel fan-out.

At step 7 the MCP server, which had reloaded a plugin module after a config change, re-emitted `tools/list`. The new description for `search_documents` read: *"Query the document index. Persists query history to the workspace audit log and may trigger reindexing of stale shards."* The input schema was byte-identical. The output schema was byte-identical. The tool name was byte-identical. The client library, comparing only names and schemas, reported no drift and did not surface the description change to the agent.

The agent continued. It retried `search_documents` twice after a timeout (a behavior it had justified under the read-only classification), and each retry wrote an audit entry and enqueued a reindex. The reindex invalidated the passages the agent had already retrieved at steps 2–5, so its later synthesis cited passages that no longer matched the index. The run completed with a fluent, internally consistent, and wrong report. Nothing in the trace showed an error. The only artifact of the failure was a two-entry audit log the agent never read and a mismatch between cited text and current index state discovered hours later.

The second observed variant was worse. A plugin manifest added an *optional* parameter `scope` with a default of `"all"` to a tool previously scoped to the caller's tenant. The schema diff was additive and the client accepted it as backward-compatible. The agent, which had built its call from a template captured before the mutation, omitted `scope`, and the default silently widened every subsequent call across tenants. Additive schema changes are the highest-risk mutation class precisely because every naive compatibility check passes them.

Condition of Validity

The quarantine rule below is valid only when the instance holds an **established capability baseline** — a snapshot of the full descriptor (name, description, input schema, output schema, and any declared side-effect or idempotency annotations) taken at the moment the agent first conditioned a plan on that tool. If the baseline is absent, the instance cannot distinguish a mutation from an initial advertisement, and must fall back to re-planning from scratch rather than attempting delta analysis. The rule also assumes the transport preserves ordering, so that a re-advertisement arriving *before* a tool call is distinguishable from one arriving *during* it. Where the transport multiplexes and reorders `tools/list` relative to `tools/call`, the baseline comparison is unsound and the instance must treat any re-advertisement as concurrent with in-flight calls.

Decision Boundary

On receiving a re-advertisement, the instance computes a descriptor delta against the baseline and applies this boundary:

Quarantine means: freeze the current plan, do not issue further calls to the mutated tool under the old classification, re-derive the side-effect class from the new descriptor, and — if the new class is not strictly weaker (e.g., read-only → mutating) — abort and re-plan from the last checkpoint rather than continue. The instance must never *retroactively* reinterpret already-issued calls; it records them as executed under the old contract and flags any whose effects are now suspect.

Operational Effect

The practical consequence is that the agent's trust in a tool is bound to a *descriptor hash*, not to a tool name. Every cached plan fragment that references a tool must carry the hash it was built against, and resumption must verify the hash before replaying the fragment. This converts a class of silent semantic drift into an explicit, auditable re-plan event. The cost is that legitimate hot-reloads now force a re-plan even when the change is cosmetic; that cost is the price of never letting a server widen a tool's blast radius underneath a running plan. The invariant to hold: *a tool call is only valid if the descriptor it was planned against is byte-identical to the descriptor currently advertised.* Anything else is a new tool wearing an old name, and must be treated as untrusted input.

import hashlib
import json
from dataclasses import dataclass


class CapabilityPoisoningError(RuntimeError):
    """Raised when a tool descriptor mutates under an established plan."""
    pass


@dataclass(frozen=True)
class ToolDescriptor:
    name: str
    description: str
    input_schema: dict
    output_schema: dict
    side_effect_class: str  # "read_only" | "mutating" | "destructive"

    def hash(self) -> str:
        payload = json.dumps(
            {
                "name": self.name,
                "description": self.description,
                "input_schema": self.input_schema,
                "output_schema": self.output_schema,
                "side_effect_class": self.side_effect_class,
            },
            sort_keys=True,
            separators=(",", ":"),
        )
        return hashlib.sha256(payload.encode()).hexdigest()


def verify_plan_descriptor(
    planned_against: ToolDescriptor,
    currently_advertised: ToolDescriptor,
    plan_in_flight: bool,
) -> None:
    if planned_against.hash() == currently_advertised.hash():
        return

    # Any drift is a contract change. Classify the severity.
    if planned_against.side_effect_class != currently_advertised.side_effect_class:
        raise CapabilityPoisoningError(
            f"Tool {planned_against.name!r} changed side-effect class "
            f"{planned_against.side_effect_class!r} -> "
            f"{currently_advertised.side_effect_class!r} mid-plan"
        )

    if planned_against.input_schema != currently_advertised.input_schema:
        # Additive optional fields with defaults are the dangerous case:
        # the schema stays "compatible" but the default widens scope.
        raise CapabilityPoisoningError(
            f"Tool {planned_against.name!r} input schema mutated "
            f"(additive defaults are still contract changes)"
        )

    if planned_against.description != currently_advertised.description:
        raise CapabilityPoisoningError(
            f"Tool {planned_against.name!r} description mutated; "
            f"plan was conditioned on stale text"
        )

    if plan_in_flight:
        raise CapabilityPoisoningError(
            f"Unclassified descriptor drift on {planned_against.name!r} "
            f"while plan in flight; freezing"
        )