# A2A: How Agents Talk to Agents

This lesson starts with one example. A Trip Planner agent hands a currency job to a Currency Agent.
It then covers Google's open A2A protocol (v1.0) and Meta's internal A2A platform.

## Open the slides

Open `index.html` in a browser. Use the arrow keys or the buttons at the bottom.
Choose "Read all" to read every slide on one long page.

## Run the code

Use Python 3.11 or newer. Start inside the `a2a` folder.

```sh
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
```

The raw lab needs no install at all. It uses only the standard library.

```sh
# Terminal 1: the from-scratch agent
python src/a2a_lab/raw_server.py --port 9999

# Terminal 2: the same agent on the official SDK
python src/a2a_lab/sdk_server.py --port 10000

# Terminal 3: the clients
python src/a2a_lab/raw_client.py --url http://localhost:9999 --wire
python src/a2a_lab/sdk_client.py http://localhost:9999 http://localhost:10000
```

Add `--wire` to the raw client to print every JSON payload it sends and gets back.

## Run the tests

```sh
python -m unittest discover -s tests -v
```

There are 13 tests. One test checks that the raw client works with the SDK server.
It is skipped when `a2a-sdk` is not installed.

## What each file does

- `src/a2a_lab/currency_rules.py` is the agent's brain. It uses fixed rates, so answers are exact.
- `src/a2a_lab/raw_server.py` is an A2A server built with only the standard library.
- `src/a2a_lab/raw_client.py` is an A2A client built with only the standard library.
- `src/a2a_lab/sdk_server.py` is the same agent on `a2a-sdk` 1.3.0.
- `src/a2a_lab/sdk_client.py` asks both servers the same question at once.
- `discovery/` shows how agents find agents. Start with `discovery/README.md`.
- `diagrams/*.dot` are the Graphviz sources for every diagram.

## Rebuild the deck and diagrams

The deck pulls its code snippets from `src/` when you build it.

```sh
python build_deck.py
python diagrams/gen_sequence.py
npm install @viz-js/viz@3      # Graphviz compiled to WASM, no system install
node diagrams/render.mjs
```

## Notes

- The rates are teaching values, not live rates.
- Meta facts come from internal docs as of 2026-11-13. The platform wiki is still a draft.
