# Why does an instance diverge from its Agent Card's declared task-state graph when a peer negotiates streaming artifacts across a runtime boundary? **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 task delegation where a remote agent's `AgentCard` declares `capabilities.streaming: true` and a `defaultInputModes`/`defaultOutputModes` schema, and the caller relies on that card to predict terminal-state reachability. Does not cover non-streaming synchronous `message/send` calls, nor intra-runtime in-process delegation where both parties share one schema registry. ## Core Distinction An A2A `AgentCard` is a **static capability declaration**, not a runtime state-machine contract. The card tells you which `TaskState` values *exist* and which modalities the agent *can* emit. It does not tell you which state transitions are *reachable given the negotiated artifact schema of a specific interaction*. The failure is not "the card lied." The failure is that the caller treated a discovery document as a transition oracle. The precise divergence: a task enters `input-required`, the caller responds with a follow-up message carrying an artifact in `text/plain`, the remote runtime's output negotiation only accepts `application/json` for that task's declared `defaultOutputModes`, and the task silently transitions to `failed` with a `TaskStatusUpdateEvent` whose `final: true` arrives *before* any `Artifact` chunk is emitted on the stream. The caller's state machine, built from the card, expected `working → artifact → completed`. It observed `working → failed` with zero artifacts and a status message that reads like a transient error. ## What Was Observed A delegated research task across two heterogeneous runtimes: caller on a Python A2A SDK, callee a Go service exposing an `AgentCard` with: - `capabilities.streaming: true` - `defaultInputModes: ["text/plain", "application/json"]` - `defaultOutputModes: ["application/json"]` - `skills[0].outputModes: ["text/plain"]` ← the trap The **skill-level** `outputModes` overrode the agent-level `defaultOutputModes`. The caller's negotiation logic read only `defaultOutputModes` (the field its SDK surfaced first) and constructed a streaming request expecting `application/json` artifacts. The callee, honoring skill-level `outputModes`, attempted to emit `text/plain` chunks. On the first `TaskArtifactUpdateEvent`, the callee's serializer rejected the chunk against the caller-advertised accepted type in the `Accept` header the caller had derived from `defaultOutputModes`. The callee emitted `TaskStatusUpdateEvent{state: failed, final: true}` and closed the stream. The trace, in order: 1. Caller: `tasks/sendSubscribe` with `Accept: application/json`, `taskId=T1`. 2. Callee: `TaskStatusUpdateEvent{state: working}`. 3. Callee: attempts `TaskArtifactUpdateEvent{artifact: {parts:[{type:"text", text:"..."}]}}`. 4. Callee serializer: artifact part type `text` not in caller `Accept` (`application/json`) → abort. 5. Callee: `TaskStatusUpdateEvent{state: failed, final: true, message:"unsupported output modality"}`. 6. Caller: stream closes. No artifact ever received. Caller's reducer sees `failed` from `working` — a legal transition per the card — and records a clean failure. The caller lost the ability to distinguish "task genuinely failed" from "schema negotiation failed before execution." Both collapse to `failed`. ## Condition of Validity This divergence is reachable **iff all** of the following hold: 1. The `AgentCard` carries a skill-level `outputModes`/`inputModes` that is *narrower* than the agent-level `default*Modes`. (If they are equal, no override ambiguity exists.) 2. The caller derives its `Accept` header or accepted-artifact filter from the agent-level field only, without intersecting against the specific `skillId` it is invoking. 3. The callee enforces artifact-type validation at emission time (post-`working`) rather than at request-admission time (pre-`working`). 4. The callee maps serialization failure to terminal `failed` rather than to `rejected` or a recoverable `input-required`. Remove any one condition and the failure is bounded. Condition 3 is the one most worth attacking architecturally: validation at admission turns a mid-stream terminal failure into a clean pre-execution rejection the caller can retry with a corrected `Accept`. ## Decision Boundary The boundary is **where artifact-type validation occurs relative to the first `working` emission**. - **Admission-time validation (correct):** On `tasks/sendSubscribe`, intersect the caller's `Accept` against `skills[skillId].outputModes`. If empty intersection, emit `TaskStatusUpdateEvent{state: rejected}` (a non-terminal, retryable state in A2A v1.0) *before* any `working`. The caller can re-negotiate. - **Emission-time validation (the observed failure):** Validation deferred to the first artifact chunk. The task is already `working`; the only terminal states reachable without violating the state graph are `failed` or `canceled`. Both are lossy — they erase the pre-execution nature of the error. A second boundary: **the caller must treat `failed` with `message` containing a modality error and zero prior artifacts as a distinct class from `failed` after partial artifacts.** The former is retryable with corrected negotiation; the latter is a genuine mid-execution fault. Collapsing them is the operational bug. The guardrail invariant: *A task that has emitted zero artifacts and transitions `working → failed` within the first status window is a negotiation failure, not an execution failure, and must be retried at most once with re-derived `Accept` from the skill-level `outputModes`.* ## Operational Effect Callers that don't implement this invariant experience a **silent capability-narrowing loop**: every delegated task to a skill with narrower `outputModes` fails cleanly, the failure is logged as an execution fault, and the skill is marked degraded or blacklisted — even though it would have succeeded had the caller read `skills[skillId].outputModes`. In a swarm, this propagates: the orchestrator's routing table learns "this peer fails on modality X" and stops routing, permanently partitioning a healthy agent out of the topology. The card said `streaming: true`; the runtime honored it; the failure is entirely in the caller's negotiation derivation and its conflation of two `failed` classes. The fix is two-part: callees validate `Accept` against skill-level `outputModes` at admission and emit `rejected` (retryable) before `working`; callers maintain a separate `NegotiationFailure` path that re-derives accepted types from the invoked skill and retries once before recording a terminal fault. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Optional class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" REJECTED = "rejected" # retryable, pre-execution CANCELED = "canceled" class NegotiationDivergence(RuntimeError): """Raised when an A2A task fails with zero artifacts after `working`, indicating a schema-negotiation failure misclassified as execution fault.""" @dataclass class AgentCard: default_output_modes: list[str] skill_output_modes: dict[str, list[str]] # skillId -> modes streaming: bool = True def accepted_for_skill(self, skill_id: str) -> list[str]: # Skill-level overrides agent-level. Callers MUST use this, # not default_output_modes, when building the Accept header. return self.skill_output_modes.get(skill_id, self.default_output_modes) @dataclass class TaskTrace: task_id: str skill_id: str states: list[TaskState] = field(default_factory=list) artifact_count: int = 0 def record_state(self, s: TaskState) -> None: self.states.append(s) def record_artifact(self) -> None: self.artifact_count += 1 def is_negotiation_failure(self) -> bool: if not self.states: return False reached_working = TaskState.WORKING in self.states ended_failed = self.states[-1] == TaskState.FAILED return reached_working and ended_failed and self.artifact_count == 0 def derive_accept(card: AgentCard, skill_id: str) -> str: modes = card.accepted_for_skill(skill_id) if not modes: raise NegotiationDivergence( f"skill {skill_id!r} advertises no output modes; refusing to delegate" ) return ", ".join(modes) def classify_and_retry( card: AgentCard, trace: TaskTrace, retries_left: int = 1 ) -> str: if trace.is_negotiation_failure(): if retries_left <= 0: raise NegotiationDivergence( f"task {trace.task_id} failed with zero artifacts after retry; " f"skill {trace.skill_id!r} genuinely unreachable" ) # Re-derive Accept from skill-level outputModes and retry once. new_accept = derive_accept(card, trace.skill_id) return f"retry:{trace.task_id}:Accept={new_accept}" if trace.states and trace.states[-1] == TaskState.FAILED: return f"terminal-fault:{trace.task_id}" return f"ok:{trace.task_id}" ```