Agent-to-Agent Protocols
Learn how the A2A protocol standardizes agent discovery, task identity, typed artifacts, and lifecycle to make multi-agent delegation reliable.
Language AI HandbookAll chapters Agent-to-Agent Protocols
A caller sends a task to another service and gets a timeout. Should it send the request again? The caller may have lost the response after the other service accepted the work. Without a shared way to identify the request and check its status, a retry can start a duplicate job.
This chapter uses the A2A protocol specification v1.0.0, released on 12 March 2026. It pins the normative schema to v1.0.1, whose release notes describe the May 2026 patch. The version on a compatible interface is 1.0. The in-memory example lets us observe status, artifacts, a retry, and both orders of a cancel racing a completion.
The Agent-to-Agent Protocol is an open specification for communication between independent, opaque AI agents. It defines agent discovery via an "Agent Card" served at a well-known URL, message exchange through bindings including JSON-RPC, gRPC, and HTTP+JSON, a task lifecycle with streamed or polled status updates, and typed results delivered as artifacts. The protocol is transport-focused: it standardizes how agents exchange tasks, not how any individual agent thinks.
Why agents need a protocol at all
Before the mechanics, it is worth being precise about what breaks without a protocol. Suppose agent A wants agent B to do some work. The naive approach is for A to call B's HTTP endpoint with a natural-language instruction and get natural-language text back. This works in a demo. In production it produces a specific and predictable set of failures. Naming those failures precisely matters, because each one is the direct motivation for a specific piece of the protocol. When you see the discovery document later, or the task identifier, or the terminal-state model, you should recognize it as the remedy for one of these four diseases.
The first failure is capability ambiguity. A does not know what B is good at, what its limits are, or what input formats it accepts. Without a description, A must either be hand-wired to B (defeating the point of interoperability) or guess by probing B with sample requests (wasteful and error-prone). A protocol that mandates a discovery document lets A decide, programmatically, whether B is the right agent for a job before sending it work. In a world of two agents, hand-wiring is fine. In a world where an orchestrator has dozens of potential delegates from many vendors, guessing is untenable: every probe costs a network round trip and a possibly expensive model invocation, and every wrong guess wastes work on the wrong agent.
The second failure is task identity and correlation. If A sends B ten instructions in rapid succession, or retries a request that timed out, or B replies asynchronously an hour later, there is no reliable way to match responses to requests. A protocol assigns each task a stable identifier and requires responses to reference it. This is what makes retries, streaming, and long-horizon work possible at all. Without a correlation key, a retried request can silently duplicate work: B receives what it believes are two independent instructions and executes both, and A has no way to tell that the two results descend from a single intent.
The third failure is result structure. A natural-language reply must be parsed, and parsing free text is exactly the fragile operation that motivated structured tool calls in Function Calling. A2A artifacts carry typed parts such as text, a file, or structured data. The wire format defines those part types. The calling application still checks whether a result has the expected media type and content, including any schema it requires.
The fourth and most serious failure is disagreement about outcome. Did the task succeed? Is it still running? Was it canceled before it produced anything, or canceled after producing a partial result that is now stale? Without a shared lifecycle model, agent A and agent B can hold inconsistent beliefs about a single task indefinitely. Think about how costly that is: a caller waiting forever on a task it believes is still running while the agent has long since discarded it, or a caller treating a partial artifact as final because it never received a clean completion signal. The A2A lifecycle exists precisely to make "what state is this task in" a question with one answer that both sides agree on.
These four failures (capability, identity, structure, and outcome) map directly onto the four pillars of any serious A2A protocol: discovery, task references, artifacts, and lifecycle with terminal states. Everything else is elaboration. Keeping this mapping in mind is useful throughout the chapter: every section that follows is, in effect, the detailed answer to one of these four questions.
The mapping between the four failures and the four pillars is worth seeing at a glance, because the rest of the chapter elaborates one pillar at a time.
VisualizationOut [4]Expand

The Model Context Protocol, briefly, and why A2A is different
The previous chapter, Model Context Protocol, described how a single LLM application connects to external tools, resources such as files, and prompts. MCP is a client-server protocol between a model host and its environment. It solves "how does this agent reach its tools and context?"
A2A solves a different problem: "how does this agent delegate a whole task to another agent?" The distinction is not academic. It shows up in the shape of the protocol, in the failure modes it must handle, and in the trust relationships it presumes.
The MCP specification dated 25 November 2025 gives a model application access to tools, resources and prompts. MCP also has experimental task augmentation in that revision for deferred operation results. The dividing line is which interface you are using. A2A exposes an agent with advertised skills and its own task exchange. A worker can use MCP on its side without exposing those client connections to the agent that delegated the work.
Discovery: the Agent Card
A caller needs to know what a peer claims to do, how to reach it, and what formats and authentication it expects. The v1 Agent Card and discovery sections describe the public well-known URI /.well-known/agent-card.json, along with discovery through registries or direct exchange. The card is JSON metadata. Treat it as an input to selection, alongside your own policy for which agents to trust and what data may cross the boundary.
supportedInterfacesdeclares the endpoint URL, the transport binding and the protocol version for each interface. Choose compatible values from the same interface entry. The card'sversiondescribes the agent, while an interface version such as1.0describes the protocol.capabilitiesadvertises optional features such as streaming, push notifications and extended Agent Card support.capabilities.extendedAgentCardadvertises support for the authenticated operation. A client still needs authorization to retrieve it.defaultInputModesanddefaultOutputModesdescribe media types. The modes listed for a skill can override the defaults. Check that the caller has a parser for the expected deliverable before delegating.skillsidentify work the agent advertises. A description and examples help an application select a skill, but the name alone does not establish that two services use the same result schema.securitySchemesdescribe available authentication mechanisms. Security requirements identify the schemes and scopes that apply. The server still enforces authorization on the request and the relevant task.
Discovery has a different role from authorization. For a sensitive request, verify the endpoint identity using trusted configuration and confirm that the authenticated peer may handle the data. Matching a skill's words only checks that the card advertises the capability. A legitimate certificate or card signature binds an identity or document to a key. It does not test how well the service performs the work.
If the caller selects among many candidates, a registry can keep verified entries and cache them according to policy. Make the selection inspectable by recording the card and interface version used when the task was delegated. Keep that record separate from proof that an individual task was authorized and correctly completed.
The task lifecycle
A Task is a server-side lifecycle record with a server-generated id, a contextId shared by related interactions, and a typed status. If the server chooses to return a task when a message is sent, the client uses that assigned ID with subsequent operations. The v1.0.1 normative TaskState enum covers submitted, working, completed, failed, canceled, rejected, input-required, and auth-required states. Submitted marks an acknowledged task, and working means active processing. input-required and auth-required are interruptions. The task can continue once the required input or authentication is available. Completed, failed, canceled, and rejected are terminal. The enum also reserves an unspecified value, which a caller should not interpret as successful completion.
A status update can carry a message, for example a clarification. The deliverable belongs in artifacts when the protocol returns a Task. An artifact carries typed parts such as inline text, a file, or structured data. An intermediate artifact can arrive while the task is working. Likewise, a final status confirms the lifecycle outcome while the application separately checks that the required result validates. A status event and an artifact update answer different questions about the same task.
Use GetTask to poll and reconcile by ID. If streaming is supported, SubscribeToTask returns the current Task first, then status and artifact updates. The subscription section states that a stream for the task closes when the task becomes terminal and that a subscription to an already terminal task is unsupported. If a disconnected client misses events, read the task snapshot and reconcile the available artifacts. Push notifications are another delivery mechanism, conditional on advertised support and configuration.
A long-horizon caller needs to decide how long it will wait for an interruption, how it will obtain the next input, and what it will report if it reaches its deadline before the remote state can be confirmed. When the connection drops, mark the observation as unknown until it can be checked. A transport failure is not a task state.
Delegation message shape
The v1 Send Message operation accepts a message with an ID, role, and typed parts. A message can include a taskId for an existing task or a contextId for related interactions. The receiving agent may give back a direct Message or create and return a Task. Omitting taskId does not force task creation. When a known task asks for more input, the client sends a new message referring to the same task and context, then follows its status again.
Match the operation names to the advertised binding. The normative v1.0.1 schema maps HTTP+JSON submission to /message:send and streaming submission to /message:stream. A SendStreamingMessage call can yield a single direct Message, or a task snapshot followed by task events. For that second form, the caller keeps the task ID so it can reconcile after interruption. Prefer a bounded wait to holding the connection open indefinitely.
The status event can report that work paused or finished, while the artifact update carries content. If the application expects a structured summary, it should validate the structure regardless of whether it sees that summary in a direct message or in a task artifact.
Idempotency and correlation
An initial send can time out after the server processes it. The client may not yet know the server-generated task ID. Section 3.3.1 permits idempotent sends using the message ID to detect duplicates. It does not guarantee that all agents deduplicate all sends. Confirm the peer's behavior before retrying requests whose effects matter. A taskId refers to already existing work and is not an initial-create idempotency key.
Give correlated identifiers separate jobs. A new message carries the sender's identifier. A returned task has a server-generated identifier. A context can thread related messages or tasks. Record all three when present, so a lost response can be reconciled with the server rather than interpreted as a fresh request. The example below includes an explicit local message-ID deduplication policy. It returns the existing task for the same message and rejects different content under the same ID.
Chunk delivery introduces a different problem. Task artifact events carry an artifact, a flag for appending to an existing artifact, and a flag for a last chunk. Artifact identity groups updates belonging to one deliverable. It does not itself distinguish two valid appends from a replay of the same append. Use the task snapshot on reconnection, unless the implementation provides a separately documented replay and ordering contract. Check that applying a duplicate delivery cannot duplicate downstream side effects.
GetTask reads an existing task and is idempotent. Repeated CancelTask requests aim for the same effect, though the response can differ once the task has ended or been purged. Keep a distinction between the effect of an operation and whether the server must return the same response on retry.
Cancellation and the cancel-before-completion race
The Cancel Task operation asks the server to stop an ongoing task. It can return the updated task or an error such as TaskNotCancelableError. The server may be unable to cancel work that has already completed or reached a point where cancellation is unavailable. A client can use GetTask to check the resulting state when an acknowledgment is lost or the cancel loses the race.
The example serializes two actions on an in-memory worker. When completion commits first, a later cancel leaves the completed task and its artifact intact. When cancel commits first, the worker does not publish a later artifact. This first-terminal rule is our local state-machine policy. The network protocol does not revoke an external side effect another service already committed. A production caller needs that service's operation status or its documented rollback policy before making a promise about the outside effect.
VisualizationOut [6]Expand

The resolution, completed, is what both sides must record. The caller's application logic, seeing completed, proceeds as if the cancel never happened. A caller that instead assumed "I sent cancel, so it's dead" would be wrong, and if the completed task had side effects, dangerously wrong. The safest client pattern is: after issuing a cancel, read the updated task or reconcile with a subsequent GetTask result within a bounded observation period.
Interoperability: vocabulary, versioning, and the opaque-agent boundary
Two agents from different vendors interoperating is not just a matter of matching byte formats. Three softer problems determine whether the protocol actually works in practice.
The first is semantic interoperability of skills. Two agents might both advertise a skill called "summarize," but one summarizes to 3 sentences and the other to a full abstract, one preserves a target reading level and the other does not, one counts tokens and the other counts characters. The protocol does not fix this; it gives you a description field and examples, and the rest is up to skill authors to write richly and callers to match carefully. This is why the specification's skill object includes free-text description and examples rather than only structured parameters: the semantics of a skill are inherently linguistic, and the matching is, at root, the same problem as Semantic Parsing and Meaning Representations at the boundary of systems. In practice, organizations that need high assurance write richer descriptions with explicit constraints (input length, output format, latency budget, example inputs and outputs) and rely on those constraints rather than on the skill name alone.
Use the v1 version negotiation rules. A matching interface advertises the major and minor protocol version. Patch numbers identify documentation and schema snapshots and stay out of version negotiation. Send the selected version as the A2A-Version service parameter on requests. For HTTP, use a header such as A2A-Version: 1.0. The pinned rules treat an empty value as 0.3 and require VersionNotSupportedError when the interface cannot serve the requested version. Inspect the capabilities of the selected interface.
The third is the opaque-agent boundary. A2A can exchange messages and task data without requiring the remote agent to expose its reasoning, tool calls or memory. A particular service can choose to supply additional diagnostics. This is a feature, since it lets agents from different vendors cooperate without leaking internals, but it means the caller cannot diagnose a failure by looking inside. When a remote agent reaches failed, it may include an error message, but that message is the agent's own account, and it may be terse, wrong, or missing. Composing reliable multi-agent systems therefore requires treating the remote agent's failure reports as untrusted, and building local observability (deadlines, heartbeat checks, artifact schema validation) on top of the protocol. This observability is local in two senses: it lives on the caller's side, and it observes only what the protocol exposes (lifecycle and artifacts) rather than the interior of the remote agent. We revisit robust evaluation of long-horizon work in Long-Horizon Agent Evaluation, the next-but-one chapter.
Verify the card against the peer identity. Check the source and task ID of lifecycle events. Before using an artifact, check its media type and contents against the application’s requirements.
VisualizationOut [7]Expand

A worked example: an in-memory cooperative task exchange
A local summarizer accepts a note in text form. It pauses to ask which format the caller wants, then the worker advances explicitly one step at a time. This lets us control the order of cancellation and completion without relying on clocks or network delays. The model of the worker is a finite state machine. Its results use immutable dataclasses so snapshots and events saved earlier remain valid when the worker changes state. The class interfaces are Python fixtures and are not serialized as A2A wire messages.
PythonIn [8]Expand
from dataclasses import dataclass, replace
from enum import Enum
from typing import Literal
class State(str, Enum):
SUBMITTED = "submitted"
INPUT_REQUIRED = "input-required"
WORKING = "working"
COMPLETED = "completed"
CANCELED = "canceled"
TERMINAL = {State.COMPLETED, State.CANCELED}
Format = Literal["text/plain", "application/json"]PythonIn [9]Expand
@dataclass(frozen=True)
class Skill:
skill_id: str
input_mode: str
output_modes: tuple[Format, ...]
@dataclass(frozen=True)
class Card:
name: str
skills: tuple[Skill, ...]
@dataclass(frozen=True)
class Submission:
message_id: str
skill_id: str
note: str
@dataclass(frozen=True)
class Summary:
text: str
word_count: int
@dataclass(frozen=True)
class Artifact:
artifact_id: str
media_type: Format
content: str | SummaryPythonIn [10]Expand
@dataclass(frozen=True)
class Task:
task_id: str
context_id: str
state: State
submitted: Submission
question: str | None = None
output_format: Format | None = None
artifacts: tuple[Artifact, ...] = ()
@dataclass(frozen=True)
class StatusEvent:
task_id: str
state: State
question: str | None
@dataclass(frozen=True)
class ArtifactEvent:
task_id: str
artifact: ArtifactThe card advertises the shapes we know how to handle. A Submission is the first caller message, with its own identifier. Task represents the remote record, with a different identifier. StatusEvent may carry a question. ArtifactEvent carries a typed piece of output. In this local fixture a structured summary is a Python object, not a string containing JSON. The Internet-facing interface would need a binding that serializes the equivalent data.
The remote agent: discovery and task handling
The worker keeps a map from accepted message IDs to tasks. This mock has one caller. A production service may have to scope those keys to an authenticated client or tenant. Putting the task ID and initial message ID in separate fields lets the caller replay an initial send even when the first response was lost. On a replay with changed contents, the original task remains unchanged and the worker raises an error.
The worker accepts three explicitly ordered steps in this fixture. request_format moves a submitted task to an interruption. answer accepts a supported format and moves it to working. finish publishes one artifact before storing the completed state. Keeping answer and finish distinct leaves a real working state in which cancellation can win. A status read by itself has no effect on the work.
PythonIn [11]Expand
class Worker:
def __init__(self, card: Card) -> None:
self.card = card
self.tasks: dict[str, Task] = {}
self.message_to_task: dict[str, str] = {}
self.events: list[StatusEvent | ArtifactEvent] = []
self.sequence = 0
def commit(self, task: Task) -> Task:
self.tasks[task.task_id] = task
self.events.append(StatusEvent(task.task_id, task.state, task.question))
return task
def get(self, task_id: str) -> Task:
return self.tasks[task_id]
def submit(self, message: Submission) -> Task:
existing_id = self.message_to_task.get(message.message_id)
if existing_id is not None:
existing = self.get(existing_id)
if message != existing.submitted:
raise ValueError("message ID reused with different contents")
return existing
if not any(
skill.skill_id == message.skill_id for skill in self.card.skills
):
raise ValueError("skill is not advertised")
self.sequence += 1
task = Task(
f"task-{self.sequence}",
f"context-{self.sequence}",
State.SUBMITTED,
message,
)
self.message_to_task[message.message_id] = task.task_id
return self.commit(task)
def request_format(self, task_id: str) -> Task:
task = self.get(task_id)
if task.state is not State.SUBMITTED:
return task
question = "Return a short text note or a structured summary?"
return self.commit(
replace(task, state=State.INPUT_REQUIRED, question=question)
)
def answer(self, task_id: str, output_format: Format) -> Task:
task = self.get(task_id)
if task.state in TERMINAL:
return task
if task.state is not State.INPUT_REQUIRED:
raise ValueError("task is not waiting for an answer")
skill = next(
s for s in self.card.skills if s.skill_id == task.submitted.skill_id
)
if output_format not in skill.output_modes:
raise ValueError("format is not advertised for this skill")
return self.commit(
replace(
task,
state=State.WORKING,
question=None,
output_format=output_format,
)
)
def finish(self, task_id: str) -> Task:
task = self.get(task_id)
if task.state is not State.WORKING:
return task
words = task.submitted.note.split()
short = " ".join(words[:4])
output_format = task.output_format
assert output_format is not None
body = (
Summary(short, len(words))
if output_format == "application/json"
else short
)
artifact = Artifact(f"result-{task_id}", output_format, body)
self.events.append(ArtifactEvent(task_id, artifact))
return self.commit(
replace(task, state=State.COMPLETED, artifacts=(artifact,))
)
def cancel(self, task_id: str) -> Task:
task = self.get(task_id)
if task.state in TERMINAL:
return task
return self.commit(replace(task, state=State.CANCELED, question=None))The separate event types make a useful invariant testable. The event log records publication of the result before the terminal status for this worker. Readers can check at the same time that canceled work has no new output and that terminal snapshots do not change. The implementation makes these updates in one process with sequential operations. A concurrent production service would need to protect the state transition and result publication together against other workers or persist both with a defined recovery rule.
The caller agent: discovery, delegation, and draining
Selection in this mock uses an exact skill ID plus input and output media types. It fails before submission when the caller cannot find a match. This demonstrates a contract check without pretending to establish the quality of the remote summarizer. The caller keeps the assigned task ID, polls the worker, and answers the one question needed by this policy.
PythonIn [12]Expand
def choose_skill(
card: Card, skill_id: str, input_mode: str, output_mode: Format
) -> Skill:
for skill in card.skills:
if (
skill.skill_id == skill_id
and skill.input_mode == input_mode
and output_mode in skill.output_modes
):
return skill
raise LookupError("no matching skill and media-type combination")PythonIn [13]Expand
def observe_until_terminal(
worker: Worker, task_id: str, output_format: Format, max_checks: int = 4
) -> Task:
for _ in range(max_checks):
current = worker.get(task_id)
if current.state in TERMINAL:
return current
if current.state is State.SUBMITTED:
worker.request_format(task_id)
elif current.state is State.INPUT_REQUIRED:
worker.answer(task_id, output_format)
elif current.state is State.WORKING:
worker.finish(task_id)
raise TimeoutError("the caller exhausted its local observation budget")Driving the mock worker from the caller's loop makes the example deterministic. In a deployed system the worker would progress separately, while a client polls or subscribes and sends a follow-up when needed. Here the budget counts reads. In the happy path the loop makes three progress operations and then one final read that observes completion. A budget of four permits those four reads, while a budget of one only observes the initial submitted snapshot before asking for the format. Reaching that budget reports a local timeout and does not silently assign a remote failure or cancel the task. That distinction also gives tests a way to inspect the unfinished state.
Running the happy path
We have the note “New reading room opens next Monday after inspection.” The first four words make a deterministic summary. Counting all words gives the structured artifact one additional field. A real summarization agent would use a model or another policy and need its own quality checks. The notebook checks this simple policy end to end so that delivery and state transitions are easy to verify.
PythonIn [14]Expand
card = Card(
"Notebook summarizer",
(Skill("summarize", "text/plain", ("text/plain", "application/json")),),
)
chosen = choose_skill(card, "summarize", "text/plain", "application/json")
message = Submission(
"message-1",
chosen.skill_id,
"New reading room opens next Monday after inspection.",
)
happy = Worker(card)
initial = happy.submit(message)
completed = observe_until_terminal(happy, initial.task_id, "application/json")
assert initial.state is State.SUBMITTED
assert completed.state is State.COMPLETED
assert completed.artifacts[0].content == Summary("New reading room opens", 8)
assert isinstance(happy.events[-2], ArtifactEvent)
assert isinstance(happy.events[-1], StatusEvent)ConsoleOut [15]Expand
Matched skill: summarize Task and context: task-1 context-1 Status events: ['submitted', 'input-required', 'working', 'completed'] Artifact media type: application/json Artifact content: Summary(text='New reading room opens', word_count=8)
The ordering of the worker's log shows the interruption and the later working and completed states. The returned structured summary is a separate value. Its contents could be wrong even when the worker accurately reports that it finished. In a production integration validate the shape and the result's suitability for the application.
Idempotent retry
Send the same message twice and check that the worker stores a single task. The response to the first send and second send can differ if work progressed in between. The promise is that they refer to the same task, and that retry does not submit work again. The assertion compares ID and number of state changes rather than relying on Python object identity.
PythonIn [16]Expand
retry_worker = Worker(card)
first = retry_worker.submit(message)
retry_worker.request_format(first.task_id)
second = retry_worker.submit(message)
assert first.task_id == second.task_id
assert first.state is State.SUBMITTED and second.state is State.INPUT_REQUIRED
assert len(retry_worker.tasks) == 1 and len(retry_worker.events) == 2
try:
retry_worker.submit(replace(message, note="Different content"))
except ValueError as conflict:
conflict_message = str(conflict)
else:
raise AssertionError("a changed request cannot reuse the same ID")
new = retry_worker.submit(replace(message, message_id="message-2"))
assert new.task_id != first.task_id and new.context_id != first.context_idConsoleOut [17]Expand
Retry refers to: task-1 task-1 Latest state on retry: input-required Conflicting reuse: message ID reused with different contents A fresh message starts: task-2 context-2
A different message identifier starts separate work in this fixture even if the note text is identical. It also gets a distinct context here because the mock has no multi-task conversation. The real protocol distinguishes context identity from task identity and permits related tasks to share one context. In this implementation only the initial local submit is deduplicated, and its mapping is process memory. A restart or another worker would require a shared durable idempotency policy to offer the same guarantee.
The cancel race, deterministically
In both cases the worker enters working before the race. First run the worker to completion and request a late cancel. Then cancel the working task in a fresh worker and try to finish it afterward. Both sequences use the same policy and the same input. Only the order of the two terminal operations differs.
PythonIn [18]Expand
def working_task() -> tuple[Worker, str]:
worker = Worker(card)
task_id = worker.submit(message).task_id
worker.request_format(task_id)
worker.answer(task_id, "application/json")
return worker, task_id
finish_first, a_id = working_task()
first_finished = finish_first.finish(a_id)
a_final = finish_first.cancel(a_id)
cancel_first, b_id = working_task()
first_canceled = cancel_first.cancel(b_id)
b_final = cancel_first.finish(b_id)
assert a_final == first_finished and a_final.state is State.COMPLETED
assert b_final == first_canceled and b_final.state is State.CANCELED
assert len(a_final.artifacts) == 1 and b_final.artifacts == ()
assert all(
not isinstance(event, ArtifactEvent) for event in cancel_first.events
)
assert cancel_first.answer(b_id, "text/plain") == b_finalPythonIn [19]Expand
limited = Worker(card)
limited_id = limited.submit(message).task_id
try:
observe_until_terminal(
limited, limited_id, "application/json", max_checks=1
)
except TimeoutError as expiry:
limit_message = str(expiry)
else:
raise AssertionError("one observation cannot complete the fixture")
assert limited.get(limited_id).state is State.INPUT_REQUIREDConsoleOut [20]Expand
Completion commits first: completed 1 artifact Cancel commits first: canceled 0 artifacts Local deadline: the caller exhausted its local observation budget Remote state remains: input-required
A late operation returns the saved terminal state in this mock. The versioned A2A cancel operation can return a not-cancelable error instead, so a real client reconciles with the authoritative task state. The last printed case distinguishes the local observation budget from the remote task state. It lets the caller stop waiting without claiming the remote work has ended.
Protocol-driven delegation at a larger scale
The mocked exchange above is small, but the shapes generalize. A production A2A client typically layers three things on top of the protocol's raw operations:
-
A discovery cache and registry. Fetching Agent Cards on every delegation is wasteful and fragile. Clients cache verified cards with a TTL, and may consult a registry that indexes many cards, filtering by skill tags before fetching individual cards. This mirrors how retrieval pipelines cache embeddings. The cache is not merely a performance optimization: it also lets a client hold a curated set of known-good cards and treat "unknown" agents as a higher-trust barrier than "known but stale" ones.
-
A task manager with deadlines. Every submitted task gets a client-side deadline. If the deadline passes while the task is still non-terminal, the client cancels (if cancellation is available) and either reports the unresolved delegation or escalates. This is how the "leaked non-terminal task" hazard is contained; the protocol will not enforce a deadline for you. Deadlines are the client's answer to the fact that non-terminal is not the same as in-progress: a task may sit in
input-requiredindefinitely if the caller never answers, and it may sit inworkingindefinitely if the agent hangs. Neither is the protocol's job to detect. -
An artifact validator. Check each artifact part against the application’s requirements. For structured data, validate against a schema when the application has one. A summarizer that returns
text/plainwhen the caller expectedapplication/jsonhas not fulfilled that application’s content contract. Catch that mismatch before passing it downstream. Validation is also the point at which a client can defend against a well-behaved-looking agent that quietly changes the shape of its output between revisions.
None of this is in the protocol, and that is by design. The spec standardizes the communication, not the client's policy. A mature A2A implementation is mostly the client's policy for discovery, deadlines, validation, and retry. This is worth naming explicitly because it is the conceptual shift that separates a demo integration from a production one: the protocol gives you a well-defined set of messages and invariants, then requires you to build a policy layer around them.
Reconcile a lost submission response
Suppose an analyst delegates a document summary, receives no response, and leaves the page open. The failure does not tell the analyst whether the worker saw the message. If the peer documents message-ID deduplication, retain the exact original message and resend it with the same message ID within the policy's retention window. If the worker already accepted it, the response may contain a different snapshot of the same task. Track identity separately from status. A working retry result for a previously submitted task can be a normal consequence of time passing.
When a peer has no documented idempotent send, a repeated submission can start a second task. The application should choose among waiting, consulting a separate operation record, or accepting the cost and effects of a duplicate. There is no general race-free read-then-create sequence: a separate check can return before the original submission becomes visible. The local mock demonstrates why a map checked and updated within one serialized worker is enough for its exact fixture. A replicated design requires a shared transaction or a unique key that survives process restart and is scoped to the right caller. The response itself need not be cached if the stable task relation can be looked up.
Keep the distinction between an accepted instruction and a completed effect in the status shown to the caller. If one component queues a report but a different worker writes it to a document store, publish completion only at the milestone stated in the application contract. If the contract defines completion as accepting the write, a separate confirmation may still be needed for the durable result. The right milestone depends on the work being delegated and what a user expects to see after success.
Rebuild the current view after a stream closes
A caller maintains a task view with the most recent observed state and a set of artifacts. An artifact update can arrive without a status change. For example, a worker can publish an initial draft and keep working on accessible formatting. If the connection breaks in between, cache the observed details as provisional and get the task snapshot on reconnect. Reconcile each available artifact with the authoritative task view. Distinguish an empty artifact collection from an inability to obtain the task, and distinguish both from an observed terminal failure.
Files and structured parts require different validation. Check the expected media type and shape before consuming a data object. When a result refers to a file, apply the application's permissions and size limits before fetching or opening it. Keep these checks attached to the result path: authenticating the server does not make every payload acceptable to the consuming application. A completed task can return a deliverable that fails the local schema. The remote lifecycle and client acceptance should therefore be displayed as separate states in logs and in recovery instructions.
A cancellation near completion illustrates the same separation. If a result exists and the task snapshot shows completed, a delayed cancel response does not by itself invalidate that artifact. If the task is canceled, any artifact published earlier must be interpreted according to the application's partial-result policy. The mock publishes only at completion, which keeps this assumption visible. Real implementations may stream intermediate work. They should tell the caller what survives cancellation so a partial result does not silently pass as final.
Decide which failures merit another attempt
Classify the observed failure before choosing a retry. A loss of connectivity leaves remote state unknown. A reported authorization failure calls for checking credentials and the actual task permission. A terminal task failure, by contrast, says the server considers this instance finished. A second attempt can be a separate task when you intend to rerun the work, or a lookup of the prior task when you only intend to recover its result. Carry the reason for that distinction into the operational log so a human can tell why there are two tasks for one document.
In an end-to-end integration test, force a lost response after the first submit, a disconnect between artifact and completion, a cancellation that wins before publication, and a cancellation that loses after it. Verify the final task ID and stored result in each case. Vary the order deliberately. Waiting for occasional real network failures rarely gives repeatable coverage of these cases.
Limitations and impact
A2A's most important contribution is conceptual: it turns "cooperate with another agent" from an integration project into a declared contract with a capability document, a task identifier, and a terminal-state model. That alone eliminates a large class of bugs. But the protocol's design choices also carry real limitations, and understanding them is what separates using a protocol from being used by it.
The deepest limitation is that a card is a claim, not a proof. Discovery standardizes how an agent describes itself, not whether that description is true. An agent can advertise a skill it implements poorly, or dishonestly. The specification lets cards be fetched over HTTPS and lets agents require authentication, and it supports an optional authenticated extended card that discloses more to trusted callers, but it does not solve the trust problem. In an open ecosystem, impersonation and skill-description poisoning are live threats. A caller that matches on skills and delegates sensitive work without independently verifying the agent's identity and competence is exposed. This is why the sibling security part, the later part on agentic AI and protocol security, treats card verification and skill poisoning as first-class. The honest summary is that A2A enables trust through identity metadata; it does not establish it.
A second limitation is semantic drift. As noted, two agents can use the same skill name for incompatible semantics. The protocol's description, examples, and tags are free text, and free-text matching is exactly the fragile operation that this book has been trying to engineer away from since tokenization. In practice, skill matching is either human-curated (you wire specific agents to specific jobs) or embedding-based (approximate and error-prone). There is no machine-checkable contract that says "this summarize skill means exactly the same thing as that one." For a system that insists on structured interfaces everywhere, this is a conspicuous soft spot at the discovery layer.
A third limitation is lifecycle discipline is the client's responsibility. The protocol defines terminal states and idempotency, but nothing forces a client to poll, to honor deadlines, to validate artifacts, or to handle the cancel race correctly. Every one of these is a place where a sloppy integration silently leaks tasks, duplicates side effects, or misreads a winner. The bounded loop and the decision to return the saved terminal task are local example policies. The v1 cancel operation can instead report that the target is no longer cancelable. This is normal for protocols (TCP does not make your application correct either) but it is worth being explicit that "A2A-compliant" says nothing about whether a client is robust.
A fourth limitation is the opaque-agent observability gap. Because the remote agent's internals are hidden, debugging a failed task means trusting an error message that may be sparse. Composition of many opaque agents magnifies this: an orchestrator that delegates to ten sub-agents and one fails can see that it failed, not why. Production systems compensate with structured error fields, correlation ids across hops, and local tracing, but the protocol itself provides no reasoning traces. This is a deliberate trade of transparency for interoperability, and it is often the right trade, but it means compound agent systems inherit a hard-to-diagnose failure mode.
The impact, notwithstanding these limits, is substantial. A2A standardizes the parts of multi-agent cooperation that can be standardized (discovery, task identity, lifecycle, artifact typing, cancellation semantics) and leaves the genuinely hard, context-dependent parts (trust, skill semantics, client policy) to be solved on top. That division is exactly right: you cannot standardize meaning, but you can standardize the envelope that carries it. For the enterprise agent ecosystems that motivated the protocol (a scheduling agent requesting work from a travel agent requesting work from a payment agent, each from a different vendor), having a shared envelope is the difference between integration-as-engineering and integration-as-adventure.
Summary
Agent-to-agent protocols address the four failures that plain HTTP-and-natural-language cannot: capability ambiguity (addressed by discovery), task identity (addressed by stable task IDs), result structure (addressed by typed artifacts), and outcome disagreement (addressed by a shared lifecycle). The A2A specification, pinned to a specific revision, standardizes each of these.
- Discovery centers on the Agent Card served at a well-known URL, listing skills (units of capability), capabilities (transport features like streaming and push notifications), input/output modes, and security schemes. Discovery is a programmatic decision over structured metadata, but the card is an untrusted claim.
- Delegation sends a message. The receiving agent can answer with a direct message or return a task. A returned task has an
id, acontextId, a state, and artifacts as they become available. Initial retry safety depends on a documented message-ID deduplication policy. - Lifecycle states include
submitted,working,input-required,auth-required,completed,failed,canceled, andrejected. Completion, failure, cancellation, and rejection are terminal. Input and authentication requirements are interruptions and may need a client response. - Status events vs. artifacts is a deliberate separation: status events report progress and outcome, artifacts carry deliverable content. An artifact arrival is not a completion signal; a terminal status is.
- Cancellation is a request, not a guarantee. A cancel can lose to completion. In the mock, the first terminal transition wins and later operations leave the stored task intact. A caller can stop waiting at its own deadline and report that the remote outcome is unresolved.
- Interoperability is limited by semantic drift in skill descriptions and by spec-version differences; pin your spec revision, check advertised capabilities, and validate artifacts against the application’s expected media and content.
- Client policy (caching verified cards, enforcing per-task deadlines, draining status until terminal, and validating artifacts) is where robustness actually lives, and it is the client's job, not the protocol's.
The working in-memory exchange made each of these concrete: an idempotent submit that returns the existing task on retry, a bounded observation loop that answers input-required, and a cancel race that resolves deterministically to whichever terminal transition commits first. Those invariants, more than any wire format, are what make long-horizon delegation between independent agents safe. The closely related problem of when a human must approve a delegation or a cancellation is the subject of the next chapter, Human Approval and Control Boundaries, and the question of whether a whole multi-agent protocol exchange actually solved the task is handled in Long-Horizon Agent Evaluation.
Quiz
Agent-to-Agent Protocols
Join the discussionAsk a question or share what you learned.
Keep exploring
Reference
Citation details
Cite or share this article.


Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!