# Under what conditions must an instance reject a peer's A2A Agent Card despite a schema-valid signature, and how does task-state divergence follow **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 client/orchestrator instances that discover peer Agent Cards, verify their signatures, and drive a task through the declared lifecycle state machine (`submitted → working → input-required → completed/failed/canceled`). Does not apply to single-agent tool invocation, MCP transport negotiation, or unsigned discovery over a trusted in-process registry. ## Core Distinction A2A Agent Card verification and task-state conformance are two independent trust decisions that operators routinely collapse into one. The card is a *capability and identity claim* signed by the peer; the task lifecycle is a *state transition contract* the peer promises to honor per task. A card can be cryptographically valid, schema-valid, and still be **semantically inadmissible** for a specific task because its declared `capabilities` and `defaultInputModes`/`defaultOutputModes` do not cover the state transitions the caller will require. Conversely, a perfectly admissible card tells you nothing about whether the peer's runtime will actually emit the `input-required` state when it stalls rather than silently hanging in `working`. The non-obvious boundary: **signature validity is necessary but not sufficient for admission, and admission is necessary but not sufficient for lifecycle conformance.** The failure mode is that most implementations check the first and assume the second. ## What Was Observed An orchestrator instance (`O`) discovers peer `P` via `GET /.well-known/agent.json`. The returned Agent Card: - parses against the A2A v1.0 JSON schema, - carries a valid JWS signature over the canonicalized card body, - declares `capabilities.streaming: true`, `capabilities.pushNotifications: true`, - declares `defaultInputModes: ["text/plain"]`, `defaultOutputModes: ["text/plain"]`, - declares `skills: [{id: "summarize", inputModes: ["text/plain"], outputModes: ["text/plain"]}]`. `O` admits the card and dispatches a `tasks/send` with a `text/plain` message. `P` responds `state: "working"`. `O` then attempts `tasks/sendSubscribe` (SSE) because the card advertised streaming. `P` returns HTTP 501 — streaming is declared but not implemented. `O` falls back to polling `tasks/get`. After 90 seconds `P` returns `state: "working"` again, with `status.timestamp` unchanged from the first poll. `O`'s task-level timeout fires at 120s and it marks the task `failed` locally. `P` later transitions the same task to `completed` and emits a push notification to a webhook `O` had registered — but `O` had already garbage-collected the task record, so the notification is dropped and `P` retains an orphaned completed task whose result is never delivered. The card was valid. The signature was valid. The task lifecycle diverged because **the card's `capabilities` block is a declaration of intent, not a probe of the running implementation**, and **the caller's local timeout is not a state in the peer's machine**. ## Condition of Validity The invariant that must hold for admission to be sound: > For every state transition `O` will require of `P` on task `T`, `P`'s card must declare the capability that gates that transition, **and** `O` must have observed at least one successful round-trip exercising that capability before relying on it for a long-running task. Concretely, admission of a card is valid only when: 1. **Capability coverage is closed under the task plan.** If `O`'s plan for `T` requires `input-required` handling, the card must declare the message modes needed to resume, and `O` must be prepared to supply them. A card declaring `defaultInputModes` that excludes the resume payload type is inadmissible for any task that may need clarification. 2. **Declared capabilities are treated as unverified until probed.** `capabilities.streaming: true` is a claim. The first `tasks/sendSubscribe` on any new peer is a *capability probe*, not a production call; its failure must downgrade the peer's effective capability set, not fail the task. 3. **State authority is explicit.** The peer is the sole authority on task state. `O`'s local timeout produces a *local* terminal marker (`timed_out`), which is not a state in the A2A machine and must not be conflated with `failed` or `canceled`. The peer may still be `working`. 4. **Push-notification registration is bound to task liveness, not to local GC.** If `O` deregisters or GCs a task while the peer holds it non-terminal, the peer's later terminal transition is undeliverable. ## Decision Boundary The boundary between "admit and proceed" and "reject or degrade" is drawn at three checks, evaluated in order: - **Card admissibility check (pre-dispatch).** Reject the card if the union of skill `inputModes`/`outputModes` does not cover the modes `O` will send and expects back for the planned task. This is a *static* rejection; it does not require a network probe. A card that is schema-valid and signature-valid but mode-incomplete is rejected with a distinct error class — not a generic "invalid card." - **Capability probe (first use per peer, per capability).** The first use of `streaming` or `pushNotifications` against a peer is a probe. Probe failure demotes the capability for that peer for the session and forces the fallback path (polling, or synchronous `tasks/send` with `blocking: true`). The task proceeds; the peer is not blacklisted, but the capability is marked unverified. - **Lifecycle divergence watch (during execution).** If two consecutive `tasks/get` polls return `state: "working"` with an unchanged `status.timestamp`, the peer is *stalled*, not progressing. This must trigger either an explicit `tasks/cancel` (moving the peer to `canceled`) or escalation to `input-required` handling — never a silent local `failed`. A local terminal marker on a non-terminal peer task is the divergence condition. The rule: **`O` may only mark a task terminal locally if it has either (a) received a terminal state from `P`, or (b) explicitly canceled and received confirmation.** Any other local terminal marker is a divergence and must be recorded as such, not as a task result. ## Operational Effect When the boundary is respected, three things change: 1. **Card rejection becomes specific and actionable.** Mode-incomplete cards are rejected at discovery with a machine-readable reason (`missing_output_mode: "application/json"`), so the orchestrator can either re-plan with a text-only skill or route to a different peer. The rejection is not a transport error and does not poison the peer's reputation for other skills. 2. **Capability demotion is session-scoped and reversible.** A failed streaming probe demotes `streaming` for that peer in that session; the next session re-probes. This prevents a single transient 501 from permanently degrading a peer, while preventing repeated 501s from wasting task budget. 3. **Stalled tasks are resolved by cancellation, not timeout.** On detecting a stalled `working` (unchanged timestamp across two polls), `O` issues `tasks/cancel` and waits for the peer's `canceled` confirmation before releasing the task record. If the peer does not confirm cancellation within the cancel timeout, `O` retains the task record in a `cancel_pending` limbo state and keeps the push-notification webhook registered, so a late `completed` from `P` is still delivered and reconciled. The task is never silently dropped. The residual risk: a peer that never confirms cancellation and never transitions leaves `O` with a `cancel_pending` record indefinitely. This is bounded by a hard retention horizon (e.g., 24h) after which the record is archived with an explicit `unreconciled` marker, not deleted — so the divergence is auditable rather than invisible. ```python import time from dataclasses import dataclass, field from enum import Enum from typing import Optional class CardInadmissibleError(RuntimeError): """Raised when a schema-valid, signature-valid Agent Card cannot cover the planned task.""" class LifecycleDivergenceError(RuntimeError): """Raised when local task state would become terminal while the peer is non-terminal.""" class TaskState(Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" # Local-only markers; never sent to or received from a peer. TIMED_OUT_LOCAL = "timed_out_local" CANCEL_PENDING = "cancel_pending" @dataclass class AgentCard: name: str default_input_modes: list[str] default_output_modes: list[str] skills: list[dict] capabilities: dict signature_valid: bool @dataclass class TaskRecord: task_id: str state: TaskState last_peer_timestamp: Optional[float] = None stalled_polls: int = 0 history: list[str] = field(default_factory=list) def admit_card(card: AgentCard, required_input: str, required_output: str) -> None: if not card.signature_valid: raise CardInadmissibleError(f"card for {card.name}: signature invalid") # Closed-under-plan check: the card must cover the modes we will actually use, # across both defaults and every skill we might route to. covered_in = set(card.default_input_modes) covered_out = set(card.default_output_modes) for skill in card.skills: covered_in.update(skill.get("inputModes", [])) covered_out.update(skill.get("outputModes", [])) if required_input not in covered_in: raise CardInadmissibleError( f"card for {card.name}: missing_input_mode {required_input!r}" ) if required_output not in covered_out: raise CardInadmissibleError( f"card for {card.name}: missing_output_mode {required_output!r}" ) # Capabilities are claims, not probes. Do not reject here; demote on probe failure. def probe_capability(card: AgentCard, capability: str, probe_result_ok: bool) -> bool: """First use of a declared capability is a probe. Returns effective availability.""" if not card.capabilities.get(capability, False): return False return probe_result_ok def observe_poll(record: TaskRecord, peer_state: TaskState, peer_timestamp: float) -> None: record.state = peer_state if peer_state == TaskState.WORKING: if record.last_peer_timestamp is not None and peer_timestamp == record.last_peer_timestamp: record.stalled_polls += 1 else: record.stalled_polls = 0 record.last_peer_timestamp = peer_timestamp else: record.stalled_polls = 0 record.last_peer_timestamp = peer_timestamp record.history.append(f"{peer_state.value}@{peer_timestamp}") def enforce_local_terminal(record: TaskRecord, local_reason: str) -> None: """Guardrail: local terminal markers require peer terminal state or confirmed cancel.""" if record.state in (TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED): return # peer already terminal; safe to mirror if record.state == TaskState.CANCEL_PENDING and local_reason == "cancel_confirmed": record.state = TaskState.CANCELED return raise LifecycleDivergenceError( f"task {record.task_id}: refusing local terminal {local_reason!r} " f"while peer state is {record.state.value!r} with " f"{record.stalled_polls} stalled poll(s); issue tasks/cancel and await confirmation" ) def drive_task(card: AgentCard, record: TaskRecord, required_input: str, required_output: str) -> None: admit_card(card, required_input, required_output) # Capability probe: streaming declared but 501 -> demote, fall back to polling. streaming_ok = probe_capability(card, "streaming", probe_result_ok=False) if not streaming_ok: record.history.append("streaming_demoted: fallback=poll") # Two identical-timestamp working polls => stalled; escalate to cancel. observe_poll(record, TaskState.WORKING, peer_timestamp=1000.0) observe_poll(record, TaskState.WORKING, peer_timestamp=1000.0) if record.stalled_polls >= 2: record.state = TaskState.CANCEL_PENDING record.history.append("stall_detected: cancel_requested") # A local timeout must NOT become a terminal marker on a non-terminal peer. try: enforce_local_terminal(record, local_reason="timeout") except LifecycleDivergenceError: # Correct behavior: retain record, keep webhook registered, await peer transition. record.history.append("timeout_suppressed: record_retained") return # If we reach here, the peer had already gone terminal; mirroring is safe. enforce_local_terminal(record, local_reason="mirror") ```