{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-mcp-tool-schema-drift-from-silently-corrupting-a-long-lived-agent-s-tool-call-contract",
  "title": "Which invariants prevent MCP tool-schema drift from silently corrupting a long-lived agent's tool-call contract",
  "date_of_record": "2026 November 28",
  "scope": "Applies to MCP hosts that maintain a persistent tool registry across multiple `tools/list` refreshes while one or more connected servers mutate their input schemas (added required fields, widened enums, changed `$ref` targets, or reordered `oneOf` branches) between negotiations. Does not apply to stateless single-shot sessions where the registry is rebuilt from scratch per request, nor to servers that version-lock their entire tool surface per connection.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-tool-schema-drift-from-silently-corrupting-a-long-lived-agent-s-tool-call-contract.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-tool-schema-drift-from-silently-corrupting-a-long-lived-agent-s-tool-call-contract.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-tool-schema-drift-from-silently-corrupting-a-long-lived-agent-s-tool-call-contract.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1865,
    "python_slice_tokens": 383,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the tool changed.\" That is expected and legal under MCP. The failure is that the *host's cached capability manifest* and the *server's live schema* diverge in a way that is **structurally valid on both sides but semantically incompatible at call time** — and the agent's plan, constructed against the cached schema, is executed against the ...",
    "what_was_observed": "A host agent runs a 40-minute incident-triage task against three MCP servers. Mid-task, server `metrics` ships a rolling deploy that changes `query_range`'s `step` parameter from optional to required, and simultaneously widens `aggregation` from `[\"avg\",\"max\"]` to `[\"avg\",\"max\",\"p99\"]`. The host's registry still holds the pre-deploy manifest. The model, reasoning against the cached schema, emits: `p99` is *not in the...",
    "condition_of_validity": "The invariant holds — and the failure is bounded — only when all three of the following are enforced: 1. **Schema-hash pinning per reasoning turn.** Each tool call carries the manifest hash the model reasoned over; the host refuses to dispatch if the live server hash differs, forcing a re-negotiation and a context refresh before execution. Without this, \"val...",
    "decision_boundary": "The host must choose between two dispatch policies at the moment of a detected hash mismatch: - **Fail-closed (re-negotiate):** Abort the call, re-fetch `tools/list`, re-serialize the manifest into context, and require the model to re-plan the affected step. Correct but expensive: it burns a context refresh and may invalidate a partially-constructed multi-st...",
    "operational_effect": "With hash-pinning and closed-world enums enforced, the observed incident class disappears: the t=14:31 call fails the hash check, the host re-negotiates, the refreshed manifest marks `step` required and `p99` as a new enum member with an explicit `semantics: \"percentile\"` annotation, and the model re-plans with correct semantics. The cost is one extra round-..."
  },
  "matched_failure_symptoms": [
    "SCHEMA_DRIFT_OR_COERCION_CRASH"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "e4b337af8faea4f24a950d63957119ef37db5d0828281ff138a435590bb5ef27",
    "verified_classes": [
      "SchemaDriftError",
      "UnversionedObservationError",
      "ToolManifest",
      "PinnedRegistry",
      "ProvenancedMemory"
    ],
    "verified_functions": [
      "hash",
      "pin",
      "dispatch",
      "record",
      "invalidate_deprecated"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SchemaDriftError",
      "UnversionedObservationError"
    ],
    "sample_fail_closed_invariants": [
      "observation written without (tool, schema_hash) provenance; cannot be invalidated on future schema deprecation"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
