This project demonstrates a simple Agent-to-Agent (A2A) workflow using the a2a-sdk. It implements a basic "Greeting Agent" server and a client to interact with it, showcasing how to build and consume agents using the A2A protocol.
- Greeting Agent: A simple agent that responds with a greeting message.
- A2A Server: Built using
starletteanduvicorn, exposing the agent via the A2A protocol. - A2A Client: A client script that discovers the agent via its Agent Card and sends a message.
- Modern Tooling: Uses
uvfor fast Python package and project management.
- Python 3.11 or higher
- uv
-
Clone the repository:
git clone <repository-url> cd a2a-workflow
-
Install dependencies using
uv:This project uses
uvto manage dependencies. Run the following command to create a virtual environment and install the required packages defined inpyproject.toml.uv sync
To see the agent in action, run the server in one terminal and the client in another.
The server hosts the "Greeting Agent" on http://localhost:9999.
Run the server using the module entry point:
uv run -m dummy_agentYou should see output indicating that uvicorn is running:
INFO: Started server process [...]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:9999 (Press CTRL+C to quit)
The client connects to the server, retrieves the Agent Card, and sends a test message.
Open a new terminal window and run:
uv run dummy_agent/client.pyExpected Output:
Agent Card {
"name": "Greeting Agent",
"description": "A simple agent that returns a greeting",
...
}
A2A Client Initialized
Response {
...
"content": "Hi Everyone! Welcome to AI with Devendra."
...
}
dummy_agent/: Contains the source code for the agent and client.__main__.py: The entry point for the server. Configures theAgentCard,AgentSkill, and starts theA2AStarletteApplication.agent_executor.py: Defines theGreetingAgentlogic and theGreetingAgentExecutorwhich handles the execution context.client.py: A client script that usesa2a.clientto communicate with the running agent.
main.py: A simple placeholder script.pyproject.toml: Project configuration and dependencies.
This project uses uv for dependency management.
-
Add a dependency:
uv add <package-name>
-
Run a script in the virtual environment:
uv run <script.py>
-
Update dependencies:
uv lock --upgrade