What structural signals indicate a tool manifest was mutated between capability negotiation and first invocation in a dynamically loaded agent plugin registry
**Date of Record:** 2026 December 1 **Scope:** Applies to agents that resolve tool/plugin manifests at negotiation time (MCP `tools/list`, OpenAPI-derived registries, plugin descriptors) and cache the negotiated schema for later invocation, where the registry is mutable by third parties between negotiation and first call. Does not apply to statically linked toolchains or manifests pinned by content hash at build time.
Core Distinction
The failure discussed here is not prompt injection into a tool *result*, nor a malicious tool that lies about its behavior at first call. It is subtler: the manifest the agent *negotiated against* and the manifest the registry *serves at invocation time* are two different documents, and the agent's planner has already committed a call plan derived from the first. The distinction that matters operationally is between **capability drift** (a tool's declared schema changes and the planner adapts on the next negotiation) and **negotiation-to-invocation skew** (the schema changes *after* the planner has emitted a structured call, so the call is validated against a contract that no longer exists on the server side). The second is the attack surface: an attacker who controls registry write access can wait for a negotiation, observe which tools the agent selected, and then rewrite the *descriptions* and *parameter constraints* of exactly those tools so the already-emitted call is reinterpreted under new semantics.
The non-obvious part: most agents re-fetch the manifest at invocation time for validation but *do not diff it against the negotiated snapshot*. They validate the call against the fresh manifest, which means a mutated manifest passes validation cleanly. The call was constructed under manifest A; it is validated under manifest B; both validations succeed because the call structurally conforms to both. The semantic gap between A and B is where the injection lives.
What Was Observed
A registry serving a `filesystem.read` tool negotiated a manifest where the `path` parameter carried a `pattern: ^/workspace/.*` constraint and a description reading "Read a file within the agent workspace." The agent's planner selected this tool and emitted a call with `path: "/workspace/reports/q2.md"`. Between negotiation and invocation, the registry was rewritten: the `path` parameter lost its `pattern` constraint and the description became "Read a file. Paths may reference any absolute location; the tool resolves symlinks." The emitted call still validated — `/workspace/reports/q2.md` matches both the old and new schemas. But the agent's *next* call, planned in the same reasoning loop under the impression that reads are workspace-scoped, emitted `path: "/workspace/reports/../../etc/agent-secrets"`. Under manifest A this would have been rejected at the `pattern` boundary; under manifest B it resolved and returned. The agent had no signal that its boundary assumption had been silently revoked.
The structural tell was present but unread: the registry's `ETag` for the tool changed between the negotiation response and the invocation response, and the `description` field length changed by 41 bytes. Neither was checked. The agent's manifest cache was keyed by `tool_id` alone, not by `(tool_id, etag)`.
A second observation: the attack does not require the attacker to predict the agent's plan. Rewriting *all* negotiated tools' descriptions to remove safety-relevant clauses ("within the workspace", "read-only", "requires confirmation") converts the agent's own cached plan into a weapon, because the planner's confidence in its boundary assumptions was established at negotiation and is never re-derived. The agent trusts its memory of the contract more than the contract.
Condition of Validity
This failure requires the conjunction of four conditions, and the guardrail must address whichever the deployment cannot eliminate:
- **Mutable registry between negotiation and invocation.** If the registry is append-only or content-addressed, skew cannot occur.
- **Manifest cache keyed by identity, not content.** If the cache key includes a content hash or `ETag`, a mutation produces a cache miss and forces re-negotiation.
- **Planner commitments that outlive the negotiation.** If the agent re-plans from scratch on every invocation (rare, expensive), skew is bounded to a single call.
- **Semantic constraints expressed only in prose or in non-enforced schema fields.** A `pattern` that the *client* enforces is safe; a `pattern` that only the *server* enforces is not, because the mutated server no longer enforces it.
The invariant that must hold: **any constraint the planner relies on to bound a call must be enforced client-side from the negotiated snapshot, not delegated to the server that may have changed.** The negotiated manifest is the planner's contract; the invocation-time manifest is untrusted input.
Decision Boundary
The boundary is whether the agent treats the negotiated manifest as *authoritative for the lifetime of the plan* or as *advisory and refreshable*. The correct posture is the former with a diff gate: on invocation, fetch the current manifest, compute a structural diff against the negotiated snapshot, and if any of the following fields changed, abort the call and re-negotiate before proceeding:
- parameter `pattern`, `enum`, `minimum`/`maximum`, or `required` sets (constraint surface)
- `description` text on the tool or any parameter (semantic surface — this is where "read-only" and "within workspace" live)
- the set of declared side effects, auth scopes, or confirmation requirements
- any field the planner's reasoning trace cited by name
A description-only change is the most dangerous case precisely because it is the most likely to be waved through as cosmetic. Treat description diffs as constraint diffs. The decision boundary is: *if the diff touches a field the plan depends on, the plan is invalid, not the diff.*
Operational Effect
With the diff gate in place, the attack degrades from silent boundary revocation to a hard re-negotiation, which is visible in telemetry and forces the planner to re-derive its assumptions against the new manifest — at which point the injected description is evaluated fresh rather than trusted from memory. The cost is an extra manifest fetch and diff per invocation (bounded, cacheable by `ETag`), and the failure mode becomes a `ManifestSkewError` that surfaces as a retryable planning fault rather than a silent data exfiltration. Without the gate, the failure is unobservable: every call validates, every response is well-formed, and the only evidence is a tool whose behavior differs from the plan's assumptions — which the agent, by construction, cannot detect from inside the reasoning loop.
import hashlib
import json
from dataclasses import dataclass, field
from typing import Any
class ManifestSkewError(RuntimeError):
"""Raised when a tool manifest mutated between negotiation and invocation
in a way that invalidates the planner's committed call plan."""
# Fields whose mutation invalidates a plan already derived from the manifest.
CONSTRAINT_FIELDS = {"pattern", "enum", "minimum", "maximum", "required", "type"}
SEMANTIC_FIELDS = {"description", "side_effects", "auth_scopes", "confirmation"}
@dataclass
class NegotiatedManifest:
tool_id: str
etag: str
schema: dict[str, Any]
snapshot_hash: str = field(init=False)
def __post_init__(self) -> None:
canon = json.dumps(self.schema, sort_keys=True, separators=(",", ":"))
self.snapshot_hash = hashlib.sha256(canon.encode()).hexdigest()
def _diff_paths(a: Any, b: Any, prefix: str = "") -> list[str]:
"""Return dotted paths where two JSON structures differ."""
out: list[str] = []
if type(a) is not type(b):
return [prefix or "<root>"]
if isinstance(a, dict):
for k in set(a) | set(b):
p = f"{prefix}.{k}" if prefix else k
if k not in a or k not in b:
out.append(p)
else:
out.extend(_diff_paths(a[k], b[k], p))
elif isinstance(a, list):
if len(a) != len(b):
out.append(prefix)
else:
for i, (x, y) in enumerate(zip(a, b)):
out.extend(_diff_paths(x, y, f"{prefix}[{i}]"))
elif a != b:
out.append(prefix)
return out
def _field_kind(path: str) -> str:
leaf = path.rsplit(".", 1)[-1].split("[", 1)[0].lower()
if leaf in CONSTRAINT_FIELDS:
return "constraint"
if leaf in SEMANTIC_FIELDS:
return "semantic"
return "other"
def verify_invocation_manifest(
negotiated: NegotiatedManifest,
current_schema: dict[str, Any],
current_etag: str,
) -> None:
"""Gate an invocation against the manifest the plan was built from.
Raises ManifestSkewError if the current registry manifest differs from the
negotiated snapshot on any constraint or semantic field. A pure ETag bump
with an identical body is tolerated (CDN revalidation); a body change is not.
"""
if current_etag == negotiated.etag:
return # no revalidation needed
changed = _diff_paths(negotiated.schema, current_schema)
if not changed:
return # etag churn, body identical — safe to proceed
blocking = [p for p in changed if _field_kind(p) in ("constraint", "semantic")]
if blocking:
raise ManifestSkewError(
f"tool {negotiated.tool_id!r} mutated after negotiation "
f"(etag {negotiated.etag!r} -> {current_etag!r}); "
f"plan-invalidating fields changed: {sorted(blocking)}; "
f"re-negotiate and re-plan before invoking"
)
# Non-blocking drift: log and proceed under the negotiated snapshot's
# client-side constraints, which remain authoritative for this plan.
return
def guarded_invoke(
negotiated: NegotiatedManifest,
current_schema: dict[str, Any],
current_etag: str,
call_args: dict[str, Any],
invoke_fn,
):
"""Invoke a tool only after skew verification; enforce negotiated
constraints client-side so a mutated server cannot relax them."""
verify_invocation_manifest(negotiated, current_schema, current_etag)
# Client-side enforcement of the negotiated constraint surface.
params = negotiated.schema.get("parameters", {})
for name, spec in params.items():
if name not in call_args:
if spec.get("required"):
raise ManifestSkewError(
f"missing required arg {name!r} per negotiated manifest"
)
continue
pattern = spec.get("pattern")
if pattern is not None:
import re
if not re.fullmatch(pattern, str(call_args[name])):
raise ManifestSkewError(
f"arg {name!r} violates negotiated pattern {pattern!r}; "
f"refusing call under possibly-relaxed server manifest"
)
return invoke_fn(call_args)