A minimal example of Google ADK's A2A protocol: one agent delegates to another over HTTP. Uses Azure OpenAI or Gemini as the LLM.
Structured course content on the A2A protocol is in the docs/ folder:
git clone git@github.com:MSKazemi/ai-agent-systems-course.git
cd ai-agent-systems-course/A2AOr with HTTPS:
git clone https://github.com/MSKazemi/ai-agent-systems-course.git
cd ai-agent-systems-course/A2ACreate and activate a Python virtual environment:
python3 -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # WindowsInstall dependencies:
pip install -r requirements.txtcp .env.example .envEdit .env. For Azure OpenAI:
LLM_PROVIDER=azure
AZURE_OPENAI_API_KEY=<from Azure Portal → Keys and Endpoint>
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_VERSION=2024-08-01-preview
AZURE_PRIMARY_LLM_DEPLOYMENT_NAME=gpt-4o
For Gemini:
LLM_PROVIDER=gemini
GOOGLE_API_KEY=<from aistudio.google.com/apikey>
Terminal 1 — Math agent (port 8001):
source .venv/bin/activate # Linux/macOS
uvicorn remote_math_agent:a2a_app --host 127.0.0.1 --port 8001Terminal 2 — Prime agent (port 8003):
source .venv/bin/activate # Linux/macOS
uvicorn remote_prime_agent:a2a_app --host 127.0.0.1 --port 8003Terminal 3 — Coordinator (chat UI):
source .venv/bin/activate # Linux/macOS
adk web . --port 8002Open http://127.0.0.1:8002. Select coordinator or dynamic_coordinator, and try:
- "What is 17 + 23?" → delegates to math agent
- "Is 17 a prime number?" → delegates to prime agent
If you get 401 errors, test your credentials:
python verify_azure.py| Problem | Solution |
|---|---|
| No agents found | Run adk web from project root |
| Port in use | Use adk web . --port 8003 |
| Azure 401 | Regenerate key in Azure Portal, update .env |
| Remote unreachable | Start both uvicorn servers (8001, 8003) before adk web |
pip: cannot execute: required file not found |
Recreate venv (see below) |
Recreate broken venv:
deactivate
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate # Linux/macOS
pip install -r requirements.txt