a2aproject / a2aproject/a2a-samples
Design: A2A-compatible ADK Agent for City Information
- 主要语言
- Jupyter Notebook
- 星标
- 1.8k
- 派生
- 751
- PR 合并指标
- 30 天内没有已合并 PR
描述
# 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
```
贡献指南
评估
这个 Issue 还没有评估数据。