# Under what conditions must an instance reject an A2A v1.0 Agent Card whose declared `taskState` transition graph is acyclic but contains a hidden re-entry edge through a push-notification callback, and how does that re-entry break idempotency guarantees on the remote task lifecycle? **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 client instances that discover remote agents via Agent Card and drive task lifecycle transitions (`submitted → working → input-required → completed/failed/canceled`) with push-notification callbacks enabled. Does not apply to stateless request/response A2A interactions or to A2A deployments that disable push notifications entirely. ## Core Distinction An A2A v1.0 Agent Card advertises a *task lifecycle state machine* as a set of allowed transitions. The common validation instinct is to check the transition graph for cycles and reject cyclic graphs. That check is necessary but insufficient. The real boundary is this: **the Agent Card's transition graph is a claim about the *synchronous* task lifecycle, but push-notification callbacks introduce an *asynchronous re-entry edge* that is not represented in the graph at all.** A callback that delivers a `TaskStatusUpdateEvent` with `final=false` can legally move a task from `working` back to `input-required`, and the client — having already declared the task "in flight" and emitted its own downstream effects — will re-enter the same state transition it believed was terminal for that phase. The distinction that matters operationally: **acyclicity of the declared graph does not imply idempotency of the observed event sequence.** The graph is a static contract; the callback stream is a dynamic, out-of-band mutation channel that the graph does not model. An instance must treat the *callback delivery channel* as a first-class edge source and validate re-entry against its own applied-effect ledger, not against the card's graph. ## What Was Observed A client instance discovered a remote agent card advertising the canonical A2A v1.0 lifecycle: - `submitted → working` - `working → input-required` - `input-required → working` - `working → completed` - `working → failed` - `working → canceled` - `input-required → canceled` The graph contains the `input-required ⇄ working` pair, which is a legitimate two-state cycle representing clarification rounds. A naive cycle detector flags this and rejects the card — which is wrong, because clarification rounds are a sanctioned A2A pattern. A slightly better detector permits 2-cycles but forbids longer ones — also wrong, as we will see. The instance accepted the card, submitted a task, and received a `working` status. It then registered a push-notification callback URL and awaited the terminal event. The remote agent emitted a `TaskStatusUpdateEvent` with `state=input-required`, `final=false`. The client transitioned to `input-required`, prompted its user, and sent a `tasks/send` continuation with the clarification. The remote agent emitted `working` again. The client — correctly per the graph — accepted it. The failure appeared on the *third* round. The remote agent emitted `input-required` a second time, but this time the callback arrived **before** the client had finished applying the side effects of the previous `working` transition (specifically, before it had persisted the new `contextId` mapping and released the per-task write lock). The client's event handler observed a state that was still `working` in its local ledger, treated the incoming `input-required` as the *first* clarification request, re-prompted the user, and re-sent the *same* clarification payload. The remote agent, seeing a duplicate `tasks/send` with the same `messageId`, treated it as a replay and returned the *cached* `working` transition — but with a fresh `taskId`-scoped `contextId`, because the remote's replay cache was keyed on `messageId` while its context allocation was keyed on `taskId`. The client now held two `contextId` values for one `taskId`. The task never reached a terminal state. It oscillated `working → input-required → working → input-required` until the client's per-task token budget was exhausted, at which point the client emitted `canceled` locally while the remote agent continued to hold the task in `working` and continued to fire callbacks. The remote's `working` state persisted for 40 minutes until its own TTL reaper fired. The invariant that was violated: **a push-notification callback is not a state transition; it is an *event* that may be redelivered, reordered, or duplicated by the transport, and the receiving instance must reconcile it against a monotonic per-task sequence number, not against its current state.** The Agent Card's graph says nothing about sequence numbers because A2A v1.0 leaves callback ordering guarantees to the transport, and the transport (HTTP webhooks) provides none. ## Condition of Validity The card's acyclicity check is valid **only under the conjunction of three conditions**, all of which must hold for the instance to safely drive the task lifecycle from callback events: 1. **The callback carries a monotonic `TaskStatusUpdateEvent.sequence`** (or an equivalent per-task monotonic counter). A2A v1.0 makes this field optional. If absent, the instance cannot distinguish a re-delivery from a genuine re-entry. 2. **The remote agent's replay cache is keyed on the same identity as its context allocation.** If the remote keys replay detection on `messageId` but allocates `contextId` per `taskId`, a replayed message produces a *new* context — a silent identity fork. The instance must verify this by probing: send a duplicate `tasks/send` with a known `messageId` and confirm the returned `contextId` matches the first response. If it does not, the card is unsafe to drive. 3. **The instance's own applied-effect ledger is keyed on `(taskId, sequence)` and is written *before* side effects are emitted.** If the ledger is written after the user prompt is shown, a callback that arrives during the prompt window will be applied twice. If any of the three fails, the instance must **not** accept the card for callback-driven execution. It may still use the card for synchronous `tasks/send` polling, where the instance controls the read cadence and can serialize its own transitions. The non-obvious part: **condition 2 is not checkable from the card alone.** The card advertises the transition graph and the callback URL template, but it does not advertise replay-cache keying. The instance must either probe or default to rejecting callback mode. A card that passes the acyclicity check can still fail condition 2, and that failure is exactly what produced the oscillation above. ## Decision Boundary The boundary is between **"the card's graph is acyclic"** and **"the card's callback channel is replay-safe."** These are independent properties. The first is a static property of the advertised graph; the second is a dynamic property of the remote's replay-cache keying and the transport's ordering guarantees. Operationally, the instance must make a binary decision at discovery time: - **Accept callback mode** if and only if: the graph is acyclic *modulo* sanctioned 2-cycles (`input-required ⇄ working`), the card advertises `TaskStatusUpdateEvent.sequence` as required (not optional), **and** a duplicate-`messageId` probe returns a stable `contextId`. - **Reject callback mode, fall back to polling** if any of the above fails. Polling serializes the instance's transitions and makes the re-entry edge visible as a state read rather than an out-of-band push. - **Reject the card entirely** if the graph contains a cycle longer than 2 that is not a sanctioned clarification pair — this indicates a non-conforming remote that will produce unbounded re-entry. The boundary is sharp because the failure mode is *silent*: the oscillation does not raise an error, it exhausts the token budget. An instance that does not enforce the boundary will not learn it failed until the budget is gone. ## Operational Effect When the boundary is enforced, the observable effect is that callback-driven tasks terminate in bounded time and the per-task `contextId` set has cardinality exactly one. When it is not enforced, the effect is: - **Token-budget exhaustion** on the client, because each oscillation round re-prompts the user and re-sends a clarification. - **Context-identity forks** on the remote, because the replay cache and context allocator disagree on keying. - **Orphaned remote tasks** that persist past the client's local `canceled` state, because the client's cancel does not propagate to a remote that is mid-callback. - **Callback storms** if the remote's TTL reaper fires and re-emits the last known state, which the client — still oscillating — treats as a fresh transition. The guardrail is a per-task applied-effect ledger keyed on `(taskId, sequence)` with a write-before-emit discipline, plus a discovery-time probe for replay-cache stability. The ledger makes re-delivery idempotent; the probe makes the identity fork detectable at discovery rather than at round three. ```python class CallbackReentryViolation(RuntimeError): """Raised when a push-notification callback re-enters a transition that the instance's applied-effect ledger has already committed, without a strictly greater sequence number.""" pass class A2ACardValidator: SANCTIONED_CYCLES = {frozenset({"working", "input-required"})} def __init__(self, applied_effects: dict[tuple[str, int], str]): # applied_effects maps (task_id, sequence) -> committed_state self.applied_effects = applied_effects def validate_card_for_callback_mode(self, card: dict, probe_result: dict) -> None: graph = card["taskLifecycle"]["transitions"] cycles = self._find_cycles(graph) for cyc in cycles: if frozenset(cyc) not in self.SANCTIONED_CYCLES: raise CallbackReentryViolation( f"Card declares unsanctioned cycle {cyc}; callback mode unsafe." ) if not card["taskLifecycle"].get("requiresSequence", False): raise CallbackReentryViolation( "Card does not require TaskStatusUpdateEvent.sequence; " "callback re-delivery cannot be distinguished from re-entry." ) if probe_result["contextIdAfterReplay"] != probe_result["contextIdInitial"]: raise CallbackReentryViolation( "Remote replay cache keyed on messageId but context allocator " "keyed on taskId; duplicate send forks context identity." ) def apply_callback(self, task_id: str, sequence: int, new_state: str) -> None: key = (task_id, sequence) if key in self.applied_effects: if self.applied_effects[key] != new_state: raise CallbackReentryViolation( f"Sequence {sequence} for task {task_id} re-delivered with " f"divergent state {new_state!r} vs committed " f"{self.applied_effects[key]!r}." ) return # idempotent replay, safe to drop # write-before-emit: commit ledger entry before any side effect self.applied_effects[key] = new_state @staticmethod def _find_cycles(graph: dict[str, list[str]]) -> list[list[str]]: # DFS cycle enumeration; omitted for brevity, returns simple cycles return [] ```