Skip to content
mentoor

Topic 1 of 5 · 5 min read

A2A agent cards, tasks and messages

Goal: Read an agent card and a task exchange and predict how a client agent will discover, call and follow up with the remote agent.

A2A (Agent2Agent) is an open protocol that lets one agent find another agent, send it work and follow that work to the end, without either side exposing its model, prompts or tools. The specification describes the agents as independent and potentially opaque. Think of it as HTTP-style plumbing for delegation.

Check yourself · 1 of 3

Where does the A2A specification say a client will usually find a public agent card?

Choose one answer

Why it matters

Once teams build agents in different frameworks, a custom adapter per pair does not scale. A client agent needs a standard way to answer three questions: who is out there, what can it do, and how do I hand it a job that may take minutes.

The four building blocks

  1. Agent card. A JSON document describing the agent: name, description, version, supported interfaces (URL and protocol binding), capabilities such as streaming and push notifications, skills, and the security schemes it accepts. By convention it is served at /.well-known/agent-card.json on the agent's domain. A client can also learn cards from a registry or from direct configuration.
  2. Message. One turn of communication with a role (user or agent) and a list of parts: text, a file, or structured data.
  3. Task. The unit of work with an id and a lifecycle. The remote agent may answer a simple request with a direct message, or open a task. States include submitted, working, input required, completed, failed, canceled and rejected; the last four are terminal.
  4. Artifact. The output of a task, also made of parts: a report, a file, a data set. Messages carry conversation; artifacts carry results.

For work that outlasts one HTTP request there are two update paths: streaming, where the client keeps a connection open and receives events, and push notifications, where the client registers a webhook and the agent calls it on changes. The client can always fetch the task again by id.

Before and after

{
  "name": "Invoice Agent",
  "description": "Checks supplier invoices against purchase orders",
  "supportedInterfaces": [
    { "url": "https://ap.example.com/a2a/v1", "protocolBinding": "HTTP+JSON", "protocolVersion": "1.0" }
  ],
  "capabilities": { "streaming": false, "pushNotifications": true },
  "version": "2.3.0"
}

A client reading this card should predict: no streaming, so a long job needs a webhook or polling; call the URL listed, in the listed binding. Treating this agent as a streaming one is the typical wrong guess. The card is the contract; check it before you write the call.

What goes wrong

  • Treating a task as a function call. A task can sit in input required or fail after minutes. Code that expects one response breaks.
  • Hard-coding a card. Capabilities and URLs change. Fetch the card, respect its version and cache it as the spec advises.
  • Ignoring terminal states. Sending a new message to a completed or failed task is an error; start a new task instead.
  • Assuming the card is proof. It is a self-description. The trust topic covers verifying it.

Examples

Reading a card before calling

A card lists "streaming": false and "pushNotifications": true. The client agent therefore sends the request, stores the task id, registers its webhook URL and returns to its own work. It does not hold a connection open waiting for events, because this agent does not offer them.

A task that needs more input

A client asks a travel agent to book a flight. The task moves to input required with a message: "Which of the two Tuesday departures?" The client answers by sending a new message on the same task id, and the task returns to working. Sending a fresh unrelated request would lose the context.

Key points

  • An agent card is the remote agent's self-description: interfaces, capabilities, skills and security schemes, usually served at a well-known URL.
  • A message carries one conversational turn as parts (text, file or data); a task carries the lifecycle of a unit of work.
  • Completed, failed, canceled and rejected are terminal task states; no further messages can be sent to that task.
  • Results of a task come back as artifacts, separate from the conversational messages.
  • Long work is followed by streaming, by a registered push-notification webhook, or by fetching the task again by id.

Common mistakes

  • Writing the client as if every call returns a final answer, with no handling for working, input required or failed.
  • Copying an agent card's URL into code instead of discovering the card, so a moved endpoint breaks the integration.
  • Sending follow-up messages to a task that has reached a terminal state.
  • Confusing artifacts with messages and parsing results out of chat text.

Check yourself · 2 of 3

A client sends a message to a remote agent and later gets a task whose state is completed. What is the right way to ask a follow-up question?

Choose one answer

Check yourself · 3 of 3

An agent card says streaming is false and push notifications are true. How should a client follow a long job?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic