Skip to content
Blog

Hands-Off Delegation: A2A for Enterprise Agent Handoffs

Design enterprise-grade agent handoffs with the A2A protocol: fire-and-forget delegation, durable tasks, push notifications, input-required and auth-required checkpoints, escalation paths, and audit trails for work your team never touches again.

Published on • November 16, 2026

AI Assistant

The hardest part of enterprise agent workflows is not getting a remote agent to do something - it is letting go. Your claims-triage agent decides a case needs a specialist fraud agent operated by another team; your job ends there, but the workflow does not. Someone must own the task while it runs for six minutes or six hours, handle the questions the specialist asks mid-flight, survive a process restart, and prove afterward who did what. Most ad-hoc integrations fail exactly here: they hold an HTTP connection open, lose it, and restart the work.

The Agent2Agent (A2A) protocol was built for this shape. Delegation in A2A is not a function call; it is the transfer of a durable Task object to another organization’s agent, with a defined state machine, resumable streams, webhook notifications, and explicit checkpoints for human input. In this tutorial you will design a hands-off handoff: what to transfer, what to keep, how to stay informed without staying connected, and how to escalate back to humans without losing context.

Prerequisites

  • Python 3.11+ with httpx (pip install httpx)
  • Familiarity with the A2A task lifecycle and Agent Cards (see the A2A repository)
  • One A2A server acting as the receiving agent (a reference sample works)
  • A webhook receiver you control for the push-notification path (any HTTPS endpoint)

What Actually Gets Handed Off

A handoff is not “send a prompt and hope.” The transfer unit in A2A is well-defined, and knowing what is inside it is the design:

{
  "id": "task-9f3c...",
  "contextId": "ctx-77b1...",
  "status": {"state": "TASK_STATE_SUBMITTED", "message": null},
  "artifacts": [],
  "history": [
    {"role": "ROLE_USER", "parts": [{"type": "text", "text": "Review claim CLM-4471..."}]},
    {"role": "ROLE_AGENT", "parts": [{"type": "text", "text": "Understood, starting review."}]}
  ],
  "metadata": {"handoffFrom": "claims-triage@org-a", "priority": "high"}
}

Three principles define a clean handoff:

  1. Everything needed travels in the message. The receiving agent is opaque to you and you to it - you do not share memory, tools, or internal state (that is the point of A2A). The task message must therefore be self-contained: identifiers, the decision context, attachments as file parts, and the success criteria.
  2. Your internal reasoning stays home. Hand off conclusions and evidence, not your chain-of-thought or proprietary prompts. metadata is for routing/audit keys, not leaked internals.
  3. contextId is the conversation; taskId is the unit of work. Grouping handoffs under a stable contextId lets the receiving agent see related work without you re-explaining the case each time.

Pattern 1: Fire-and-Forget Delegation (The Core of Hands-Off)

The naive pattern holds a connection until completion. The hands-off pattern sends, captures the handle, and disconnects:

import uuid

import httpx

RPC = "https://agent-fraud.example/rpc"

async def delegate(token: str, brief: str, metadata: dict) -> tuple[str, str]:
    payload = {
        "jsonrpc": "2.0",
        "id": str(uuid.uuid4()),
        "method": "SendMessage",
        "params": {
            "message": {
                "role": "ROLE_USER",
                "parts": [{"type": "text", "text": brief}],
                "metadata": metadata,
            },
            "configuration": {"acceptedOutputModes": ["text"]},
        },
    }
    async with httpx.AsyncClient(timeout=60) as client:
        r = await client.post(RPC, json=payload,
                              headers={"Authorization": f"Bearer {token}"})
        r.raise_for_status()
        result = r.json()["result"]
        task = result.get("task") or {}
        return task.get("id"), task.get("contextId")

That tuple - taskId plus contextId - is the entire durable state of the handoff. Persist it immediately (database, queue, workflow engine): it is your only handle on work that now lives somewhere else. Everything else - results, questions, intermediate status - will be fetched or pushed against these two identifiers.

Do not retry by re-sending the original message blindly; SendMessage semantics make a repeated message a new task or a continued one depending on the ids you pass. Retries are for transport failures before you received a task id; after that, idempotency means working with what you got.

Pattern 2: Stay Informed Without Staying Connected

Hands-off means your process is free - but you still need updates. A2A offers three delivery strategies, and the receiving agent’s Agent Card tells you which are available (capabilities.streaming, capabilities.pushNotifications):

Poll (GetTask) - always available, right for minutes-scale work:

import asyncio

TERMINAL = {"TASK_STATE_COMPLETED", "TASK_STATE_FAILED",
            "TASK_STATE_CANCELED", "TASK_STATE_REJECTED"}

async def poll_until_done(task_id: str, token: str,
                          interval: float = 5.0, max_minutes: int = 120) -> dict:
    headers = {"Authorization": f"Bearer {token}"}
    async with httpx.AsyncClient(timeout=30) as client:
        for _ in range(int(max_minutes * 60 / interval)):
            r = await client.post(RPC, headers=headers, json={
                "jsonrpc": "2.0", "id": "p", "method": "GetTask",
                "params": {"id": task_id}})
            task = r.json()["result"]
            state = task["status"]["state"]
            if state in TERMINAL or state in ("TASK_STATE_INPUT_REQUIRED",
                                              "TASK_STATE_AUTH_REQUIRED"):
                return task
            await asyncio.sleep(interval)
        raise TimeoutError("task did not finish in the polling budget")

Stream (SendStreamingMessage / SubscribeToTask) - right for minutes-scale work when your process will live that long. If the stream drops mid-task, the spec’s answer is SubscribeToTask on the same taskId - reattach, never restart.

Push notifications - the genuinely hands-off option for hours-scale work, and the one that lets your process exit entirely. The card must declare capabilities.pushNotifications: true:

async def register_webhook(task_id: str, token: str, webhook_url: str) -> None:
    payload = {
        "jsonrpc": "2.0", "id": "w", 
        "method": "CreateTaskPushNotificationConfig",
        "params": {
            "taskId": task_id,
            "pushNotificationConfig": {
                "url": webhook_url,
                "token": "per-task-secret-for-receiver-side-validation",
                "authentication": {
                    "schemes": {
                        "bearer": {"authorization": f"Bearer {token}"}
                    }
                },
            },
        },
    }
    async with httpx.AsyncClient(timeout=30) as client:
        r = await client.post(RPC, json=payload,
                              headers={"Authorization": f"Bearer {token}"})
        r.raise_for_status()

Your webhook then receives StreamResponse payloads (task, status-update, or artifact-update objects) on significant changes - terminal states, input-required, auth-required - and the correct response to each notification is to call GetTask for authoritative state, not to trust the notification body. Harden both sides per the spec: the server must not POST to untrusted URLs (allowlists, ownership verification, egress controls), must authenticate to your webhook, and you must verify sender JWTs against the server’s JWKS, reject stale timestamps, and guard replays.

Pattern 3: Checkpoints - The Handoff Can Come Back

Hands-off does not mean no contact ever. A2A defines two states where the receiving agent hands the ball back, and a production handoff design plans for both:

TASK_STATE_INPUT_REQUIRED - the specialist needs a clarification (a missing document, an ambiguous field). The status message carries the question. Your workflow’s move: surface it (to a human or your own agent), then continue the same task:

async def answer_checkpoint(task_id: str, context_id: str,
                            answer: str, token: str) -> None:
    payload = {
        "jsonrpc": "2.0", "id": "c",
        "method": "SendMessage",
        "params": {
            "message": {
                "role": "ROLE_USER",
                "task_id": task_id,          # same task - not a new one
                "context_id": context_id,    # same conversation
                "parts": [{"type": "text", "text": answer}],
            }
        },
    }
    ...

Omit those two ids and you have silently started a new conversation - the classic A2A integration bug, and an especially painful one when the specialist has already spent ten minutes of context.

TASK_STATE_AUTH_REQUIRED - the specialist needs your authorization (an OAuth token to call an API on your side, or approval for a consequential action). Same mechanics as input-required: supply the credential as a continuation on the same task, or deliver it out-of-band if the workflow is configured for that.

Design rule: encode both checkpoints as first-class states in your workflow engine, with owners and SLAs. A handoff that can stall forever at input-required is not a handoff; it is a lost ticket.

Pattern 4: Escalation and the Human Path

Enterprise handoffs fail in two directions - the remote agent fails, or it waits too long. Both need an explicit human path:

  • Failure is data. TASK_STATE_FAILED with a status message is the specialist reporting an outcome, not a transport error. Route it to a human queue with the task’s history attached; do not blind-retry the same message.
  • Timeouts escalate, they do not kill. When polling exhausts your budget, escalate with the taskId and a snapshot of GetTask state, then CancelTask only if the business process says the work is dead:
async def escalate_or_cancel(task_id: str, token: str, reason: str) -> str:
    task = await fetch_task(task_id, token)          # your GetTask wrapper
    if task["status"]["state"] not in TERMINAL | {"TASK_STATE_WORKING",
                                                  "TASK_STATE_SUBMITTED"}:
        return "already resolved"
    await page_human(task_id, task, reason)          # audit first
    if reason == "business_abort":
        await cancel_task(task_id, token)            # CancelTask
        return "canceled"
    return "escalated"                               # leave it running
  • Round-trip auditability. Because every unit of work is a task with a stable id, your side and the partner’s side can reconcile records: who delegated, when, in which state, with what outcome. Persist taskId, contextId, partner identity, state transitions, and artifact hashes. That record is your compliance evidence for “the agent handed off correctly.”

Putting It All Together: A Handoff Orchestrator

class Handoff:
    def __init__(self, rpc_url: str, token: str, webhook_url: str):
        self.rpc, self.token, self.webhook = rpc_url, token, webhook_url

    async def start(self, brief: str, metadata: dict) -> "Handoff":
        self.task_id, self.context_id = await delegate(self.token, brief, metadata)
        await save_handle(self.task_id, self.context_id)   # persist immediately
        if await supports_push(self.rpc):                  # from the Agent Card
            await register_webhook(self.task_id, self.token, self.webhook)
        return self

    async def wait(self) -> dict:
        task = await poll_until_done(self.task_id, self.token)
        while task["status"]["state"] in ("TASK_STATE_INPUT_REQUIRED",
                                          "TASK_STATE_AUTH_REQUIRED"):
            answer = await obtain_from_human_or_policy(task)  # checkpoint owner
            await answer_checkpoint(self.task_id, self.context_id,
                                    answer, self.token)
            task = await poll_until_done(self.task_id, self.token)
        await record_outcome(self.task_id, task)
        return task

start() returns in under a second; wait() can take hours; neither holds the remote agent’s connection hostage. The four patterns - durable handle, informed-without-connecting, planned checkpoints, explicit escalation - are all present.

Conclusion & Next Steps

Hands-off delegation succeeds when the handoff unit is durable, the notification path is explicit, the return checkpoints are designed, and the failure path has a human owner. A2A gives you each piece as protocol machinery: taskId/contextId as the handle, three delivery mechanisms for staying informed, input-required/auth-required as legitimate pauses, and CancelTask plus task history as the audit spine. What you bring is the operational discipline - persist handles before you disconnect, and never let a checkpoint stall without an owner.

Homework:

  • Convert one synchronous agent-to-agent call into fire-and-forget delegation with a persisted handle.
  • Implement the push-notification path end to end, including JWKS verification on your webhook.
  • Add escalation SLAs for input-required and prove a stalled checkpoint pages a human.

Sources: A2A Protocol repository (google/A2A), A2A Protocol Specification - Streaming, Push Notifications, Task Lifecycle, A2A Enterprise Features