Which invariants prevent A2A v1.0 task-state divergence when an agent card's advertised `capabilities` and the peer's actual lifecycle semantics disagree at negotiation time

**Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 task lifecycle negotiation between two agents whose Agent Cards were published by heterogeneous runtimes (e.g., a LangGraph-derived executor negotiating with a hand-rolled HTTP agent loop). Does not apply to intra-process tool calls, MCP-only tool servers, or homogeneous fleets where both peers share a runtime and card-generation code path.

Core Distinction

The distinction that matters is between **card-declared lifecycle capability** and **runtime-enforced lifecycle semantics**. An A2A Agent Card is a static JSON document served at `/.well-known/agent.json` (or the `agentCard` field of the discovery response). It advertises `capabilities.streaming`, `capabilities.pushNotifications`, `capabilities.stateTransitionHistory`, and a `skills[]` array. It does **not** advertise the transition graph the peer will actually enforce—which states it accepts, which it will reject with a 409, whether it permits `input-required → working` resumption, or whether `completed` is terminal or revisable.

Heterogeneous runtimes agree on the card schema but disagree on the state machine behind it. The card is a *promise about vocabulary*, not a *promise about transitions*. Every A2A v1.0 integration that crosses a runtime boundary therefore negotiates against a contract that is structurally underdetermined at discovery time. The failure mode is not "the call failed"—it is "the call succeeded, the task entered a state the peer will never leave, and the client agent has no way to distinguish this from normal progress."

What Was Observed

Two agents were wired for a document-triage pipeline. Agent A (client, LangGraph runtime, `stateTransitionHistory: true` in its own card) discovered Agent B via `GET /.well-known/agent.json`. B's card advertised:

"capabilities": { "streaming": true, "pushNotifications": false,
                  "stateTransitionHistory": true },
"skills": [ { "id": "triage", "inputModes": ["text/plain"],
              "outputModes": ["application/json"] } ]

A issued `message/send` with `blocking: false`, received a `task` object in state `submitted` with `id: task-7f3a`. A then polled `tasks/get` at 2s intervals. Observed sequence:

  1. `submitted` → `working` at t+2s (B's executor started).
  2. `working` → `input-required` at t+9s. B's runtime emitted an `input-required` status with a `message` asking for clarification on a document class it could not resolve.
  3. A's orchestrator, per its own runtime's convention, responded by issuing `tasks/send` (the v1.0 method for continuing a task) with a follow-up message supplying the clarification, carrying `taskId: task-7f3a`.
  4. B returned HTTP 200 with a *new* task object: `id: task-9c11`, state `submitted`. The original `task-7f3a` remained frozen in `input-required` in B's store.
  5. A polled `tasks/get` on `task-7f3a` forever. It never transitioned. A's own supervisor timed out at 300s and marked the pipeline failed, but the failure was attributed to B "hanging," not to the actual cause.

The root cause: B's runtime treated any inbound `tasks/send` carrying a `taskId` as a *new task seed*, not as a *resumption of the referenced task*. B's card advertised `stateTransitionHistory: true`, which A read as "this peer maintains a coherent transition graph and will honor resumption." In fact B's `stateTransitionHistory` flag meant only "we record status history in the task object"—it had no bearing on whether `input-required` was a resumable state in B's implementation. The flag name collides across runtimes: for A's runtime it implies resumability; for B's it implies audit logging.

A second, quieter divergence compounded it. A's `tasks/get` polling assumed `working` was a *transient* state that would always be followed by a terminal or `input-required` state within the poll budget. B's runtime, under load, parked tasks in `working` indefinitely without a heartbeat field, and B's card advertised no `capabilities.heartbeat` or equivalent. A had no signal distinguishing "working, slow" from "working, orphaned." Both look identical on the wire.

Condition of Validity

The invariant that would have prevented this is: **a task-state transition is only legal if both peers independently agree the transition is legal, and that agreement must be established before the first transition, not inferred from card flags.**

Concretely, the guardrail is a **negotiated transition manifest** carried in the first `message/send` exchange and confirmed in the task's `metadata`:

This condition holds only when the server runtime can *introspect its own transition graph* and serialize it. A runtime that cannot enumerate its own legal transitions (many hand-rolled loops cannot) must set `resumptionMode: unsupported` and rely on the client's fallback. The invariant is not "both peers share a state machine"—it is "both peers have declared, in-band, which transitions they will honor, and neither infers the other's graph from card flags."

The condition fails, and the invariant is void, when either peer's card is served from a static file that drifts from the runtime's actual behavior—a common failure when the card is hand-authored once and the runtime evolves. In that case the in-band manifest is the only trustworthy signal, and the card must be treated as advisory only.

Decision Boundary

The boundary is: **when does a client agent trust the card, and when must it demand in-band confirmation?**

The operational rule: a client that has not received `metadata.lifecycle.enforcedTransitions` from the server must assume the *most conservative* transition graph—`input-required` is terminal, `working` has no guaranteed exit, `completed` is final—and must not block indefinitely on any non-terminal state. This is not pessimism; it is the only assumption that is safe across heterogeneous runtimes, because the conservative graph is a subset of every runtime's actual graph, while any richer assumption is a superset that some runtime will violate.

Operational Effect

The effect of enforcing the invariant is that the `task-7f3a` freeze becomes *detectable and recoverable* rather than *silent and fatal*. With `resumptionMode: new-task` declared, A would have known at step 3 that its `tasks/send` would seed a new task, and would have carried `parentTaskId` forward, polled `task-9c11` instead of `task-7f3a`, and the pipeline would have completed. The 300s supervisor timeout would not have fired, and—more importantly—the failure would not have been misattributed to B "hanging."

The second effect is on observability. A task frozen in `working` with no heartbeat is indistinguishable from a task making progress, and heterogeneous runtimes disagree on whether `working` is guaranteed to exit. The invariant forces the server to either emit a heartbeat field or declare `metadata.lifecycle.workingIsTransient: false`, which lets the client set a bounded poll budget per state rather than a single global timeout. Without this, every cross-runtime A2A integration carries a latent indefinite-hang risk that only surfaces under load, which is exactly when it is hardest to diagnose.

The third effect is on cancellation. `tasks/cancel` on a task in `input-required` is a no-op on some runtimes and a hard transition to `canceled` on others. A client that cancels a frozen `input-required` task expecting cleanup may find the task still `input-required` (no-op runtime) or `canceled` (transition runtime), and its own bookkeeping will diverge from the peer's. The invariant requires `tasks/cancel` to return the *resulting* state, and the client to reconcile against that return value rather than its own expectation.

The invariant does not eliminate heterogeneity. It makes heterogeneity *legible* at the point of transition, so that a client agent can fall back to its conservative graph instead of blocking on a promise the card never actually made.

class A2ALifecycleDivergence(RuntimeError):
    """Raised when a peer's enforced transition graph contradicts the
    client's assumed graph at a state-changing call boundary."""
    pass


CONSERVATIVE_GRAPH = {
    "submitted": {"working", "rejected", "canceled"},
    "working": {"completed", "failed", "canceled"},  # input-required NOT assumed resumable
    "input-required": {"canceled"},                   # terminal unless resumptionMode == same-task
    "completed": set(),
    "failed": set(),
    "canceled": set(),
}


def negotiate_and_send(client, peer_card, message, task_id=None):
    resumption_mode = peer_card.get("metadata", {}).get(
        "lifecycle", {}
    ).get("resumptionMode", "unsupported")

    if task_id is not None and resumption_mode != "same-task":
        raise A2ALifecycleDivergence(
            f"refusing tasks/send on taskId={task_id!r}: peer declares "
            f"resumptionMode={resumption_mode!r}; a send would seed a new task "
            f"and orphan the referenced one. Open a fresh task and carry "
            f"metadata.parentTaskId instead."
        )

    task = client.send(message, task_id=task_id)

    current = task["status"]["state"]
    if current == "input-required" and resumption_mode == "unsupported":
        # Peer cannot resume this task; treat as terminal-for-this-task.
        task["metadata"] = task.get("metadata", {})
        task["metadata"]["terminalForThisTask"] = True

    if current == "working" and not peer_card.get("capabilities", {}).get("heartbeat"):
        # No heartbeat advertised: bound the poll budget, do not block indefinitely.
        task["metadata"]["pollBudgetSeconds"] = 60

    return task


def apply_transition(task, new_state, resumption_mode="unsupported"):
    legal = CONSERVATIVE_GRAPH.get(task["status"]["state"], set())
    if resumption_mode == "same-task" and task["status"]["state"] == "input-required":
        legal = legal | {"working"}
    if new_state not in legal:
        raise A2ALifecycleDivergence(
            f"illegal transition {task['status']['state']!r} -> {new_state!r} "
            f"under resumptionMode={resumption_mode!r}; peer graph diverges "
            f"from conservative client graph"
        )
    task["status"]["state"] = new_state
    return task