* Python: Migrate agent-framework-a2a to a2a-sdk v1.0
Upgrade the a2a-sdk dependency from v0.3.x to v1.0.0 and migrate all
source, tests, samples, and documentation to the v1.0 API.
Key changes:
- Dependency: a2a-sdk>=1.0.0,<2 (was >=0.3.5,<0.3.24)
- Types are now protobuf-based: Part replaces TextPart/FilePart/DataPart
- Enums use SCREAMING_SNAKE_CASE (e.g. TaskState.TASK_STATE_COMPLETED)
- Roles: Role.ROLE_AGENT, Role.ROLE_USER
- Client: SendMessageRequest wrapper, subscribe() replaces resubscribe()
- Server: A2AStarletteApplication replaced by Starlette + route factories
- DefaultRequestHandler now requires agent_card parameter
- TaskUpdater: final parameter removed, add_artifact gains last_chunk
- AgentCard.url removed; use supported_interfaces with AgentInterface
- Stream yields StreamResponse with WhichOneof('payload')
Closes #5661
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review: validate fallback URL, remove unused task_id vars
- Raise ValueError with clear message when transport negotiation fails
and no fallback URL is available (neither url arg nor supported_interfaces)
- Remove unused task_id local in status_update branch
- Inline artifact_event.task_id directly in artifact_update branch
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A2A Agent Examples
This sample demonstrates how to host and consume agents using the A2A (Agent2Agent) protocol with the agent_framework package. There are three runnable entry points:
| Run this file | To... |
|---|---|
a2a_server.py |
Host an Agent Framework agent as an A2A-compliant server. |
agent_with_a2a.py |
Connect to an A2A server and send requests (non-streaming and streaming). |
a2a_agent_as_function_tools.py |
Convert A2A agent skills into function tools for a host agent. |
The remaining files are supporting modules used by the server:
| File | Description |
|---|---|
agent_framework_to_a2a.py |
Exposes an agent_framework agent as an A2A-compliant server. Demonstrates how to wrap an agent_framework agent and expose it as an A2A service that other A2A clients can discover and communicate with. |
agent_definitions.py |
Agent and AgentCard factory definitions for invoice, policy, and logistics agents. |
agent_executor.py |
Bridges the a2a-sdk AgentExecutor interface to Agent Framework agents. |
invoice_data.py |
Mock invoice data and tool functions for the invoice agent. |
a2a_server.http |
REST Client requests for testing the server directly from VS Code. |
Environment Variables
Make sure to set the following environment variables before running the examples:
Required (Server)
FOUNDRY_PROJECT_ENDPOINT— Your Azure AI Foundry project endpointFOUNDRY_MODEL— Model deployment name (e.g.gpt-4o)
Required (Client)
A2A_AGENT_HOST— URL of the A2A server (e.g.http://localhost:5001/)
Required (Function Tools Sample)
A2A_AGENT_HOST— URL of the A2A server (e.g.http://localhost:5000/)FOUNDRY_PROJECT_ENDPOINT— Your Azure AI Foundry project endpointFOUNDRY_MODEL— Model deployment name (e.g.gpt-4o)
Quick Start
All commands below should be run from this directory:
cd python/samples/04-hosting/a2a
0. Install Dependencies
Copy .env.example to .env and fill in your values:
copy .env.example .env
Option A — pip (standard):
python -m venv .venv
.venv\Scripts\Activate.ps1 # Windows
# source .venv/bin/activate # macOS / Linux
pip install -r requirements.txt
Option B — uv:
uv run python a2a_server.py --agent-type policy
1. Start the A2A Server
Note (Option A — pip users): Replace
uv run pythonwithpythonin alluv runcommands below (e.g.python a2a_server.py ...).uvis not required once the virtual environment is activated.
Pick an agent type and start the server (each in its own terminal):
uv run python a2a_server.py --agent-type invoice --port 5000
uv run python a2a_server.py --agent-type policy --port 5001
uv run python a2a_server.py --agent-type logistics --port 5002
You can run one agent or all three — each listens on its own port.
2. Run the A2A Client
In a separate terminal (from the same directory), point the client at a running server:
$env:A2A_AGENT_HOST = "http://localhost:5001/"
uv run python agent_with_a2a.py
# A2A server exposing an agent_framework agent
uv run python agent_framework_to_a2a.py
3. Run the Function Tools Sample
This sample resolves the remote agent's skills and registers each one as a function tool on a host Foundry-backed agent. The host agent then autonomously selects the right skill to handle the user's request.
$env:A2A_AGENT_HOST = "http://localhost:5000/"
uv run python a2a_agent_as_function_tools.py