This project serves as a foundational "Hello World" example for developing agents using the Google Agent Development Kit (ADK) and the Agent-to-Agent (A2A) protocol. It demonstrates how to build a simple Python-based agent capable of interacting with external tools (like fetching weather and time information) and provides a comprehensive set of scripts for local development, testing, and deployment to Google Cloud Run. The primary goal is to offer a clear, runnable template for developers to quickly get started with ADK and A2A agent development, showcasing the power of inter-agent communication.
init.sh: Initializes the environment by prompting the user for their Google Cloud project ID and Gemini API Key. It also runsgcloud auth application-default loginto get user credentials.set_env.sh: Sets various environment variables required for the other scripts to run. It reads the project ID and Gemini key from the files created byinit.sh. This script also sets thePUBLIC_URLenvironment variable, which is used to configure the public URL for the agent.
These scripts facilitate running the agent in various modes and environments:
cli.sh/run.sh: Runs the agent in command-line mode, allowing you to interact with it from your terminal.run.shis an alias forcli.sh.local.sh: Runs the agent in a local web server, accessible typically athttp://localhost:8080.web.sh: Runs the agent in a local web server and automatically opens the UI in your default web browser.api_server.sh: Runs the agent in API server mode, exposing its functionalities via a RESTful API.cloudrun.sh: Deploys the agent as a scalable service to Google Cloud Run, making it accessible publicly.
These scripts are tailored for specific agents within the project, demonstrating various A2A interactions and functionalities:
a2acard.sh: Runs thea2a-agentcardagent, which handles agent card-related interactions.a2aevents.sh: Executes thea2a-eventsagent, designed for finding events with Google Search Tool.a2ahello.sh: Runs thea2a-hello-worldagent, a basic example of A2A communication.a2amaster.sh: Starts thea2a-master-agent, which orchestrates interactions between other agents.a2atest.sh: A utility script for testing A2A agent functionalities.a2aweather.sh: Runs thea2a-weather-timeagent, demonstrating tool usage for weather and time information.
The core agent logic is defined in src/agents/a2a_hello_world/agent.py. This simple agent demonstrates:
- Tool Usage: It utilizes two predefined tools:
get_weatherto retrieve current weather conditions for a specified city, andget_current_timeto obtain the current time for a given location. - Model Integration: The agent is configured to use the
gemini-2.5-flashmodel for its conversational capabilities and tool orchestration. - Direct Execution: The
agent.pyscript can be run directly to start auvicornserver, which is useful for local development and testing.
This project highlights the integration of the Agent-to-Agent (A2A) protocol, enabling seamless communication between different agents. The agent-specific scripts (e.g., a2ahello.sh, a2aweather.sh) are designed to run agents in A2A mode, allowing them to send and receive messages from other agents. This setup is crucial for building complex multi-agent systems where specialized agents collaborate to achieve a larger goal. The a2a-hello-world agent, while simple, provides a clear example of how to expose an agent's capabilities for inter-agent communication using the ADK framework.
To extend or modify this agent:
- Locate Agent Code: The main agent implementation is in
src/agents/a2a_hello_world/agent.py. - Add Tools: Define new tools within the agent's
toolslist, similar toget_weatherandget_current_time. - Modify Agent Logic: Adjust the agent's prompt or add new functionalities within the
agent.pyfile. - Dependencies: If new Python packages are required, add them to
src/agents/a2a_hello_world/requirements.txt. For development dependencies, add them to the rootrequirements.txt. - Testing: Utilize the
cli.shorlocal.shscripts for quick local testing during development.