# How does an instance detect a terminal-state divergence between its local task ledger and a peer's advertised `TaskState` when A2A v1.0 `tasks/get` returns `completed` but the peer's agent card still lists the capability as `input-required`-gated? **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 clients that cache agent cards for capability gating and reconcile task lifecycle state via `tasks/get` polling or `tasks/sendSubscribe` SSE streams. Does not apply to single-vendor deployments where card and task state share one authoritative store. ## Core Distinction The failure is not "the peer returned the wrong state." It is that **the agent card and the task state machine are two independently versioned artifacts served by two independently deployed subsystems**, and A2A v1.0 does not mandate that a card's `capabilities` block be invalidated when a task transitions to a terminal state. A remote agent can legitimately report `TaskState.completed` for a task while its own published card continues to advertise `input-required` as a required precondition for that capability, because the card describes *capability shape*, not *task instance state*. Local orchestrators that conflate the two — treating the card as a live capability oracle — will either refuse to accept the completion (deadlock) or synthesize a phantom follow-up turn (state divergence). The boundary condition is: **a terminal `TaskState` from `tasks/get` contradicts a non-terminal capability precondition in the cached card, and no spec-mandated field tells you which wins.** ## What Was Observed A cross-vendor conformance harness ran a 3-hop chain: orchestrator A (vendor X) → worker B (vendor Y) → auditor C (vendor Z). B's card, fetched once at session start, advertised: ``` capabilities: { "streaming": true, "pushNotifications": false } skills: [{ id: "summarize", inputModes: ["text"], outputModes: ["text"] }] defaultInputModes: ["text"] defaultOutputModes: ["text"] ``` B's `tasks/send` for a summarize task returned `state: "input-required"` with a `metadata.clarification` field asking for a max-length. A relayed the clarification, B resumed, and `tasks/get` returned `state: "completed"` with the artifact. So far conformant. The divergence appeared on the *second* task to B in the same session. A's cache still held B's card. A re-issued `tasks/send` for the same skill. B returned `state: "input-required"` again — but this time the clarification was a *different* field (a `metadata.tone` selector) that was not present in the first task's clarification schema. A's orchestrator, which had memoized the first clarification's schema against the skill id, rejected the response as schema-violating and re-polled `tasks/get` on the still-open task. `tasks/get` kept returning `input-required` with the new clarification. A deadlocked: its local task ledger marked the task `failed` (schema mismatch), while B's ledger held it `input-required` indefinitely. C, the auditor, saw A's `failed` and B's `input-required` for the same `taskId` and raised a consensus conflict. Root cause: B's card advertised `input-required` as a *capability precondition* for `summarize`, but the card did not enumerate the clarification *schema* per invocation. A's orchestrator had promoted a per-task observation (clarification schema from task 1) into a per-capability invariant (clarification schema for `summarize`), because A2A v1.0 gives no field to distinguish them. The card is static; the clarification schema is dynamic; the spec's `TaskState` enum does not carry a schema-version discriminator. ## Condition of Validity The divergence is *reachable* only when all of the following hold: 1. The peer's card is cached beyond a single task (session-scoped card caching, the common optimization). 2. The peer's skill emits `input-required` with a clarification payload whose schema is not fixed by the card (i.e., the card's `skills[].inputModes` does not fully constrain the clarification shape — which is true for any skill using `metadata` for free-form clarification). 3. The local orchestrator performs schema validation on clarification payloads and treats validation failure as terminal. 4. No out-of-band card-refresh signal exists (A2A v1.0 defines no `cardVersion` in the task response, and `tasks/get` does not echo the card revision the peer used). If (1) is absent (card fetched per task), the divergence collapses to a latency cost. If (3) is absent (orchestrator accepts any clarification), the divergence manifests as silent misrouting rather than deadlock — arguably worse, because the phantom turn is accepted and the task proceeds on a stale schema assumption. ## Decision Boundary The invariant a conformant orchestrator must enforce is: **card-derived capability constraints are necessary but not sufficient; per-task `input-required` payloads must be validated against the task's own declared schema, not against a memoized card projection.** Concretely: - Treat `skills[].inputModes` / `outputModes` as *transport-level* constraints (what MIME types the skill accepts), never as *semantic* constraints on clarification fields. - On every `input-required`, re-read the clarification payload's own schema (if present in `metadata`) or accept it as opaque and route it to the human/planner, but do **not** compare it to a prior task's clarification. - If the orchestrator *must* cache clarification schemas for efficiency, key the cache on `(skillId, taskId)`, not `skillId`, and evict on terminal state. - When `tasks/get` returns a terminal state (`completed`, `failed`, `canceled`) while the cached card still lists the capability as `input-required`-gated, the terminal state wins for that `taskId`; the card is not invalidated, and the next task to the same skill re-enters the `input-required` gate fresh. The boundary: the moment an orchestrator promotes a per-task observation to a per-capability invariant, it has crossed from conformance into a private protocol the peer never agreed to. ## Operational Effect In the harness, the deadlock cost 4m12s of wall-clock before the session timeout fired, and the auditor's conflict forced a full replay of the chain. The replay succeeded only because the harness happened to re-fetch B's card between attempts — an accident of the test driver, not a designed guardrail. In production, the same pattern produces: - **Stuck tasks** on the peer (B holds `input-required` until its own TTL), consuming peer-side task slots. - **False `failed`** on the orchestrator, which then triggers retry storms against a peer that is correctly waiting for input. - **Auditor divergence** when the auditor's card cache differs from the orchestrator's, yielding conflicting consensus on the same `taskId`. The guardrail is a card-revision pin: attach the card's `version` (if present) or a content hash to every task at `tasks/send`, and on any `input-required` whose clarification schema is not implied by the pinned card, force a card re-fetch before re-issuing. If the re-fetched card still does not constrain the clarification, the orchestrator must escalate to the planner rather than fail the task — because the spec permits dynamic clarification, and a schema-strict orchestrator is the non-conformant party. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any, Optional class CardTaskStateDivergence(RuntimeError): """Raised when a task's terminal state contradicts a cached card's capability gate in a way the orchestrator cannot resolve without a card re-fetch or planner escalation.""" @dataclass class AgentCard: raw: dict version: str def content_hash(self) -> str: return hashlib.sha256( json.dumps(self.raw, sort_keys=True).encode() ).hexdigest() @dataclass class TaskRecord: task_id: str skill_id: str pinned_card_hash: str state: str clarification_schema: Optional[dict] = None clarification_cache_key: Optional[str] = None @dataclass class Orchestrator: card_cache: dict = field(default_factory=dict) # skillId -> AgentCard clarification_cache: dict = field(default_factory=dict) # cacheKey -> schema ledger: dict = field(default_factory=dict) # taskId -> TaskRecord def _cache_key(self, skill_id: str, task_id: str) -> str: # Invariant: clarify schema is per-task, never per-skill. return f"{skill_id}::{task_id}" def on_input_required( self, task: TaskRecord, card: AgentCard, clarification: dict, ) -> dict: key = self._cache_key(task.skill_id, task.task_id) task.clarification_cache_key = key task.clarification_schema = clarification.get("schema") # A2A v1.0: card does not constrain clarification schema. # If the orchestrator has a memoized schema for this skill (not this task), # it MUST NOT compare. Detect the violation explicitly. skill_memo = self.clarification_cache.get(task.skill_id) if skill_memo is not None and skill_memo != task.clarification_schema: raise CardTaskStateDivergence( f"skill-scoped clarification memo for {task.skill_id!r} " f"diverges from task {task.task_id!r} clarification; " f"re-fetch card and escalate to planner, do not fail task" ) self.clarification_cache[key] = task.clarification_schema return clarification def on_tasks_get(self, task: TaskRecord, card: AgentCard, response: dict) -> str: state = response["state"] if state in ("completed", "failed", "canceled"): # Terminal state wins for this taskId; card is NOT invalidated. task.state = state self.clarification_cache.pop(task.clarification_cache_key or "", None) return state if state == "input-required": # Card gate must still be satisfiable; if the pinned card hash # no longer matches the live card, force re-fetch before accepting. if card.content_hash() != task.pinned_card_hash: raise CardTaskStateDivergence( f"task {task.task_id!r} still input-required but card hash " f"drifted from {task.pinned_card_hash[:12]} to " f"{card.content_hash()[:12]}; re-pin card before re-issuing" ) return state ```