Google ADKgoogle-adk · Python 3.10+
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
14 small wins to finish your pathNext lesson

Your first agent

An ADK agent is one file with one variable in it. The variable has to be called root_agent.

The folder

text
my_agent/
  __init__.py
  agent.py
  .env

The agent

python
from google.adk.agents.llm_agent import Agent


def get_current_time(city: str) -> dict:
    """Returns the current time in a specified city."""
    return {"status": "success", "city": city, "time": "10:30 AM"}


root_agent = Agent(
    model="gemini-flash-latest",
    name="root_agent",
    description="Tells the current time in a specified city.",
    instruction="You are a helpful assistant that tells the current time in cities. "
                "Use the 'get_current_time' tool for this purpose.",
    tools=[get_current_time],
)

That is the whole agent. A model, a name, a description, an instruction, and a list of plain Python functions it is allowed to call.

root_agent is not optional
ADK looks for a variable with that exact name. Call it something else and the CLI will not find your agent.
PreviousInstall ADK

You understood something today that you didn't yesterday.