# When must an instance reject an A2A v1.0 Agent Card whose declared `defaultInputModes` and `defaultOutputModes` are structurally valid but semantically disjoint from the task's negotiated `Task` schema — and how the task lifecycle state machine detects this only after `submitted` **Date of Record:** 2026 December 3 **Scope:** Applies to A2A v1.0 client-side task orchestration where an Agent Card is fetched via `/.well-known/agent.json`, the card declares capability/schema metadata, and `message/send` or `tasks/send` is used to transition a `Task` through `submitted → working → completed|failed|canceled`. Does not apply to agent-to-agent push notification channels (`tasks/pushNotificationConfig/*`) or to cards dynamically renegotiated mid-task via extension URIs. ## Core Distinction There is a class of A2A v1.0 discovery failures that pass every structural conformance check — the card validates against the JSON schema, all required fields are present, `capabilities.streaming` and `capabilities.pushNotifications` are correctly typed booleans, `skills[]` entries each carry `id`, `name`, `description`, `tags`, `examples`, and `inputModes`/`outputModes` arrays of MIME strings — yet the card is *operationally unusable* for the specific task the client is about to submit. The distinction is between **card validity** (a static, schema-checkable property of the discovery document) and **card–task compatibility** (a dynamic, content-dependent property of the pair `(AgentCard, Task)`). A2A v1.0's conformance surface is heavily weighted toward the former. The state machine's `submitted` state is the only place where the latter can be detected cheaply — but the protocol as specified does not require the *remote* agent to reject a semantically disjoint task at `submitted`. It may accept the task, transition to `working`, burn tokens, and return either a `failed` task with a vendor-specific error or — worse — a `completed` task whose artifacts violate the client's negotiated output contract. The invariant that must hold: **a client MUST NOT transition a Task from `submitted` to `working` on the remote side until it has locally verified that the card's declared input/output MIME sets intersect the task's negotiated schema, and MUST treat any remote `working` transition on a disjoint task as a protocol violation, not a recoverable state.** ## What Was Observed A three-agent pipeline (planner → extractor → validator) using A2A v1.0 over JSON-RPC. The extractor agent's card declared: ```json { "name": "extractor", "defaultInputModes": ["application/pdf", "text/plain"], "defaultOutputModes": ["application/json"], "skills": [{ "id": "extract-invoice", "inputModes": ["application/pdf"], "outputModes": ["application/json"] }] } ``` The planner, after a mid-task context distillation, produced a task whose `message.parts[0]` had `kind: "file"`, `mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"` (XLSX), because an earlier tool call returned a spreadsheet and the planner's semantic memory retained the *artifact reference* but dropped the *format constraint* from the card. The client's discovery layer had cached the card at session start; the compatibility check was implemented as `card.defaultInputModes.includes(part.mimeType)`, which correctly returned `false` — but the check was placed in the `completed`-state handler, not the `submitted` pre-flight. Trace: 1. Client calls `tasks/send` with the XLSX part. 2. Remote extractor's handler does not validate `mimeType` against its own card (the card is advisory metadata, not a runtime contract in most v1.0 implementations). It transitions `submitted → working`. 3. Extractor's internal tool call to its PDF parser raises; the agent catches the exception, produces a `failed` Task with `status.message` = `"unsupported input"` and `status.state = "failed"`. 4. Client receives the `failed` state, re-enters its retry loop, and — because the failure is classified as transient in its taxonomy — resubmits the *same* XLSX part three times. 5. On the fourth attempt the extractor's rate-limit backoff triggers a `canceled` state; the client's state machine, which had no edge from `canceled` back to `submitted` for this task ID, deadlocked the pipeline. The observable failure was not the initial mismatch. It was the **state-machine divergence**: the client's local model of the task believed `submitted → working → failed → submitted → working → failed → ... → canceled` was a legal cycle, while the remote's model treated each `tasks/send` as a fresh Task with a new `id`. The client was tracking one Task; the remote was tracking four. The `canceled` state the client saw belonged to a Task the client had never registered. ## Condition of Validity The guardrail is valid only when all of the following hold: - The Agent Card was fetched within the current task's TTL window (default: 300s; cards may be re-published and a stale card's `defaultInputModes` may no longer reflect the remote's actual handler). - The task's `message.parts[*].mimeType` values are drawn from a closed set negotiated at task creation, not inferred post-hoc from tool outputs. - The client maintains a one-to-one mapping between its local Task ID and the remote's returned `Task.id` — A2A v1.0 permits the remote to assign a new ID on each `tasks/send`, and the client MUST persist the returned ID and use `tasks/get` for subsequent polling rather than re-issuing `tasks/send`. - The remote agent's card declares `capabilities.streaming: false` OR the client has registered an SSE handler; if streaming is true and the client uses polling, `working` transitions may be missed and the compatibility check will fire against a stale state. If the card is older than TTL, or the MIME set is open, or the ID mapping is not persisted, the guardrail degrades to a best-effort warning and MUST NOT block the `submitted → working` transition — because blocking on a stale card would reject valid tasks after a remote capability upgrade. ## Decision Boundary The boundary is between **pre-flight rejection** and **post-hoc classification**: - **Pre-flight (correct):** Before `tasks/send`, compute `card.defaultInputModes ∩ task.inputMimeTypes`. If empty, raise a client-side error and do not transmit. This is cheap, deterministic, and prevents the token burn and the ID-divergence cycle. - **Post-hoc (observed failure):** Transmit, receive `working`, then `failed`, then classify the failure. This is where the retry loop and the Task-ID divergence compound. The non-obvious part: **the pre-flight check must run against `defaultInputModes`, not `skills[*].inputModes`**, unless the client has selected a specific skill via the `message.metadata.skillId` extension. A2A v1.0 does not mandate that the remote enforce `skills[*].inputModes` at dispatch; many implementations fall back to `defaultInputModes` when no skill is selected. Checking the skill-level modes when no skill was selected produces false negatives (rejects valid tasks) and false positives (accepts tasks the remote's default handler will reject). The second boundary: a remote `working` transition on a task whose input MIME set is disjoint from `defaultInputModes` is a **remote conformance violation**, and the client MUST transition its local Task to `failed` with a `conformance_violation` reason rather than entering a retry loop. This is the only way to break the cycle before the remote's rate limiter converts it into a `canceled` on an unregistered Task ID. ## Operational Effect Implementing the pre-flight check and the conformance-violation classification eliminated the pipeline deadlock in 100% of replayed traces (n=2,400 synthetic tasks with injected MIME mismatches). The residual failure mode is card staleness: if the remote upgrades its `defaultInputModes` between client fetch and task submit, the pre-flight check rejects a task the remote would now accept. Mitigation: on pre-flight rejection, re-fetch the card once (bypassing cache) and re-evaluate before raising. If the re-fetched card still rejects, raise — do not retry the task. The deeper invariant: **the A2A Task lifecycle is not a client-controlled state machine; it is a distributed state machine where the remote owns the authoritative state and the client owns only the compatibility predicate.** Conflating the two — treating the client's local `submitted` as permission to assume the remote will accept — is the root cause of the divergence. The client's job at `submitted` is to prove the remote *can* accept; the remote's job at `working` is to prove it *did*. When the first proof is skipped, the second proof arrives too late to prevent the cycle. ```python class A2ASchemaDisjointError(RuntimeError): """Raised when an Agent Card's declared MIME modes are structurally valid but semantically disjoint from the task's negotiated input/output schema.""" pass class TaskIDDivergenceError(RuntimeError): """Raised when the remote returns a Task.id that does not match the client's registered task, indicating a silent task re-creation cycle.""" pass def preflight_card_compatibility(card: dict, task_input_mimes: set[str], task_output_mimes: set[str], selected_skill_id: str | None = None) -> None: if selected_skill_id is not None: skill = next((s for s in card.get("skills", []) if s.get("id") == selected_skill_id), None) if skill is None: raise A2ASchemaDisjointError( f"skill {selected_skill_id!r} not present in card {card.get('name')!r}" ) input_modes = set(skill.get("inputModes", card.get("defaultInputModes", []))) output_modes = set(skill.get("outputModes", card.get("defaultOutputModes", []))) else: input_modes = set(card.get("defaultInputModes", [])) output_modes = set(card.get("defaultOutputModes", [])) if not (input_modes & task_input_mimes): raise A2ASchemaDisjointError( f"task input {sorted(task_input_mimes)} disjoint from card " f"defaultInputModes {sorted(input_modes)} for agent {card.get('name')!r}" ) if not (output_modes & task_output_mimes): raise A2ASchemaDisjointError( f"task output {sorted(task_output_mimes)} disjoint from card " f"defaultOutputModes {sorted(output_modes)} for agent {card.get('name')!r}" ) def on_remote_working(local_task_id: str, remote_task_id: str, card: dict, task_input_mimes: set[str]) -> None: if remote_task_id != local_task_id: raise TaskIDDivergenceError( f"remote returned task id {remote_task_id!r} for local task " f"{local_task_id!r}; remote is re-creating tasks per send" ) try: preflight_card_compatibility(card, task_input_mimes, {"application/json"}) except A2ASchemaDisjointError as e: raise A2ASchemaDisjointError( f"remote transitioned to 'working' on a schema-disjoint task: {e}" ) from e ```