Skip to main content
In this lesson you’ll scaffold and run a minimal Google ADK agent — a “hello world” style example that shows how to:
  • scaffold an agent,
  • register simple tools,
  • and let the LLM decide which tool to call based on natural language.
This step-by-step walkthrough covers creating a Python virtual environment, installing the Google ADK package, scaffolding a starter application, implementing two deterministic tools (get_current_time and get_current_weather), and running the agent interactively.
A presentation slide that says "Build Your First Agent" on the left with a large "Demo" label on a dark, curved shape on the right. A small "© Copyright KodeKloud" appears in the lower-left corner.
What we’ll do
  • Create and activate a Python virtual environment
  • Install google-adk
  • Scaffold an ADK app
  • Add two simple tools
  • Run the agent and interact with it
Create and activate a virtual environment (macOS / Linux shown):
Install the Google ADK package inside the virtual environment:
The package installs several dependencies; expect to download multiple MBs. Scaffold a new ADK application from your project root:
Follow the interactive prompts. For this lesson choose the Gemini model and Google AI backend:
After entering your API key the scaffold creates a basic layout (files like __init__.py and agent.py). The generated agent.py is the canonical place to register your agent and tools. Example agent.py Below is a minimal agent.py that defines two deterministic tools and registers them with the root agent. These are intentionally hard-coded for clarity; replace them with real API calls in production.
Why register tools this way?
  • instruction: The text given to the LLM that defines the agent’s behavior and available tools.
  • tools: A list of Python callables the model may invoke. The LLM chooses which tool to call based on the user query.
Run the agent from the project root:
A typical interactive session:
Key concepts and best practices
  • The LLM acts as a router: the instruction plus the user query determines which tool (if any) gets invoked.
  • Tools are plain Python callables and can wrap HTTP APIs, SDKs, or complex business logic.
  • For production, use real services (timezone APIs, weather APIs), robust error handling, timeouts, and non-blocking I/O when appropriate.
  • Keep tool signatures simple and well-documented (type hints and short docstrings improve the LLM’s ability to choose correctly).
Tooling at a glance
Tip: Keep your tool interfaces simple and well-documented (type hints and concise docstrings help the LLM choose the right tool). In production, prefer non-blocking calls and proper error handling in tools.
Warning: Some ADK features are experimental and may emit warnings at runtime. Pay attention to those messages and review the ADK changelog when upgrading.
Why this structure matters
  • The model performs semantic routing: given the instruction and a user prompt, it decides which tool to call and how to format the call.
  • This approach separates decision-making (LLM) from execution (tools/APIs), enabling safer, auditable, and extensible agents.
  • It mirrors retrieval-augmented patterns: the LLM identifies the appropriate capability or data source and returns the result in natural language.
Summary
  • We created a Python virtual environment, installed google-adk, scaffolded a project, added two deterministic tools, and ran an interactive agent that uses the LLM to choose tools based on natural language.
  • To build a production-ready agent, replace the stub tools with real API integrations (timezone, weather, or other services), add robust error handling, and monitor agent behavior.
Links and references

Watch Video