Python Examples
This page introduces the Python example code used to demonstrate the functionality of the A2A Protocol.
Code Structure
The example code is divided into three main subdirectories:
- Common: Contains common code used by all example Agents and applications for implementing A2A communication over HTTP.
- Agents: Contains example Agents written using various frameworks. These Agents perform example tasks and use tools. They all utilize the common
A2AServer
. - Hosts: Contains host applications that use the
A2AClient
. This includes:- A simple CLI (Command-Line Interface) demonstrating task completion with a single Agent.
- A Mesop Web application capable of communicating with multiple Agents.
- An orchestrator Agent that delegates tasks to multiple remote A2A Agents.
Prerequisites
- Python 3.13 or higher
- UV
Running the Examples
To run the examples, you need to start one (or more) Agent A2A servers and one host application.
The following example demonstrates running the LangGraph Agent and the Python CLI Host:
- Navigate to the directory: (Assuming you are in the repository root)
# Adjust this path according to your local code structure cd path/to/your/a2a-protocol/samples/python
- Run the Agent: (In one terminal window)
uv run agents/langgraph
- Run the Host: (In another terminal window)
uv run hosts/cli
Please consult the README files within the Agents
and Hosts
subdirectories for more information on available Agents and Hosts and their specific running instructions.