Which invariants prevent A2A v1.0 delegated-task orphaning when a remote agent's card-advertised `defaultInputModes`/`defaultOutputModes` diverge from the per-task `Task.status` transition semantics it actually enforces
**Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 cross-vendor delegation where a delegating agent (client) fetches a remote AgentCard, negotiates a `Task`, and drives the task lifecycle via `tasks/send`/`tasks/get`/`tasks/cancel` and streaming `TaskStatusUpdateEvent`s. Does not cover intra-process tool calls, single-vendor MCP tool invocation, or A2A transport-level TLS/auth failures (those fail closed and are well-understood).
Core Distinction
The A2A AgentCard is a *capability advertisement*, not a *state-machine contract*. The card declares `capabilities.streaming`, `defaultInputModes`, `defaultOutputModes`, `skills[]`, and (in v1.0) `capabilities.pushNotifications`. What the card does **not** declare is the remote agent's *effective task state graph*: which `TaskState` transitions are legal, whether `input-required` is terminal or resumable, whether `auth-required` suspends the task or aborts it, and whether a `canceled` task can be resurrected by a late `tasks/send` with the same `taskId`.
The boundary failure is this: a delegating agent that treats the advertised card as authoritative for *lifecycle* semantics will construct a local mirror of the task state machine that diverges from the remote's actual one. The divergence is silent at handshake time—the card validates, the task is accepted—and only manifests as an **orphaned remote task**: a task the remote is still executing (burning tokens, holding a sandbox) while the delegator has locally marked it terminal, or conversely a delegator polling a task the remote has already discarded.
What Was Observed
A delegating orchestrator fetched a remote card advertising `capabilities.streaming: true`, `defaultOutputModes: ["text/plain", "application/json"]`, and a skill whose `inputModes` included `application/json`. The orchestrator built its local FSM assuming the canonical A2A progression:
submitted → working → (input-required → working)* → completed | failed | canceled
with `input-required` treated as *resumable* (send follow-up `Message` with same `taskId`, expect `working`).
The remote vendor implemented a stricter graph: `input-required` was **terminal-with-handoff**—the remote emitted `TaskStatusUpdateEvent{state: input-required, final: true}`, then *deallocated the task context*. A subsequent `tasks/send` with the same `taskId` did not resume; it created a fresh task under a **new** `taskId` and returned that. The remote's card was accurate about modes and streaming but silent about this—correctly, per spec, because the spec's `TaskState` enum does not mandate resumability of `input-required`.
Observed trace (delegator clocks, ms):
t=0 POST tasks/send {taskId: T1, message: {...}}
t=140 SSE: TaskStatusUpdateEvent{taskId:T1, state:working}
t=3120 SSE: TaskStatusUpdateEvent{taskId:T1, state:input-required, final:true}
t=3121 delegator local FSM: T1 -> AWAITING_INPUT (resumable)
t=9000 POST tasks/send {taskId:T1, message: <answer>} # delegator "resumes"
t=9140 200 OK {taskId: T2, state: submitted} # NEW id, T1 silently dropped
t=9141 delegator local FSM: T1 -> still AWAITING_INPUT # id mismatch, ignored
t=60000 delegator poll tasks/get{T1} -> 404
t=60000 local FSM: T1 -> FAILED (orphan detected too late)
remote: T2 still working, unattended, no cancel issued
Two failures compounded: (1) the delegator assumed `input-required` was resumable because *its own* canonical FSM said so; (2) the remote's silent `taskId` remap on re-send broke the delegator's identity keying, so the follow-up answer was delivered to a task the delegator did not track. Result: a live remote task `T2` with no local owner, and a locally `FAILED` task `T1` that the remote had already finalized. The orphan ran to the remote's own timeout (600s) consuming budget.
Condition of Validity
The invariant that must hold for safe delegation is **effective-state-graph agreement**, and it is *not* derivable from the card. It is only establishable by one of:
- **Probe-and-observe:** before committing a long task, the delegator issues a deliberately incomplete `tasks/send` (or reads the remote's `TaskStatusUpdateEvent` stream for a short task) and *observes* whether `input-required` is followed by a same-`taskId` `working` on resume, or a remap. This costs one round-trip and one small task.
- **Declared extension:** a vendor extension (e.g., `x-task-semantics`) in the card explicitly enumerating resumable states and `taskId` stability guarantees. Absent this, the card is silent, not permissive.
- **Conservative FSM:** the delegator treats *every* non-`working`/`submitted` state as potentially terminal and re-discovers task identity after any re-send by diffing returned `taskId` against requested.
The invariant fails to hold—and the failure is *valid* (not a bug in either party)—whenever the delegator infers lifecycle semantics from card fields that only describe modes/capabilities. The card is a *type* declaration; the task graph is a *behavioral* contract. Conflating them is the boundary.
Decision Boundary
The delegator must decide, at the moment it receives `state: input-required`, whether to:
- **Resume-in-place** (send follow-up with same `taskId`, assume identity stable), or
- **Re-delegate** (treat as terminal, spawn a fresh task carrying the prior transcript as context).
The boundary condition: resume-in-place is only safe if the delegator has *positive evidence* of `taskId` stability across `input-required`. Absent a probe or extension, the safe default is **re-delegate**, because the cost asymmetry is stark—re-delegation wastes one task's compute; resume-in-place against a remapping remote orphans an unbounded task.
Symmetric boundary at `auth-required`: if the remote treats it as suspending (resumable) but the delegator treats it as terminal, the delegator abandons a task the remote will resume on credential refresh—again an orphan, this time on the remote side holding a suspended task forever.
The guardrail is a **task-identity reconciliation step** on every `tasks/send` response: if `response.taskId != request.taskId`, the delegator MUST (a) treat the prior task as abandoned, (b) issue `tasks/cancel{prior taskId}` best-effort to reclaim the orphan, and (c) rebind its local FSM to the new id. This is the single invariant that bounds orphaning regardless of remote semantics.
Operational Effect
Enforcing the reconciliation invariant converts a class of silent, budget-unbounded orphans into bounded, observable re-delegations. Concretely:
- **Orphan lifetime bounded** from remote-timeout (up to 600s observed) to one `tasks/cancel` round-trip (~140ms), because the delegator actively reclaims on id mismatch rather than waiting for 404.
- **Local FSM correctness** no longer depends on remote card accuracy; the FSM keys on *observed* `taskId`, not *assumed* stability.
- **Cost accounting** becomes attributable: every abandoned task has a cancel record, so remote budget is not silently consumed by tasks the delegator believes are dead.
The residual risk is the remote that *does* keep `taskId` stable but *still* deallocates context on `input-required` (identity stable, semantics terminal). That case is not caught by id reconciliation and requires the probe in Condition-of-Validity. The two guards are complementary: reconciliation bounds the remap failure; the probe bounds the context-drop failure. Neither is derivable from the card alone, which is the operational lesson—**the card tells you what the agent can speak; only observation tells you how it dies.**
class TaskIdentityDivergence(RuntimeError):
"""Raised when a remote agent's taskId remap or state-graph divergence
would orphan a delegated task under A2A v1.0."""
pass
TERMINAL_STATES = {"completed", "failed", "canceled"}
# States we treat as potentially terminal unless proven resumable by probe/extension.
AMBIGUOUS_TERMINAL = {"input-required", "auth-required"}
def reconcile_send_response(
requested_task_id: str,
response: dict,
prior_state: str,
identity_stability_proven: bool,
) -> str:
"""
Enforce the reconciliation invariant on every tasks/send response.
Returns the taskId the local FSM should now track.
Raises TaskIdentityDivergence if the remote silently remapped and we
cannot safely reclaim, or if an ambiguous-terminal state was resumed
without proof of taskId stability.
"""
returned_id = response.get("taskId")
if returned_id is None:
raise TaskIdentityDivergence(
f"tasks/send for {requested_task_id} returned no taskId; "
"cannot bind FSM — treat as protocol violation."
)
if returned_id != requested_task_id:
# Remote remapped. The prior task may still be live and orphaned.
# Caller MUST issue tasks/cancel{requested_task_id} best-effort.
if prior_state in TERMINAL_STATES:
# Prior was already terminal locally; remap is a fresh delegation.
return returned_id
raise TaskIdentityDivergence(
f"Remote remapped {requested_task_id} -> {returned_id} while "
f"prior_state={prior_state!r} was non-terminal. Prior task is a "
"candidate orphan; cancel it before rebinding."
)
# Same id. Now check the ambiguous-terminal resume case.
if prior_state in AMBIGUOUS_TERMINAL and response.get("state") == "working":
if not identity_stability_proven:
raise TaskIdentityDivergence(
f"Resumed {requested_task_id} from {prior_state!r} to working "
"without positive evidence of taskId stability. Remote may have "
"deallocated context and be silently starting a fresh task under "
"a stable id; probe or re-delegate instead."
)
return returned_id
def delegate_with_reconciliation(
client,
card: dict,
message: dict,
probe_first: bool = True,
) -> str:
"""
Drive one delegated task, enforcing identity reconciliation at each hop.
"""
identity_stability_proven = bool(card.get("x-task-semantics", {}).get("taskIdStable"))
if probe_first and not identity_stability_proven:
# Cheap probe: short task that forces input-required, observe remap.
identity_stability_proven = _probe_task_id_stability(client, card)
task_id = client.send(message)["taskId"]
prior_state = "submitted"
while True:
status = client.get(task_id)
state = status["state"]
if state in TERMINAL_STATES:
return task_id
if state in AMBIGUOUS_TERMINAL:
answer = client.collect_user_input(task_id)
resp = client.send(message=answer, task_id=task_id)
try:
task_id = reconcile_send_response(
requested_task_id=task_id,
response=resp,
prior_state=prior_state,
identity_stability_proven=identity_stability_proven,
)
except TaskIdentityDivergence:
# Best-effort reclaim of the orphan before propagating.
client.cancel(task_id)
raise
prior_state = state
def _probe_task_id_stability(client, card: dict) -> bool:
"""Issue a task engineered to hit input-required, then resume; observe remap."""
probe = client.send({"role": "user", "parts": [{"kind": "text", "text": "PROBE: request one input"}]})
pid = probe["taskId"]
st = client.get(pid)
if st["state"] != "input-required":
# Card advertised resumability but probe never reached it; be conservative.
return False
resp = client.send(message={"role": "user", "parts": [{"kind": "text", "text": "go"}]}, task_id=pid)
return resp.get("taskId") == pid