liveBook · Manning

A2A

As explained in Context Engineering

A2A is an open protocol standard for interoperability and context exchange between independent agentic applications.

A2A (agent-to-agent) is an open protocol for interoperability and context exchange between independent agentic applications. It supports capability discovery, modality negotiation, task lifecycle management, and artifact exchange across agents built with different frameworks or operated by different organizations. section 7.8.1

A client agent packages relevant context and delegates a task; a server agent processes it within its own isolated context and returns results. These are interaction roles, not permanent identities: an agent can receive work as a server and delegate a subtask as a client. A2A differs from MCP, which connects agents to external tools and data. section 7.8.1 section 4.4

A typical exchange follows these steps:

  • Discover an agent through its agent card, a JSON capability manifest that can describe interfaces, input and output modes, and skills. section 7.8.1
  • Select a supported interface and send a message containing the context needed for the delegated task, rather than the entire prompt history. section 7.8.1 section 7.9.6
  • Receive a task-shaped response and any structured artifacts; use task and context identifiers correctly when managing the interaction. section 7.9.6

Weather agent

A simplified client fetches a weather agent’s card, selects an interface, and sends a location in a message. A Flask server returns a completed task-shaped response with a weather artifact. The scaffold illustrates discovery and structured communication, but is not a conformant A2A implementation. section 7.9.6

Listing 7.8 A2A client logic for discovering a server agent and sending a message
agent_card_url = f"{SERVER_BASE_URL}/agent-card.json" #1
response = requests.get(agent_card_url)
response.raise_for_status()
agent_card = response.json()

interfaces = agent_card.get("supportedInterfaces", []) #2
if not interfaces:
    raise ValueError("Agent card does not declare a supported interface.")
message_endpoint = interfaces[0]["url"]

message_payload = { #3
    "message": {
        "messageId": str(uuid.uuid4()),
        "role": "ROLE_USER",
        "parts": [{"text": "Current weather. location: San Francisco, CA"}]
    },
    "configuration": {"acceptedOutputModes": ["text/plain"]}
}
headers = {"Content-Type": "application/a2a+json"}
message_response = requests.post(message_endpoint, json=message_payload,
headers=headers)
message_response.raise_for_status()
result_payload = message_response.json()

artifact = result_payload["task"]["artifacts"][0] #4
final_message = artifact["parts"][0]["text"]
print(f"Result: {final_message}")

Inspect the illustrative client’s card discovery, interface selection, and message submission. section 7.9.6

For production, consult the current specification: A2A continues to evolve. Use the binding selected from the card, validate capabilities, apply authentication, and support the interaction mechanism required by the task. The simplified scaffold omits these safeguards and features including streaming, polling, version negotiation, and the complete error model. section 7.8.1 section 7.9.6

How Context Engineering covers it

How deep it goes
Explains agent roles, cards, discovery, and task-oriented exchange, then demonstrates a simplified nonconformant client and server.
Examples
Uses travel-planning delegation and a weather-forecast client and server to illustrate context sharing.
What you can do after
Evaluate/understand agent discovery and task exchange, and identify production requirements omitted from a simplified implementation.
How it connects
Distinguishes agent-to-agent communication from MCP tool and data access and AG-UI client interaction.

Also explained in

Compare how 4 books explain A2A →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.