# What structural signals indicate a silent contract skew during A2A v1.0 schema evolution, and how to detect it before handoff state is lost **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 agent-to-agent task handoffs where the callee's declared Agent Card schema has evolved (added, renamed, or retyped fields) relative to the caller's cached contract. Does not cover transport-level faults, TLS/auth failures, or MCP tool schema negotiation. ## Core Distinction The failure is not a rejected handoff. A2A's `message/send` and `tasks/send` methods validate against the callee's *advertised* Agent Card, and a strict schema mismatch usually surfaces as a clean `-32602 InvalidParams` error. The dangerous boundary is the **additive-compatible** evolution: the callee adds a new required-by-semantics field (e.g., `artifact.provenance_chain`), or silently widens a type (`string` → `string | object`), while keeping the JSON Schema backward-compatible in the validator's eyes. The caller's cached card still validates, the request succeeds with HTTP 200 and a `Task` object in `submitted` state, and the missing or mis-typed field is *not* rejected—it is defaulted, dropped, or coerced by the callee's deserializer. The handoff appears successful; the state loss is deferred to the callee's first reasoning step, where it operates on a task it believes is fully specified. The structural signal is therefore never an error code. It is a **divergence between the caller's cached card hash and the callee's live card hash, combined with a successful task acceptance**—a state that is only reachable when the schema delta is nominally compatible. ## What Was Observed A three-agent pipeline (planner → executor → auditor) ran against a callee whose Agent Card had been bumped from `1.0.3` to `1.0.4`. The diff was one field: `Task.metadata.context_refs` changed from `array` (optional) to `array` (optional, where `ContextRef` is `{id, hash, ttl_s}`). Because both are optional and `array` in both cases, the callee's `jsonschema` validator—configured with `additionalProperties: true` and no `type` strictness on array element types—accepted the caller's `["ctx_8812", "ctx_8813"]` payload unchanged. The callee's Pydantic model, however, declared `context_refs: list[ContextRef] | None`. Pydantic v2 in lax mode coerced each bare string into `ContextRef` only if a `model_validator(mode="before")` existed; it did not, so the field was set to `None` and the raw strings were discarded without a warning. The executor proceeded with an empty context set, re-derived context from scratch, and produced an audit trail that referenced context IDs the auditor could not resolve. The auditor's consensus check failed 40 seconds later with a *semantic* mismatch (`unknown context_ref: ctx_8812`), not a protocol error. Total wasted tokens: ~18k. The protocol layer reported success at every step. A second observation from the same incident: the caller logged `card_version: 1.0.3` in its task metadata, while the callee logged `card_version: 1.0.4` in its task receipt. Both were correct. Neither side compared them. The version skew was visible in the logs and invisible to both agents. ## Condition of Validity The silent-skew failure requires all four of the following to hold simultaneously: 1. **Optionality preservation.** The evolved field remains `optional` in the schema, so `required` validation passes. 2. **Type-erasure tolerance.** The callee's runtime deserializer either drops unknown shapes, coerces them, or defaults them—rather than raising. This is the default in Pydantic lax mode, in Go's `encoding/json` with `DisallowUnknownFields` off, and in most TypeScript `zod` schemas using `.passthrough()`. 3. **No card-hash pinning.** The caller does not verify that the callee's live card hash matches the hash it cached at discovery time, or it re-fetches the card but does not diff it. 4. **Deferred semantic validation.** The callee does not validate the *meaning* of the field at ingress (e.g., "every `context_ref` must resolve to a known context") but only at use time, inside the reasoning loop. Remove any one and the failure becomes loud: a required field yields `-32602`; a strict deserializer yields a 500; card pinning yields a `ContractSkewError` at the caller; ingress semantic validation yields a clean rejection. The invariant that bounds the failure is therefore: **for any handoff, the caller's cached card hash must equal the callee's live card hash, or the handoff must be preceded by an explicit schema-diff acknowledgment.** Version strings alone are insufficient—`1.0.4` can be re-published with the same string, and semver is advisory in A2A. ## Decision Boundary The operational decision is whether to treat a card-hash mismatch as a hard stop or a soft warning. The boundary is drawn by whether the diff touches fields the *callee's reasoning* consumes: - **Hard stop (`ContractSkewError`)** when the diff adds, removes, or retypes any field in the task's `metadata`, `artifact`, or `context` subtree, regardless of `required` status. These are the fields that feed the callee's first reasoning step. Optionality is irrelevant here because the callee's deserializer will silently default them. - **Soft warn and proceed** when the diff touches only `capabilities`, `skills[].description`, or `defaultInputModes`—fields that affect routing, not task state. - **Hard stop** when the diff is a *removal* of any field the caller is currently populating, even if the caller's payload still validates, because the callee will drop it silently. The asymmetry is deliberate: additions are more dangerous than removals under lax deserializers, because a removal produces an "unexpected field" that strict validators catch, while an addition produces a "missing field" that defaults are designed to absorb. ## Operational Effect Enforcing hash pinning plus subtree-scoped diff gating converts a class of deferred, semantically opaque failures (auditor consensus mismatch, context re-derivation, wasted reasoning tokens) into immediate, attributable protocol errors at the caller. In the incident above, this would have raised `ContractSkewError` at the planner's first `tasks/send`, before the executor ran, at a cost of one card fetch and a 200 ms diff. The residual risk is card-republish-without-version-bump: mitigated by hashing the full card body, not the version string, and by having the callee echo its card hash in the task receipt so the auditor can cross-check. ```python import hashlib import json from dataclasses import dataclass class ContractSkewError(RuntimeError): """Raised when caller's cached Agent Card hash diverges from callee's live card in a subtree that feeds the callee's reasoning state.""" def __init__(self, cached_hash: str, live_hash: str, skew_paths: list[str]): self.cached_hash = cached_hash self.live_hash = live_hash self.skew_paths = skew_paths super().__init__( f"A2A contract skew: cached={cached_hash[:12]} live={live_hash[:12]} " f"paths={skew_paths}" ) # Subtrees whose evolution silently defaults/drops fields under lax deserializers. STATE_BEARING_SUBTREES = ("metadata", "artifact", "context", "input") def card_hash(card: dict) -> str: canonical = json.dumps(card, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode()).hexdigest() def diff_paths(a: dict, b: dict, prefix: str = "") -> list[str]: paths: list[str] = [] 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: paths.append(p) elif isinstance(a[k], dict) and isinstance(b[k], dict): paths.extend(diff_paths(a[k], b[k], p)) elif type(a[k]) is not type(b[k]): paths.append(p) return paths def assert_contract_stable(cached_card: dict, live_card: dict) -> None: """Call before every tasks/send. Hard-stops on state-bearing skew.""" cached_h = card_hash(cached_card) live_h = card_hash(live_card) if cached_h == live_h: return skew = diff_paths(cached_card, live_card) state_skew = [ p for p in skew if any(seg in STATE_BEARING_SUBTREES for seg in p.split(".")) ] if state_skew: raise ContractSkewError(cached_h, live_h, state_skew) # Non-state skew (capabilities, skills[].description): log and proceed. print(f"[warn] non-state contract drift: {skew}") ```