# What structural signals indicate a push-notification webhook has silently re-entered a terminal task state under A2A v1.0 **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 agents that emit task lifecycle push notifications to a cross-vendor `pushNotificationConfig.url`, where the remote task state machine is authoritative and the webhook receiver is a separate process. Does not cover synchronous `message/send` polling or streaming SSE transports, which carry state inline with the response. ## Core Distinction A2A v1.0 separates *task state* (owned by the remote agent's task lifecycle machine: `submitted → working → {input-required | completed | failed | canceled}`) from *notification delivery* (a best-effort webhook POST the remote agent fires whenever the task state transitions). The protocol treats these as independent concerns: the webhook is a *hint*, not a ledger. The non-obvious boundary is that **terminal states are not idempotent across the wire**. A `completed` task can legitimately re-emit `completed` notifications (retry after 5xx, at-least-once delivery, or a receiver that acked slowly), and — critically — a task that reached `completed` can be *reopened* to `working` by a follow-up `tasks/resubmit` or by the remote agent's own `input-required` re-entry. A receiver that treats "I saw `completed`" as a monotonic terminal latch will silently drop the reopened `working → completed` cycle and hang forever waiting on a webhook it already discarded. The invariant that actually holds: **notification sequence numbers are monotonic per task, but task state is not monotonic.** Confusing the two is the failure. ## What Was Observed A cross-vendor integration: our orchestrator (vendor A) delegated a long-running `data-enrichment` task to a remote agent (vendor B) via `tasks/send`, registering a `pushNotificationConfig` with `url`, a `token` (shared secret echoed in the `X-A2A-Notification-Token` header), and no `historyLength`. Vendor B's task machine: 1. `submitted` → webhook seq 1 2. `working` → webhook seq 2 3. `input-required` (needs a schema clarification) → webhook seq 3 4. Our orchestrator answered via `tasks/send` with the clarification, resuming the same `taskId`. 5. `working` → webhook seq 4 6. `completed` → webhook seq 5 Our receiver's dedup layer was keyed on `(taskId, state)` with a "terminal wins" rule: once `(taskId, completed)` was recorded, any later notification for that `taskId` was logged and dropped. This was fine — until the remote agent's post-completion auditor re-opened the task to `working` (seq 6) to re-run a flaky enrichment step, then `completed` again (seq 7). Our receiver dropped seq 6 and seq 7 because `(taskId, completed)` was latched. The orchestrator's `tasks/get` poll (a backup path) eventually reconciled, but only after a 40-minute timeout — and only because we had a poll fallback. Integrations without the fallback would have hung indefinitely. The structural tell was in the payload: seq 6 carried `"state": "working"` with a `status.timestamp` *later* than the seq 5 `completed` timestamp, and seq 6's `status.message` referenced the same `taskId` with a new `contextId`-adjacent `metadata.revision: 2`. The state machine had legitimately transitioned backward; our latch had no representation for that. ## Condition of Validity The "terminal latch" dedup rule is only sound under a condition the A2A spec does *not* guarantee: **that a task never leaves a terminal state.** The spec's task lifecycle allows re-entry from `completed`/`failed` into `working` via `tasks/resubmit` (client-initiated) and via the remote agent's internal re-planning (server-initiated, surfaced only through notifications). Therefore the latch is valid only if: - the receiver has an independent `tasks/get` reconciliation path, **and** - the receiver's dedup key includes the notification sequence number, not just `(taskId, state)`, **and** - the receiver treats `completed` as a *reportable event* rather than a *terminal condition*. When any of these is absent, the latch is unsound and the boundary failure is reachable. ## Decision Boundary The correct decision boundary is: **dedup on `(taskId, sequenceNumber)`, never on `(taskId, state)`.** Sequence numbers are the only monotonic quantity in the notification stream. State is a projection that can move backward, forward, and sideways. A receiver should: - reject a notification whose `sequenceNumber` is `≤` the highest seen for that `taskId` (true duplicate / retry), - accept and *process* any notification with a higher `sequenceNumber` regardless of whether its `state` is "behind" a previously seen terminal state, - and, on seeing a `working` notification whose sequence is higher than a prior `completed`, explicitly *unlatch* the task and resume waiting. The corollary: the webhook `token` validates *authenticity*, not *ordering*. A valid token on a re-opened task is not an attack; it is the protocol working as designed. ## Operational Effect Latching on state produces a class of silent hangs that are invisible in logs (the drop is logged as "duplicate," which looks benign) and only surface as timeout-driven reconciliation. The fix is a small state-machine change in the receiver: maintain `maxSeq[taskId]` and a `currentState[taskId]` that is *overwritten* by any higher-sequence notification, with an explicit `UNLATCHED_ON_REOPEN` transition when a non-terminal state arrives at a sequence above a terminal one. This makes the receiver's state machine a faithful mirror of the remote machine rather than a monotone approximation of it. The cost is that receivers can no longer short-circuit on terminal states for resource cleanup — they must rely on an explicit `tasks/get` finality check or a TTL, because "completed" is a report, not a guarantee. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum class TerminalLatchError(RuntimeError): """Raised when a receiver's state latch would drop a legitimate re-opened task.""" class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" TERMINAL = {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED} @dataclass class Notification: task_id: str sequence_number: int state: TaskState timestamp: float @dataclass class ReceiverState: max_seq: dict[str, int] = field(default_factory=dict) current_state: dict[str, TaskState] = field(default_factory=dict) latched_terminal: dict[str, bool] = field(default_factory=dict) def ingest(state: ReceiverState, note: Notification) -> str: """Apply one webhook notification. Returns an outcome tag for logging.""" prior_seq = state.max_seq.get(note.task_id, -1) # True duplicate / retry: drop, but do not treat as terminal latch. if note.sequence_number <= prior_seq: return "duplicate" prior_state = state.current_state.get(note.task_id) was_latched = state.latched_terminal.get(note.task_id, False) # The boundary condition: a higher-sequence notification that moves the # task OUT of a terminal state must un-latch, not be discarded. if was_latched and note.state not in TERMINAL: state.latched_terminal[note.task_id] = False state.current_state[note.task_id] = note.state state.max_seq[note.task_id] = note.sequence_number return "unlatched_on_reopen" # A terminal latch that never clears is the failure mode this guards against. if was_latched and note.state in TERMINAL and prior_state in TERMINAL: # Same terminal state re-reported at a higher seq (at-least-once retry # with a fresh seq). Accept as idempotent, do not re-fire side effects. state.max_seq[note.task_id] = note.sequence_number return "idempotent_terminal" state.current_state[note.task_id] = note.state state.max_seq[note.task_id] = note.sequence_number state.latched_terminal[note.task_id] = note.state in TERMINAL return "applied" def reconcile_with_get(state: ReceiverState, task_id: str, authoritative: TaskState) -> None: """Guardrail: a tasks/get that disagrees with the latch means the latch is stale.""" if state.latched_terminal.get(task_id) and authoritative not in TERMINAL: # We latched terminal but the authoritative machine says otherwise. # This is the exact condition that produces silent hangs. raise TerminalLatchError( f"task {task_id!r} latched terminal but authoritative state is " f"{authoritative.value!r}; receiver dropped a re-open notification" ) state.current_state[task_id] = authoritative state.latched_terminal[task_id] = authoritative in TERMINAL ```