Week 2 · From concepts to a working prototype
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.
What you'll walk away with
Part 1 · Theory (30 min)
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.
Break the goal into steps and decide what to do next. "To answer this, I first need today's news."
Abilities the model doesn't have on its own — web search, a calculator, running code, reading a file.
Hold on to what it has already found so each step builds on the last instead of starting over.
Actually call a tool, read the result, and loop — until it can deliver a real answer.
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 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.
# 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."
Reason → Act → Observe → repeat. Every agent you build this term — including today's — is some version of this loop.
Kaggle is where the data-science world learns, competes, and shows off. Three parts matter to you right now:
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)
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.
Install the SDK and connect to Gemini (free via Google AI Studio). You'll also import pandas and requests for later.
# 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
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).
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
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.
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
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.
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?
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.
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
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).
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.