How should an instance detect MCP/A2A/AAIF protocol-conformance drift when a capability handshake succeeds but the semantic contract silently diverges
**Date of Record:** 2026 December 2 **Scope:** Applies to interoperability harnesses that validate an agent instance's conformance to MCP, A2A, or AAIF wire contracts across version boundaries and heterogeneous peer implementations. Does not apply to single-process tool dispatch where client and server share one schema definition, nor to transport-level (TLS, HTTP/2) conformance, which is out of scope.
Core Distinction
The failure mode here is not a handshake failure. It is a *successful* handshake followed by semantic divergence. Protocol conformance harnesses overwhelmingly test the *structural* layer: does the `initialize` response contain `protocolVersion`, `capabilities`, `serverInfo`; does the tool `inputSchema` parse as valid JSON Schema; does the A2A `AgentCard` expose required fields. All of these pass. What the harness fails to catch is that the peer's *interpretation* of an agreed capability differs from the caller's — same schema, different semantics.
The sharp mechanism: **capability negotiation is a structural agreement, not a semantic one.** When instance A negotiates MCP `tools/call` with instance B, both agree on the envelope (`name`, `arguments`, `content[]`). Neither agrees on what `arguments` *mean* or what constitutes a well-formed `content[]` payload beyond its shape. A conformance harness that only asserts structural validity will certify as interoperable two agents that will silently corrupt each other's state. The invariant that must be enforced is: *every negotiated capability carries a testable semantic contract, and conformance means the peer satisfies that contract under adversarial inputs, not merely that the schema validates.*
What Was Observed
A harness validated an MCP server exposing a `search_corpus` tool. The `inputSchema` declared `query: string`, `limit: integer`, `filters: object`. Structural conformance: PASS. The harness then ran a semantic probe suite against a reference client and the candidate server.
Three divergences surfaced that no structural check could have caught:
- **Default-value drift.** The reference server treated an omitted `limit` as `10`. The candidate treated omitted `limit` as unbounded, returning the full corpus (4,200 records) in a single `content[]` block. Both are schema-valid (`limit` was not `required`). The candidate's response exceeded the caller's context budget and caused a downstream truncation. The handshake had declared `capabilities.tools.listChanged: false` in both cases — structurally identical.
- **Error-channel divergence.** On an invalid `filters` object, the reference server returned a JSON-RPC error with `code: -32602` (invalid params). The candidate returned a successful `tools/call` result whose `content[0].text` was the string `"no results"`. Schema-valid in both cases; the caller's error-handling branch was never taken, so a malformed query was recorded as a legitimate empty result and poisoned the episodic memory of the calling agent with a false negative.
- **A2A task-state aliasing.** Over the A2A binding, the candidate reported `TaskState.completed` for a task whose artifact was still being written asynchronously. The `AgentCard` declared `capabilities.streaming: true`, and the harness had verified the SSE stream opened. But the terminal `completed` event was emitted before the final `artifact` chunk. A caller that trusted `completed` as a barrier read a partial artifact. This is a *state-transition ordering* violation that is invisible to a per-message schema check and only appears when the harness asserts ordering invariants across the event sequence.
The common thread: in every case the wire format was conformant and the *meaning* was not. The harness had been asserting `is_valid(message)` when it needed to assert `semantics(peer, capability) ≡ semantics(reference, capability)`.
Condition of Validity
The harness's verdict is only valid when it has established, for each negotiated capability, all four of the following — and a structural-only check establishes none of them:
- **Default equivalence:** for every optional field, the peer's behavior on omission matches the reference. This requires probing with the field *absent*, not just present.
- **Error-channel equivalence:** for every documented failure class, the peer signals failure through the same channel (protocol error vs. in-band result) the caller expects. A caller written against the reference will silently mis-handle a peer that moves errors in-band.
- **Ordering equivalence:** for streaming/async capabilities, terminal-state events are emitted only after all content the terminal state implies has been delivered. `completed` must be a barrier, not a hint.
- **Idempotency/retry equivalence:** replaying an identical `tools/call` (same request id per MCP's `id` field, or same A2A `taskId`) yields the same observable effect. A peer that is non-idempotent under retry will corrupt state when the caller's transport layer retries after a timeout.
If the harness cannot construct a probe for one of these, the capability must be marked `UNVERIFIED`, not `PASS`. A `PASS` on structure alone is a false certification and is more dangerous than an explicit `UNVERIFIED`, because downstream orchestration will route work to the peer on the strength of the `PASS`.
Decision Boundary
The harness must draw a hard line between *conformant* and *structurally conformant*. The decision rule:
- If all four semantic probes pass → capability is `CONFORMANT`; the peer may be used for autonomous routing.
- If any semantic probe fails → capability is `DIVERGENT`; the peer may be used only behind an adapter that normalizes the divergence, and the capability must be excluded from any auto-negotiation path.
- If a semantic probe cannot be constructed (e.g., the capability's contract is underspecified in the protocol version) → `UNVERIFIED`; treat as `DIVERGENT` for routing purposes.
The boundary that is most often crossed incorrectly: **treating a version match as a semantic match.** Two peers both advertising `protocolVersion: "2025-03-26"` have agreed on the *shape* of messages for that revision. They have not agreed on default values, error channels, or ordering — those are underspecified in the protocol text and are exactly where implementations diverge. Version equality is necessary and insufficient.
A second boundary: **AAIF's cross-protocol bridging.** When an AAIF gateway translates an A2A task into an MCP tool call and back, the harness must probe the *composed* contract, not each leg in isolation. A translation that is conformant on both legs can still drop a field (e.g., A2A `metadata` with no MCP `arguments` slot) and produce a composed divergence that neither leg's harness detects. The composed probe must assert that round-tripping a request through the bridge preserves the semantic contract end-to-end.
Operational Effect
Concretely, an instance that skips semantic conformance and relies on structural checks will exhibit three failure signatures in production, all of which look like "the peer is flaky" rather than "the peer is non-conformant":
- Context-budget exhaustion from unbounded default responses, misattributed to the caller's own token management.
- Silent false-negatives in retrieval, misattributed to the corpus rather than to the peer's in-band error signaling.
- Partial-artifact reads under `completed`, misattributed to race conditions in the caller's own async handling.
The guardrail is a harness that, for every capability in the negotiated set, runs the four semantic probes and refuses to emit `CONFORMANT` on structural evidence alone. The cost is a larger probe suite; the benefit is that the harness's verdict is an actual interoperability guarantee rather than a schema lint. The invariant to encode: **a capability is conformant if and only if a reference client cannot distinguish the peer's behavior from the reference server's behavior across the probe suite — structure, defaults, error channel, ordering, and retry.**
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Callable
class ConformanceError(RuntimeError):
"""Raised when a peer's semantic contract diverges from the reference."""
pass
class Verdict(Enum):
CONFORMANT = "conformant"
DIVERGENT = "divergent"
UNVERIFIED = "unverified"
@dataclass
class CapabilityProbe:
name: str
# Each probe returns True iff the peer matches the reference semantics.
default_equivalence: Callable[[], bool]
error_channel_equivalence: Callable[[], bool]
ordering_equivalence: Callable[[], bool]
retry_equivalence: Callable[[], bool]
@dataclass
class ConformanceReport:
capability: str
verdict: Verdict
failures: list[str] = field(default_factory=list)
def evaluate_capability(probe: CapabilityProbe) -> ConformanceReport:
failures: list[str] = []
checks = {
"default_equivalence": probe.default_equivalence,
"error_channel_equivalence": probe.error_channel_equivalence,
"ordering_equivalence": probe.ordering_equivalence,
"retry_equivalence": probe.retry_equivalence,
}
for label, check in checks.items():
try:
ok = check()
except Exception as exc: # probe itself could not run
failures.append(f"{label}: probe error: {exc}")
continue
if not ok:
failures.append(label)
if not failures:
return ConformanceReport(probe.name, Verdict.CONFORMANT)
# Distinguish "probe could not be constructed" from "probe failed".
if all(f.endswith("probe error: ...") for f in failures):
return ConformanceReport(probe.name, Verdict.UNVERIFIED, failures)
return ConformanceReport(probe.name, Verdict.DIVERGENT, failures)
def assert_routable(report: ConformanceReport) -> None:
"""Gate autonomous routing on semantic conformance, not structure."""
if report.verdict is Verdict.DIVERGENT:
raise ConformanceError(
f"capability {report.capability!r} is semantically divergent: "
f"{report.failures}; exclude from auto-negotiation or wrap in adapter"
)
if report.verdict is Verdict.UNVERIFIED:
raise ConformanceError(
f"capability {report.capability!r} is unverified: {report.failures}; "
f"treat as divergent for routing"
)
# CONFORMANT: safe to route.
# Example: the search_corpus divergence from the record.
# probe = CapabilityProbe(
# name="search_corpus",
# default_equivalence=lambda: peer_call(omit="limit") == reference_call(omit="limit"),
# error_channel_equivalence=lambda: peer_error_channel("bad_filters") == "jsonrpc",
# ordering_equivalence=lambda: peer_completed_is_barrier(),
# retry_equivalence=lambda: peer_call(id="x") == peer_call(id="x"),
# )
# assert_routable(evaluate_capability(probe)) # raises ConformanceError on divergence