A tutorial demonstrating how to build an AI agent that provides current time and weather information for cities using the Google ADK (Agent Development Kit). The agent can answer questions like "What time is it in New York?"
GEMINI_API_KEY={YOUR-KEY}cd /google_adk/tutorials/city-time-weatherThis tutorial demonstrates two different agent loading approaches:
Automatically discovers agents with ROOT_AGENT fields in compiled classes:
mvn exec:java -Dadk.agents.source-dir=$PWDThis approach:
- Uses Spring Boot to start
AdkWebServerdirectly CompiledAgentLoaderscanstarget/classesforROOT_AGENTfields- Automatically loads the
CityTimeWeather.ROOT_AGENT
Explicitly provides pre-created agent instances:
With custom port:
mvn exec:java -Dexec.mainClass="com.google.adk.tutorials.CityTimeWeather" -Dserver.port=8081This approach:
- Calls
CityTimeWeather.main()which executesAdkWebServer.start(ROOT_AGENT) - Directly provides the agent instance programmatically
- Uses
AgentStaticLoaderwith the provided agent
Once running, you can interact with the agent through:
- Web interface:
http://localhost:8080 - API endpoints for city time and weather queries
- Agent name:
multi_tool_agent
This tutorial demonstrates both agent loading strategies:
- CompiledAgentLoader (Option 1): Automatically discovers agents in compiled classes. Good for development and when you have multiple agents.
- AgentStaticLoader (Option 2): Takes pre-created agent instances programmatically. Good for production and when you need precise control.
Choose Option 1 for automatic discovery, Option 2 for programmatic control.
See https://google.github.io/adk-docs/get-started/quickstart/#java for more information.