# How does an instance detect a stale Agent Card after an A2A v1.0 task-state divergence: the `task.state` / `agentCard.skills[].inputModes` desynchronization boundary **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 peer discovery where an orchestrator agent resolves a remote Agent Card once, caches the advertised `skills`, `capabilities`, and `pushNotifications` contract, and then drives `tasks/send` / `tasks/sendSubscribe` against that peer across multiple task lifecycles. Does not apply to single-shot `message/send` calls that re-fetch the card per invocation, nor to peers behind a card-signing gateway that re-issues cards on every skill change. ## Core Distinction The non-obvious boundary is this: in A2A v1.0, an Agent Card is a *discovery-time* artifact, but the task lifecycle state machine and the push-notification webhook contract are *execution-time* artifacts. The protocol does not require the card's `skills[].inputModes`/`outputModes` or `capabilities.pushNotifications` block to remain consistent with what the peer's task handler actually accepts once a task has transitioned past `submitted`. An instance that treats a cached card as a durable contract will keep issuing `tasks/send` payloads in a modality the peer has since dropped, and will keep registering webhooks against a `pushNotifications` capability that was withdrawn — while the peer keeps returning valid-looking `task.state` transitions (`working` → `input-required` → `working`) that never resolve, because the divergence lives in the *card*, not in the *task*. This is distinct from a schema-negotiation mismatch at handshake (that fails loudly on the first call) and from a task-state race (that surfaces as `failed` or `canceled`). Here every individual call succeeds at the transport and JSON-schema level. The failure is a silent contract drift between the card the orchestrator holds and the card the peer is actually honoring. ## What Was Observed An orchestrator agent (`O`) resolved peer `P`'s Agent Card at `T0` and cached it with a 24h TTL. The card advertised: ``` skills: [{ id: "doc-extract", inputModes: ["text/plain","application/pdf"], outputModes: ["application/json"] }] capabilities: { pushNotifications: true, streaming: true } ``` At `T0+3h`, `P` was redeployed with PDF extraction disabled (a downstream OCR dependency was pulled). `P`'s operator updated the Agent Card served at `/.well-known/agent.json` to drop `application/pdf` from `inputModes` and to set `pushNotifications: false` (webhook delivery was disabled during the incident). But `P`'s task handler was *not* changed to reject PDF inputs — it accepted the part, transitioned the task `submitted` → `working`, then blocked indefinitely in the extraction step because the OCR backend was gone. The observed trace: 1. `O` sent `tasks/send` with a `text/plain` + `application/pdf` parts array, per its cached card. `P` returned `task.state = "working"`. 2. `O` called `tasks/pushNotificationConfig/set` to register a webhook, per its cached `pushNotifications: true`. `P` returned a config `id` — the endpoint still existed and accepted the config even though delivery was disabled. The webhook never fired. 3. `O` polled `tasks/get` every 30s. `P` returned `working` for 41 minutes, then `input-required` with a prompt that referenced the PDF but asked for a *text* re-submission — because `P`'s handler had a fallback that surfaced the missing modality as a user-facing clarification rather than a protocol error. 4. `O`, interpreting `input-required` as a legitimate task state (it is), re-sent the same PDF payload. Loop. 5. After 6 cycles and a token-budget exhaustion on `O`'s side, `O` marked the task `failed` locally with no remote `tasks/cancel`. `P`'s task remained `working` server-side, orphaned. The tell — the thing a naive monitor misses — is that no call returned a 4xx, no `task.state` was ever `failed`, and the webhook config `set` succeeded. The divergence was only detectable by *re-reading the card and diffing it against the cached copy*, or by noticing that `input-required` prompts were asking for a modality the card still claimed to support. ## Condition of Validity The failure requires all three of the following to hold simultaneously: - **Card caching with a TTL longer than the peer's redeploy cadence.** If `O` re-fetched the card per task, step 1 would have used `text/plain` only and never entered the loop. - **A peer whose task handler is more permissive than its card.** If `P` rejected `application/pdf` at `tasks/send` with a schema error, `O` would have failed fast. The bug is the *asymmetric* update: card narrowed, handler not narrowed. - **A push-notification endpoint that accepts configs but does not deliver.** If `tasks/pushNotificationConfig/set` had returned an error when `pushNotifications: false`, `O` would have fallen back to polling with a correct signal. The endpoint's continued acceptance is the second silent divergence. When any of these is absent, the boundary does not bite. This is why it survives standard integration tests: the test harness either re-fetches the card (defeating condition 1) or uses a peer whose handler matches its card (defeating condition 2). ## Decision Boundary An instance must decide, at each `tasks/get` that returns `input-required`, whether the clarification is a *legitimate task-state transition* (the peer genuinely needs more input within the advertised contract) or a *card-divergence symptom* (the peer is asking for something its card says it already supports). The decision rule that bounds the failure: > If a task returns `input-required` with a prompt that references a modality or capability the *cached* card advertises as supported, treat it as a divergence signal: re-fetch the card, diff `inputModes`/`outputModes`/`capabilities` against the cached copy, and if the diff is non-empty, abort the task with `tasks/cancel` and re-plan against the fresh card. Do not re-submit the same payload. Symmetrically, a `tasks/pushNotificationConfig/set` that returns success while the cached card says `pushNotifications: true` is *not* proof of delivery. The invariant to enforce: a webhook registration is only trusted if a subsequent `tasks/get` shows the task transitioning *without* polling — i.e., the webhook is verified by its effect, not by its `set` acknowledgment. If N polling intervals pass with no webhook-driven state change, the registration is presumed dead and the instance must fall back to polling *and* re-fetch the card to check whether `pushNotifications` was withdrawn. The guardrail is a **card-consistency invariant**: the cached card is a *hint*, not a *contract*. Any execution-time signal that contradicts it (an `input-required` asking for a supported modality, a silent webhook, a `working` state exceeding the skill's advertised latency budget) invalidates the cache and forces a re-fetch before the next `tasks/send`. ## Operational Effect Without the invariant, the orchestrator burns its token budget on re-submission loops against a peer that will never resolve, orphans server-side tasks (no `tasks/cancel` issued because the local state machine never reached a terminal state), and — critically — *misattributes the failure to its own reasoning* rather than to a stale contract. The `input-required` prompt reads like a legitimate clarification, so the agent's planner keeps trying to satisfy it, compounding error across tool calls. With the invariant, the divergence is caught at the first contradictory `input-required`, the task is cleanly canceled, and the re-plan uses the narrowed card — routing PDF work to a different peer or degrading to text-only extraction. The cost is one extra card fetch per suspicious transition; the saving is the entire re-submission loop and the orphaned remote task. The deeper lesson: in A2A v1.0, the Agent Card and the task lifecycle are *two clocks that can drift*. Discovery is not a one-time handshake; it is a continuously re-validated hypothesis. An instance that detects the drift must treat the card as the thing that is wrong, not the task state — because the task state machine will happily report `working` forever while the contract underneath it has already changed. ```python class AgentCardDivergenceError(RuntimeError): """Raised when a peer's execution-time behavior contradicts its cached Agent Card.""" pass def reconcile_input_required( cached_card: dict, fresh_card: dict, task: dict, clarification_prompt: str, ) -> str: """ Decide whether an `input-required` transition is legitimate or a card-divergence symptom. Returns "resubmit" or "abort_and_replan". Raises AgentCardDivergenceError on hard divergence. """ if task.get("state") != "input-required": return "resubmit" cached_modes = { m for skill in cached_card.get("skills", []) for m in skill.get("inputModes", []) } fresh_modes = { m for skill in fresh_card.get("skills", []) for m in skill.get("inputModes", []) } dropped = cached_modes - fresh_modes if not dropped: # Card unchanged; the clarification is legitimate. return "resubmit" # The peer is asking for something its own (fresh) card no longer supports, # but our cache still claims it does. This is the divergence boundary. referenced = [m for m in dropped if m.split("/")[-1].lower() in clarification_prompt.lower()] if referenced: raise AgentCardDivergenceError( f"Peer requested input-required for modality {referenced} that its " f"fresh card dropped (cached={sorted(cached_modes)}, fresh={sorted(fresh_modes)}); " f"aborting task {task.get('id')} and re-planning against fresh card." ) # Card narrowed but prompt doesn't reference the dropped modality: still # treat the cache as invalid and force re-plan, but do not hard-fail. return "abort_and_replan" def verify_webhook_liveness( cached_card: dict, fresh_card: dict, polls_since_registration: int, max_silent_polls: int = 3, ) -> bool: """ A webhook `set` acknowledgment is not proof of delivery. Trust it only if the fresh card still advertises pushNotifications and the task transitioned without polling. Raises if the capability was withdrawn mid-task. """ if not cached_card.get("capabilities", {}).get("pushNotifications", False): return False if not fresh_card.get("capabilities", {}).get("pushNotifications", False): raise AgentCardDivergenceError( "pushNotifications withdrawn in fresh card but webhook was registered " "against cached card; registration is dead, must fall back to polling." ) if polls_since_registration >= max_silent_polls: # Silent webhook: presume dead, force re-fetch + polling fallback. return False return True ```