mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
f48c4512d3
* updated automation tasks and commands, with alias for the time being * Restore aggregate test exclusions Preserve the legacy all-tests scope for test --all by excluding lab and devui from the default aggregate sweep, while still allowing explicit package selection. Also ignore hidden/generated test directories such as .mypy_cache during aggregate discovery. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * updated versions in pre-commit --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f48c4512d3
·
2026-03-18 18:39:11 +00:00
History
A2A Agent Examples
This sample demonstrates how to host and consume agents using the A2A (Agent2Agent) protocol with the agent_framework package. There are two 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). |
The remaining files are supporting modules used by the server:
| File | Description |
|---|---|
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)
AZURE_AI_PROJECT_ENDPOINT— Your Azure AI Foundry project endpointAZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME— Model deployment name (e.g.gpt-4o)
Required (Client)
A2A_AGENT_HOST— URL of the A2A server (e.g.http://localhost:5001/)
Quick Start
All commands below should be run from this directory:
cd python/samples/04-hosting/a2a
1. Start the A2A Server
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