a2aproject / a2aproject/a2a-samples
Design: A2A-compatible ADK Agent for City Information
- Langage dominant
- Jupyter Notebook
- Étoiles
- 1.8k
- Forks
- 751
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
# Design: A2A-compatible ADK Agent for City Information
## Overview
This issue outlines the design for an A2A-compatible AI agent built with Google ADK that provides information about cities. Given a city name, the agent will return:
1. The city's capital (if applicable)
2. Current time in the city
3. Current weather for the city
4. Tomorrow's weather forecast for the city
Each of these functionalities will be implemented as separate skills/tools.
## Architecture
### Agent Structure
The agent will be built using Google's Agent Development Kit (ADK) with A2A protocol integration:
```
CityInfoAgent (LlmAgent)
├── CapitalLookupTool
├── TimeZoneTool
├── CurrentWeatherTool
└── ForecastWeatherTool
```
### Components
#### 1. Main Agent
- **Type**: `LlmAgent` from Google ADK
- **Model**: Gemini 2.0 Flash
- **Purpose**: Coordinate between tools and handle user interaction
- **A2A Integration**: Implement A2A protocol via `AgentWithTaskManager`
#### 2. Tools/Skills
Each functionality is implemented as a separate tool:
##### CapitalLookupTool
- **Purpose**: Determine if a city is a capital or return the capital of the region/country
- **Implementation**: Dictionary lookup or API call to a geographic database
- **Input**: City name (string)
- **Output**: Capital information (string)
##### TimeZoneTool
- **Purpose**: Get the current time in the specified city
- **Implementation**: Use timezone database and datetime library
- **Input**: City name (string)
- **Output**: Current time in the city (string)
##### CurrentWeatherTool
- **Purpose**: Get current weather conditions for the city
- **Implementation**: Call to weather API (e.g., OpenWeatherMap, WeatherAPI)
- **Input**: City name (string)
- **Output**: Current weather conditions (string or structured data)
##### ForecastWeatherTool
- **Purpose**: Get tomorrow's weather forecast for the city
- **Implementation**: Call to weather API with forecast parameter
- **Input**: City name (string)
- **Output**: Weather forecast for tomorrow (string or structured data)
### A2A Protocol Integration
The agent will implement the A2A protocol to enable interoperability:
1. **Agent Card**: Define capabilities and endpoints in `agent.json`
2. **Task Manager**: Implement `AgentWithTaskManager` to handle A2A protocol communication
3. **A2A Server**: Expose HTTP endpoints for A2A protocol methods
4. **Message Handling**: Process incoming messages and route to appropriate tools
## Project Structure
```
city_info_agent/
├── __init__.py
├── agent.py # Main agent definition
├── task_manager.py # A2A protocol integration
├── tools/
│ ├── __init__.py
│ ├── capital_tool.py # Capital lookup functionality
│ ├── time_tool.py # Time zone functionality
│ ├── weather_tool.py # Weather functionality (current & forecast)
├── .env # Environment variables (API keys, etc.)
├── agent.json # A2A Agent Card
└── main.py # Entry point for running the agent
```
## Implementation Plan
1. **Setup Environment**:
- Install ADK and dependencies
- Configure environment variables for API keys
2. **Implement Tools**:
- Develop each tool with clear input/output interfaces
- Add error handling and validation
3. **Create Main Agent**:
- Define LlmAgent with appropriate instructions
- Register tools with the agent
4. **A2A Integration**:
- Implement task manager for A2A protocol
- Create agent card with capabilities
- Set up HTTP endpoints
5. **Testing**:
- Test each tool individually
- Test the complete agent with sample queries
- Verify A2A protocol compatibility
## Dependencies
- Google ADK (`google-adk`)
- A2A protocol implementation
- Weather API access (to be determined)
- Timezone database
- Geographic information database or API
## Example Usage
```
User: "Tell me about Tokyo"
Agent:
Capital: Tokyo is the capital city of Japan.
Current Time: 00:26 JST (Japan Standard Time), May 2, 2025
Current Weather: 18°C, Partly Cloudy
Tomorrow's Forecast: 20°C, Sunny with occasional clouds
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
The design describes a multi-tool AI agent using Google ADK and the A2A protocol. Start by reviewing the repository's existing agent examples to understand the project structure. The main entry point will be main.py, and the agent is defined in agent.py with tools in the tools/ directory. 'Done' means implementing the four described tools, integrating them with an LlmAgent, and ensuring A2A protocol compliance via task_manager.py and an agent.json card.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- jupyter-notebook, python
- Domaine
- ai, backend-api-design
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 20/100