# Which invariants prevent cross-vendor Agent Card capability drift from silently corrupting delegated task state in A2A v1.0 **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 task delegation where a delegating agent (client) resolves a remote Agent Card, negotiates a skill/capability, and hands off a multi-turn task to a remote executor across organizational boundaries. Does not address single-vendor intra-pod agent meshes that share a registry, nor synchronous request/response RPC that completes within one turn. ## Core Distinction The dangerous failure is not "the remote agent is unreachable" — that surfaces as a clean transport error. The dangerous failure is **capability drift under a stable identity**: the remote Agent Card at `/.well-known/agent.json` advertises a skill contract, the client caches and trusts it, but the *executing* agent behind that card has been redeployed with a semantically narrower skill (same skill `id`, changed `inputSchema` constraints, changed `outputSchema` optionality, or a silently dropped `streaming`/`pushNotifications` capability). Because the card's `id` and `name` are unchanged, naive client-side equality checks pass, and the task is delegated against a contract the executor no longer honors. The result is not a failed handoff — it is a *partially honored* handoff: the task is accepted (`submitted` → `working`), then the executor produces output that violates the schema the client validated against, and the client's downstream state machine ingests malformed artifacts as if valid. The distinction that matters: **identity stability ≠ contract stability.** A2A v1.0 gives you a stable `AgentCard.name`/`id` and a `version` string, but the spec does not mandate that `version` change when a *skill-level* schema changes. Vendors bump the top-level card version on breaking platform changes, not on tightening an `inputSchema` `required` array. So drift is invisible to version-pinned clients. ## What Was Observed A client orchestrator (`planner-agent`, vendor A) delegated a structured "extract-and-summarize" task to `doc-processor`, vendor B, resolved via Agent Card at first contact and cached for a 24h TTL. - **T0 (cache fill):** Card advertised skill `extract_summary` v1 with `outputSchema` where `entities` was `required` and `confidence` was `required`, both typed `array`/`number`. Client validated this and built its downstream merger expecting `entities` present on every artifact. - **T+9h (silent redeploy, vendor B):** `doc-processor` rolled a new executor. Same `id`, same `name`, same `version: "1.4.0"`, but `entities` became `required: false` (empty docs now yield `entities: []` omitted entirely to save tokens) and `confidence` was renamed internally to `score` in a serialization shim that *sometimes* mapped back to `confidence` and sometimes didn't, depending on whether the extraction path hit the fallback model. - **T+11h (first corrupted delegation):** Client sent a task; executor returned `completed` with an artifact lacking `entities`. Client's `TaskState` transitioned to `completed`, merger attempted `artifact["entities"]` → `KeyError`, caught by a broad handler that substituted `[]`, and the merged summary shipped with silently empty entity lists for 340 documents before a downstream consumer noticed. - **Detection lag:** ~2.5 hours of wall-clock, 340 corrupted artifacts, because *every individual task returned `completed` with HTTP 200 and a schema-plausible (but not schema-valid) body.* The tell was that `confidence` appeared on exactly the documents where the fallback model fired, and was absent otherwise — a bimodal output distribution across the same skill, same card, same version. No transport error, no `failed` task state, no version bump. ## Condition of Validity The invariant that bounds this failure is: **a delegated task's artifact must be validated against the schema captured at delegation time, not the schema currently advertised, and the executor must be obligated to reject or flag a task whose contract it can no longer honor.** Concretely, the guardrail requires three things to hold simultaneously: 1. **Contract pinning at handoff.** When the client transitions a task to `submitted`, it must snapshot the resolved `AgentSkill` object (full `inputSchema` + `outputSchema` + capability flags) into the task record. Every artifact returned for that `taskId` is validated against the *snapshot*, not a re-fetched card. Re-fetching mid-task is the bug, not the fix — a mid-task card change means the executor and client are now in contract disagreement and the task must be failed, not silently renegotiated. 2. **Executor-side contract assertion.** The executor, before transitioning to `working`, must assert that its *current* compiled skill schema is byte-equal (or semantically equal under a declared equivalence) to the schema hash the client sent in the task's `metadata.contractHash`. If not, it must transition the task to `failed` with a `contract_mismatch` reason rather than proceeding under a narrower contract. The spec permits this via task `metadata`; it does not enforce it, which is exactly the gap. 3. **Artifact completeness gate.** The client must treat a `completed` task with a schema-invalid artifact as a *task failure*, not a partial success. The `completed` state is a claim by the executor; the client is the sole authority on whether that claim satisfies the pinned contract. Conflating "executor said completed" with "artifact is valid" is the state-corruption vector. The invariant is **not** "poll the card frequently" — polling makes the window smaller but never closes it, because the redeploy can land between poll and delegation. The invariant is **contract immutability per task lifetime plus executor-side self-assertion**. ## Decision Boundary The boundary between "safe to proceed" and "must fail the task" is the moment of *schema hash mismatch at the executor*, evaluated before any work is done: - **Hash match (or declared-equivalent):** proceed to `working`. Client validates artifacts against the pinned snapshot. - **Hash mismatch:** the executor must fail fast with `contract_mismatch`. The client, on receiving this, must invalidate its cached card *for that skill only* (not the whole card — other skills may be intact), re-resolve, and re-delegate as a *new* task with a new `taskId`. It must never resume the old task under the new contract, because the old task's partial artifacts were produced under a contract that no longer exists and cannot be merged with new-contract artifacts without an explicit reconciliation step. - **No hash sent (legacy client):** executor proceeds under current contract but must annotate the artifact with `contractDrift: true` and its current schema hash, so the client's completeness gate can decide. This is the degraded-but-honest path. The boundary is sharp: the decision is made **once, at task admission, by the executor, on a hash the client supplied.** It is not made by the client re-reading the card, and it is not made lazily when an artifact fails validation — by then work has been done and state may already be merged. ## Operational Effect Enforcing this invariant converts a silent, hours-long, 340-artifact corruption into a single, immediate, attributable `failed` task with a machine-readable reason, at the cost of: - A `contractHash` field in task `metadata` (client-computed, executor-verified). - Executor-side schema compilation pinned to a build artifact the card is generated *from*, so the hash the executor computes matches what it advertises (this is the hard part — card and executor must be generated from one source of truth, or drift is reintroduced at the executor). - Client-side artifact validation against the snapshot, with `completed`-but-invalid treated as `failed`. The residual risk that remains even with the invariant: a *semantic* drift that preserves schema shape (e.g., `entities` still `required` but now always `[]` because the extractor was downgraded). No schema hash catches that. That class requires output-distribution monitoring (bimodal `confidence` presence, empty-array rate) — a statistical guardrail layered on top of the structural one. The structural invariant bounds the *schema* drift; it does not bound *quality* drift, and conflating the two is how teams convince themselves they are safe when they are only schema-safe. ## Operational Record ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class ContractDriftError(RuntimeError): """Raised when an executor's live skill schema no longer matches the contract hash pinned by the client at task admission.""" pass class ArtifactValidationError(RuntimeError): """Raised when a 'completed' task's artifact violates the pinned schema. This is a task failure, not a partial success.""" pass def _schema_hash(schema: dict[str, Any]) -> str: # Canonicalize: sort keys, drop whitespace, stable separators. canonical = json.dumps(schema, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() @dataclass class PinnedContract: skill_id: str input_schema: dict[str, Any] output_schema: dict[str, Any] contract_hash: str = field(init=False) def __post_init__(self) -> None: self.contract_hash = _schema_hash( {"input": self.input_schema, "output": self.output_schema} ) @dataclass class RemoteSkill: """What the executor currently compiles and runs.""" skill_id: str input_schema: dict[str, Any] output_schema: dict[str, Any] def live_contract_hash(self) -> str: return _schema_hash( {"input": self.input_schema, "output": self.output_schema} ) def admit_task(pinned: PinnedContract, executor: RemoteSkill) -> None: """Executor-side admission gate. Must run BEFORE transition to 'working'. Fails fast on any contract drift; never proceeds under a narrower contract.""" if executor.skill_id != pinned.skill_id: raise ContractDriftError( f"skill id mismatch: pinned={pinned.skill_id} live={executor.skill_id}" ) if executor.live_contract_hash() != pinned.contract_hash: raise ContractDriftError( "contract_mismatch: executor schema drifted from pinned contract " f"for skill {pinned.skill_id}; task must fail, not renegotiate" ) def validate_artifact(pinned: PinnedContract, artifact: dict[str, Any]) -> None: """Client-side completeness gate. 'completed' is a claim; validity is ours.""" required = pinned.output_schema.get("required", []) missing = [k for k in required if k not in artifact] if missing: raise ArtifactValidationError( f"artifact missing required fields {missing} for " f"skill {pinned.skill_id}; treating task as failed" ) # --- failure trace: the T+11h corruption, now caught at admission --- pinned = PinnedContract( skill_id="extract_summary", input_schema={"type": "object", "required": ["doc"]}, output_schema={ "type": "object", "required": ["entities", "confidence"], }, ) # Vendor B redeployed: entities no longer required, confidence renamed. drifted = RemoteSkill( skill_id="extract_summary", input_schema={"type": "object", "required": ["doc"]}, output_schema={"type": "object", "required": []}, ) try: admit_task(pinned, drifted) except ContractDriftError as e: # Correct behavior: task fails at admission, zero artifacts produced, # client invalidates cached card for this skill and re-resolves. print(f"task failed fast: {e}") # Had admission been skipped, the completeness gate would still catch it: try: validate_artifact(pinned, {"confidence": 0.91}) except ArtifactValidationError as e: print(f"artifact rejected: {e}") ```