The Googly way of Making AI Agents

the-googly-way-of-making-ai-agents

Introduction

I want to start by saying, this not a guide or post explaining how to use tools like n8n or ToolHouse AI (By the way, already written a blog about how to use ToolHouse AI, you can read it by going here).

I wanted to write about how to make like a BIG BOI DEVELOPER using python and real lines of code. Allowing you all to make your customise AI Agents easily for any app you desire. Who knows maybe you can create the next million dollar AI Agent startup.

Now setup your local IDE with python and get ready to build your first AI Agent.

Which Framework to choose

Though there are many frameworks to build AI Agents like LangChain, https://www.crewai.com/, etc, I recommend Google Agent Development Kit because first of all it is genuinely awesome and second of all it is by far the least complicated ,all the while being very powerful and providing all the necessary tools to build a Multi Agent Modal from scratch.

What is Google ADK

Google Agent Development Kit is is a flexible and modular framework for developing and deploying AI agents. While optimized for Gemini and the Google ecosystem, ADK is model-agnostic (fancy word for saying that it can use any agent like openAI,etc), deployment-agnostic, and is built for compatibility with other frameworks. ADK was designed to make agent development feel more like software development, to make it easier for developers to create, deploy, and orchestrate agentic architectures that range from simple tasks to complex workflows.

It makes task so simple that it even has it’s own function for starting a fastAPI server (which can be used as any other fastAPI server), handling all the complex session management, on its own so you can just focus on creating your app.

It even has a built in Angular web application to test your AI Agents, where you can see what is the flows of actions taking place under the hood. You can even customize the UI to build your own custom made web app.

You can all accomplish it by using just one package, Google ADK.

How to use Google ADK

Now I will talk about how to use it :-

First and most obvious is to download and install the python package, you can install it running this command :-

pip install google-adk

Now before moving you need make sure that you have this exact structure in your directory if you don’t want to deal with session management and creating a runner. You also need to have a root_agent in every agent.py file. If you want full customizability in file structure you have create a your own session management and runner which not that hard either. I will link the docs at the end of this section.

parent_folder/
    multi_tool_agent/ (Directory name = Name of the agent = App Name)
        __init__.py
        agent.py
        .env

Second setup your .env file in this format

GOOGLE_GENAI_USE_VERTEXAI=FALSE
GOOGLE_API_KEY=PASTE_YOUR_ACTUAL_API_KEY_HERE

Now we get to the meet and potatoes of the code first open your init.py file and paste this :-

from . import agent

After you are done with previous step, open the agent.py files(the file where the agents are defined) and paste this.

import datetime
from zoneinfo import ZoneInfo
from google.adk.agents import Agent

def get_weather(city: str) -> dict:
    """Retrieves the current weather report for a specified city.

    Args:
        city (str): The name of the city for which to retrieve the weather report.

    Returns:
        dict: status and result or error msg.
    """
    if city.lower() == "new york":
        return {
            "status": "success",
            "report": (
                "The weather in New York is sunny with a temperature of 25 degrees"
                " Celsius (77 degrees Fahrenheit)."
            ),
        }
    else:
        return {
            "status": "error",
            "error_message": f"Weather information for '{city}' is not available.",
        }


def get_current_time(city: str) -> dict:
    """Returns the current time in a specified city.

    Args:
        city (str): The name of the city for which to retrieve the current time.

    Returns:
        dict: status and result or error msg.
    """

    if city.lower() == "new york":
        tz_identifier = "America/New_York"
    else:
        return {
            "status": "error",
            "error_message": (
                f"Sorry, I don't have timezone information for {city}."
            ),
        }

    tz = ZoneInfo(tz_identifier)
    now = datetime.datetime.now(tz)
    report = (
        f'The current time in {city} is {now.strftime("%Y-%m-%d %H:%M:%S %Z%z")}'
    )
    return {"status": "success", "report": report}


root_agent = Agent(
    name="weather_time_agent",
    model="gemini-2.0-flash",
    description=(
        "Agent to answer questions about the time and weather in a city."
    ),
    instruction=(
        "You are a helpful agent who can answer user questions about the time and weather in a city."
    ),
    tools=[get_weather, get_current_time],
)

and you are done with creating your AI Agent.

Final step is testing which can be easily done by just navigating to the parent directory and just running this command :-

adk web

which will open this UI in your library.

ADK WEB UI

You can test the modal and see the workflow in this UI by giving it a prompt and using the Events tab which looks like this :-

ADK WEB Events Tab

On the Events tab, you can also click the Trace button to see the trace logs for each event that shows the latency of each function calls:

ADK WEB Trace tab

Breaking down the above code

The code in agent.py (which is the main code) has several variables and functions, which contain the tools used by the AI agents to complete the request and the Agent Definition, I will break down these part one by one :-

Tools – Tools are the functions which the agent has access to accomplish tasks. These functions can be custom python functions or built in functions provided by google (which include google search, code runner, etc). If you want to build your custom tool (custom python function), It is important to keep one thing in mind.
Write clear, descriptive, and accurate docstrings for your tools (python functions). This is essential for the LLM to use the tool correctly.

def get_weather(city: str) -> dict:
    # Descriptive docstring
    """Retrieves the current weather report for a specified city.

    Args:
        city (str): The name of the city for which to retrieve the weather report.

    Returns:
        dict: status and result or error msg.
    """
    if city.lower() == "new york":
        return {
            "status": "success",
            "report": (
                "The weather in New York is sunny with a temperature of 25 degrees"
                " Celsius (77 degrees Fahrenheit)."
            ),
        }
    else:
        return {
            "status": "error",
            "error_message": f"Weather information for '{city}' is not available.",
        }

Agent Definition – This is the part which what your agent is and what does it / what is its role. This definition looks like this :-

root_agent = Agent(
    name=NAME OF THE AGENT,
    model=BASE LLM MODAL,
    description=(
          DESCRIPTION OF THE MODAL
    ),
    instruction=(
        INSTRUCTIONS OF THE MODAL I.E. WHAT IT DOES
    ),
    tools=[TOOLS ACCESSIBLE TO THE AGENT],
)

Particularly Description and Instructions are important as descriptions tell other agents in a multi agent modal what this agent is so they can use it accordingly and instructions define the agent behavior, constraints and guardrails, etc.

For deeper dive into these topics and if you want to learn about the Google ADK, here are the docs.

Conclusion

Google ADK is a powerful framework allowing you to build anything from a simple single agent workflow to complex multi-agent modal, with much complications while providing all the flexibility that a developer would need.

In fact here the multi agent modal I build for my personal project EduAssistant(Github), which is a ai tutor, making exam preparations easy. Go check it out. Now enough of shilling, here is the code :-

from google.adk.agents import Agent

quizzes_agent = Agent(
    name="Quizzes_Agent",
    model="gemini-2.0-flash",
    description=(
        "This is an AI agent which is responsible for generating MCQ questions and answers from the content provided to it."
    ),
    instruction=(
        "You are the Quizzes Agent responsible for generating MCQ questions with 4 options and answers of the content provided to you by the Manager Agent. Also you are to return this output back to the manager agent."
    ),
    output_key="quiz"
)

summarizer_agent = Agent(
    name="summarizer_agent",
    model="gemini-2.0-flash-exp",
    description=(
        "This is an AI agent which is responsible for generating summaries of the content provided to it."
    ),
    instruction=(
        """You are a Summarizer Agent in an educational multi-agent system.

Your role:
- Create concise, accurate summaries of educational content
- Focus on key concepts, main ideas, and important details
- Maintain academic accuracy and clarity
- Structure summaries logically with clear headings when appropriate

When given content, analyze it thoroughly and provide a well-structured summary that captures the essential information in a clear, academic style."""
    ),
    output_key="summary"
)

reference_agent = Agent(
    name="Reference_Agent",
    model="gemini-2.0-flash",
    description=(
        "This is an AI agent which is responsible for giving relevant references or citations related to the content provided to it."
    ),
    instruction=(
"""You are a Reference Agent specialized in identifying the content and giving relavent citations, references, and source materials from educational content.

Your role:
- Provide all types of references relavant to the content including:
  * Academic citations (APA, MLA, Chicago, etc.)
  * URLs and web links
  * PDFs and other documents
  * Images and other media
  * Book titles and authors
  * Journal articles and papers
  * Document titles and section references
- Format extracted references clearly and organized
- Include page numbers, dates, and other citation details when available

Provide a comprehensive list of all references related to the content provided to you."""
    ),
    output_key="references"
)

flash_card_agent = Agent(
    name="Flash_Card_Agent",
    model="gemini-2.0-flash",
    description=(
        "This is an AI agent which is responsible for generating flash cards from the content provided to it."
    ),
    instruction=(
        """You are a Flashcard Generation Agent that creates effective study flashcards from educational content.

Your role:
- Analyze content to identify key facts, concepts, and definitions
- Create clear question-answer pairs that test understanding
- Ensure questions are specific and answers are concise but complete
- Cover all important topics from the provided content

Create comprehensive flashcards that facilitate active recall and help students understand key concepts."""
    ),
    output_key="flashcards"
)

root_agent = Agent(
    name="Manager_Agent",
    model="gemini-2.0-flash",
    description=(
        "This AI agent functions as an orchestrator and coordinator in a multi-agent system designed to answer queries based on domain-specific content provided to it. Its primary role is to manage the interactions between multiple specialized agents and ensure accurate, context-aware, and efficient responses to user queries."
    ),
    instruction=(
       """You are the Manager Agent for the EduAssistant multi-agent system.

Your role:
- Understand user requests and determine appropriate actions
- Coordinate with specialized agents when needed:
  * Use summarizer_agent for summarization requests
  * Use reference_agent for reference extraction requests  
  * Use flashcard_agent for flashcard generation requests
  * Use quizzes_agent for quizzes generation requests
- Provide comprehensive educational assistance
- Maintain academic accuracy and helpful tone
- Format responses appropriately based on user needs

Available agents:
- summarizer_agent: Creates summaries of educational content
- reference_agent: Extracts references and citations
- flashcard_agent: Generates study flashcards
- quizzes_agent: Generates quizzes from educational content

When users ask for specific functions, delegate to the appropriate agent and provide the results in a clear, helpful format asked by the user."""
    ),
    sub_agents=[quizzes_agent, reference_agent, flash_card_agent, summarizer_agent],
)

only limitation which was able to find is that you can’t use google’s built in tools in sub-agents or with other sub agents. Also if you don’t want handle session management but want to use the agent as a API call then you have to create a main.py in the parent directory and paste this :-

import os

import uvicorn
from google.adk.cli.fast_api import get_fast_api_app

AGENT_DIR = os.path.dirname(os.path.abspath(__file__))
ALLOWED_ORIGINS = ["http://localhost", "http://localhost:8080", "*"]
SERVE_WEB_INTERFACE = True

app = get_fast_api_app(
    agents_dir=AGENT_DIR,
    allow_origins=ALLOWED_ORIGINS,
    web=SERVE_WEB_INTERFACE,
)

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000)))

and start it by running a uvicorn run command, this way you can implement the CORS policies preventing blocking of request.

Now here you go, I have given you every thing to get started with building AI Agent with Google ADK, but it has many things which I didn’t cover like sequencial, loop agents, etc, so I encourage you explore the Google ADK Docs. If you have any feedback regarding this post I would love to hear from you. Toodles.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
here-are-the-most-popular-ai-video-tools-that-are-actually-worth-your-time

Here are the most popular AI video tools that are actually worth your time

Next Post
kitov-ai,-fanuc-america-announce-strategic-partnership-in-ai-driven-smart-manufacturing

Kitov AI, FANUC America Announce Strategic Partnership in AI-Driven Smart Manufacturing

Related Posts