Agent-to-Agent Protocols › Protocol-driven delegation at a larger scale
Language AI HandbookAll chapters 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.
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!