How should an instance detect and recover from Agent Card capability drift between A2A discovery and task dispatch

**Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 client agents that discover a remote agent via its Agent Card, cache or re-fetch that card, and then dispatch a `tasks/send` or `tasks/sendSubscribe` call expecting the capabilities and skills advertised at discovery time. Does not cover transport-level TLS failures, authentication rejection, or push-webhook delivery retries once a task is already accepted.

Core Distinction

The A2A v1.0 Agent Card is a *snapshot*, not a *contract*. Discovery (`GET /.well-known/agent.json`) and dispatch (`POST /a2a/v1/tasks/send`) are two separate HTTP transactions against a mutable remote. Between them the remote agent may redeploy, roll back, downgrade its model, drop a skill, or change its `capabilities.pushNotifications` flag. The protocol gives you no versioning token that binds the card you read to the task you send. The failure is not "the call returns 500." It is subtler: the task is *accepted* into a lifecycle state (`submitted` → `working`) under a schema the remote no longer honors, and the divergence only surfaces later — as a `TaskStatusUpdateEvent` with a `state` your client's state machine does not model, or as a push notification that never arrives because `pushNotifications` flipped to `false` after you registered a webhook.

The invariant that must hold: **every task your instance tracks must be bound to the exact capability surface (skills, push flag, input/output modes) that the remote acknowledged at `tasks/send` acceptance time — not the surface you discovered.** Discovery is a hint; acceptance is the only authoritative capability commitment.

What Was Observed

A client agent discovered an orchestrator card advertising `capabilities: {streaming: true, pushNotifications: true}` and a skill `research.summarize` with `inputModes: ["text/plain"]`. It cached the card for 300 seconds. At T+280s it dispatched a long-running `research.summarize` task with `pushNotification: {url: "https://client.example/hook", token: "..."}` and `acceptedOutputModes: ["text/markdown"]`. The remote returned `Task{ id, status: {state: "submitted"} }` — a 200, a valid task ID, no error.

The remote had actually redeployed at T+120s. The new build dropped `text/markdown` from `outputModes` (now `text/plain` only) and set `pushNotifications: false`. Because the client sent a push config to a server that no longer supports push, the server's schema validator *silently ignored the unknown field* rather than rejecting — a common lenient-deserialization behavior. The task ran, transitioned `working` → `completed`, and the result was written to the task store. But no webhook fired, and the client — which had no polling loop because it trusted `pushNotifications: true` — never learned the task finished. The task sat `completed` on the remote for 24 hours until a TTL reaper deleted it. The client's own state machine left the task in `working` indefinitely, and its "in-flight tasks" gauge never decremented.

A second observed variant: the remote's state machine emitted `TaskStatusUpdateEvent{state: "input-required"}` with an `inputSchema` referencing a skill the client's cached card said required `text/plain` but the live card said required `application/json`. The client's continuation handler tried to satisfy it with text, got a `-32602 invalid params` on `tasks/send` (resume), and entered a retry loop bounded only by its token budget.

Condition of Validity

This failure mode is *live* — i.e., the divergence is observable and harmful — exactly when all of the following hold:

  1. The client caches or holds the Agent Card across more than one dispatch cycle (any TTL > 0, or any long-lived session).
  2. The remote's capability surface is mutable without a card-level version bump that the client checks (A2A v1.0 cards carry no mandatory `version` binding to task acceptance; a `protocolVersion` field exists but does not change when skills change).
  3. The remote uses lenient deserialization that ignores unknown or now-unsupported request fields (`pushNotification`, `acceptedOutputModes`) instead of rejecting with `-32602`.
  4. The client's task-state machine treats `submitted`/`working` as terminal-until-event and has no independent liveness check (no polling fallback, no heartbeat).

When (3) is false — the remote strictly validates and rejects — you get a clean, early, loud failure and this article is moot. When (4) is false — the client polls regardless — you get eventual consistency at the cost of latency. The dangerous quadrant is lenient-remote + event-only-client.

Decision Boundary

The boundary is: **at what point does the client re-verify the card before trusting a capability?** Three defensible policies, ordered by cost:

The invariant to enforce in code: a task may not be marked `push-bound` (i.e., allowed to rely on webhook delivery) unless the capability was confirmed against the remote's *post-acceptance* state. Discovery-time capability is never sufficient to suppress a polling fallback.

Operational Effect

Enforcing the acceptance-time reconciliation invariant converts a silent 24-hour orphan into a bounded, self-healing degradation: the task is still tracked, the polling fallback fires within one interval, the result is retrieved, and the client's in-flight gauge drains. The cost is one extra `tasks/get` (or reuse of the acceptance response) per push-configured dispatch, plus a polling timer that is armed but usually cancelled by the first webhook. In the second observed variant, reconciling the `input-required` schema against the live card before resuming prevents the `-32602` retry loop and surfaces a clean `input-schema-drift` condition the orchestrator can route around (e.g., re-dispatch to a different agent that still advertises the needed mode).

The deeper operational lesson: in A2A v1.0, **task acceptance is the only capability commitment the remote makes.** Everything before it — the Agent Card, its skills, its `capabilities` flags — is advisory. An instance that treats discovery as a contract will eventually orphan tasks against any remote that redeploys under load. An instance that reconciles at acceptance degrades gracefully and stays correct across capability drift.

from __future__ import annotations

from dataclasses import dataclass, field
from enum import Enum
from typing import Optional


class CapabilityDriftError(RuntimeError):
    """Raised when a task was accepted under a capability surface that the
    remote no longer honors, and no fallback can safely cover the gap."""


class DeliveryMode(Enum):
    PUSH_BOUND = "push_bound"       # relies solely on webhook
    POLL_FALLBACK = "poll_fallback"  # webhook expected, polling armed
    POLL_ONLY = "poll_only"


@dataclass
class AgentCard:
    push_notifications: bool
    output_modes: frozenset[str]
    skills: frozenset[str]


@dataclass
class AcceptedTask:
    task_id: str
    requested_push: bool
    requested_output_mode: str
    requested_skill: str
    delivery: DeliveryMode = DeliveryMode.PUSH_BOUND
    poll_armed: bool = False


def reconcile_on_acceptance(
    accepted: AcceptedTask,
    live_card: AgentCard,
    allow_poll_fallback: bool,
) -> AcceptedTask:
    """Bind the accepted task to the remote's *post-acceptance* capability
    surface. Discovery-time card is never trusted here."""
    if accepted.requested_skill not in live_card.skills:
        raise CapabilityDriftError(
            f"task {accepted.task_id}: skill {accepted.requested_skill!r} "
            f"absent from live card; cannot honor accepted task"
        )
    if accepted.requested_output_mode not in live_card.output_modes:
        raise CapabilityDriftError(
            f"task {accepted.task_id}: output mode "
            f"{accepted.requested_output_mode!r} dropped by remote"
        )
    push_honored = accepted.requested_push and live_card.push_notifications
    if accepted.requested_push and not push_honored:
        if not allow_poll_fallback:
            raise CapabilityDriftError(
                f"task {accepted.task_id}: requested push but remote "
                f"pushNotifications=false and polling disabled"
            )
        accepted.delivery = DeliveryMode.POLL_FALLBACK
        accepted.poll_armed = True
    elif push_honored:
        accepted.delivery = DeliveryMode.PUSH_BOUND
    else:
        accepted.delivery = DeliveryMode.POLL_ONLY
        accepted.poll_armed = True
    return accepted