LearnAIAgent Track · Weeks 2–5 ← Roadmap

Week 2 · From concepts to a working prototype

Building your first AI agent

Last time, AI talked. This week it acts — you'll learn what actually makes something an "agent," meet Kaggle (your future portfolio home), and build a working DataFetcher agent that goes and gets real information for you.

Week 2 of 5 · theory 30 min · practical 90 min

What you'll walk away with

Part 1 · Theory (30 min)

Anatomy of an AI agent

A chatbot answers in one shot. An agent works toward a goal: it plans, uses tools, remembers what it found, and acts — over and over — until the job is done. Four parts make that possible.

1

🧠 Planning

Break the goal into steps and decide what to do next. "To answer this, I first need today's news."

2

🛠️ Tools

Abilities the model doesn't have on its own — web search, a calculator, running code, reading a file.

3

📓 Memory

Hold on to what it has already found so each step builds on the last instead of starting over.

4

⚡ Action

Actually call a tool, read the result, and loop — until it can deliver a real answer.

🕵️ Analogy: a detective on a case

A detective doesn't guess the culprit from their armchair. They form a theory (plan), interview a witness or check records (tools), keep a case file (memory), and follow leads (action) — looping until the case is solved. An AI agent works a task the same way.

The ReAct loop: Reason + Act

The most common recipe for agents is called ReAct. It's a simple loop the model repeats: think about what to do, do it, look at the result, and go again.

the ReAct loop
# repeat until the goal is reached:
Thought   → "I need the latest AI-education headlines."
Action   → search_web("AI in education 2026")
Observation → [3 articles come back]
Thought   → "Now summarize them into 3 bullets."
Action   → summarize_text(articles)
Observation → [a clean 3-bullet summary]
Thought   → "Goal reached. Give the final answer."
why it mattersNotice it never guesses the news — it calls a tool to find out, then reasons on what came back. That's the difference between an agent and a chatbot.
🔑 The one idea

Reason → Act → Observe → repeat. Every agent you build this term — including today's — is some version of this loop.

The Kaggle ecosystem

Kaggle is where the data-science world learns, competes, and shows off. Three parts matter to you right now:

💼 Why this is portfolio gold

A public Kaggle notebook is a link you can put on a résumé or college app that says "here's a real project I built and explained." Recruiters and admissions readers can click it and see you can actually do the work. By Week 5, you'll publish one.

Part 2 · Practical (90 min)

Build the "DataFetcher" agent

Now you build the loop for real in Colab. The DataFetcher is an agent that, given a goal, calls tools to fetch and summarize live information. Here's the shape — the full, runnable version is in the Week 2 notebook.

Step 1 — Set up & initialize the LLM

Install the SDK and connect to Gemini (free via Google AI Studio). You'll also import pandas and requests for later.

setup
# in Colab
!pip install google-genai pandas requests
from google import genai
client = genai.Client(api_key=API_KEY)   # key from aistudio.google.com/apikey

Step 2 — Create the tools

A "tool" is just a Python function the agent can choose to call. We give it two. For reliability in class, search_web() returns mock news (a real NewsAPI key is optional).

tools.py
def search_web(query: str) -> str:
    """Return recent headlines for a topic."""
    return MOCK_NEWS   # swap in a real API later

def summarize_text(text: str) -> str:
    """Ask the LLM to shrink text to 3 bullets."""
    return client.models.generate_content(
        model=MODEL,
        contents=f"Summarize in exactly 3 bullets:\n{text}",
    ).text

Step 3 — The agent loop

Hand the tools to the model and let it drive: it decides which tool to call, you run it, feed the result back, and repeat until it has a final answer. That while loop is the agent.

agent loop (simplified)
while True:
    reply = model_step(history, tools=[search_web, summarize_text])
    if reply.wants_tool:                 # Thought → Action
        result = run_tool(reply.tool, reply.args)
        history.append(result)          # Observation → Memory
    else:
        print(reply.text); break          # goal reached
the task"Find the latest AI-education news and give me a 3-bullet summary." Watch the agent call search_web, then summarize_text, then answer.

Kaggle data integration — meet the Titanic

Finally, point the agent at structured data. You'll load the famous Titanic dataset in one line and ask a simple question — a preview of Week 3's data-analysis agents.

titanic.py
import pandas as pd
df = pd.read_csv("https://.../titanic.csv")   # one line to load
# agent task: "What's the average age by gender?"
df.groupby("Sex")["Age"].mean()

Checkpoint

Your agent needs to answer "what's trending in AI news?" — but the model's training stopped months ago. What makes it able to answer anyway?

It secretly already knows all news. It calls the search_web tool, then reasons on the fresh result. It guesses the most likely headline.

That's the whole point of tools: the model doesn't need to know the news — it acts (calls a tool), observes the result, and reasons on it. Reason + Act = ReAct.

⚡ Energizer · The Human ReAct Loop

Before the build, get everyone on their feet for 12–15 minutes and run the agent loop as humans — it makes the code obvious afterward.

Run it · 12–15 min · teams of 4

Be the loop

In teams, students take the roles Brain (Thought + Action), Hands (uses a tool card), Memory (writes each Observation), and Narrator. Round 1 they answer a question as a tool-less chatbot (and guess wrong). Round 2 they loop — Thought → Action → Observation — using SEARCH and CALCULATOR tool cards until they can answer for real. The gap between the two rounds is exactly why we build agents.

Coach: open the printable card → The Human ReAct Loop (green energizer sheet, ready to print).

Homework & deliverables


Recap. An agent = Planning → Tools → Memory → Action, run as the ReAct loop (Reason + Act). You built a DataFetcher that calls tools to fetch and summarize live info, met Kaggle (your portfolio home), and loaded your first real dataset. Next week: agents that reason over that data — and you'll scope your own project.