↑ Contents Chapter 1 of 12

Chapter 1: What's an Agent, Really?

Maya has a problem. It's Tuesday, and she needs to plan a surprise anniversary trip to Lisbon for her and her wife, Devi. She has a budget, a narrow window of dates, and exactly zero free evenings this week. She opens a chatbot and types: "Help me plan a 4-day trip to Lisbon, under €1,500, sometime in October." The chatbot is brilliant. It suggests neighbourhoods, recommends boutique hotels in her price range, lists must-see restaurants, even drafts a day-by-day itinerary. Maya is impressed. Then she looks at her screen and realises: she still has to do every single thing herself. Open six tabs. Compare flight prices. Check her calendar against the dates. Copy confirmation numbers into a notes app. The chatbot is the world's most knowledgeable travel advisor — and it has no hands.

Why This Matters

By the end of this chapter, you'll be able to explain — to anyone, without hand-waving — what an AI agent is, how it's different from the chatbot you've already been using, and what the agent loop is. That loop is the heartbeat of every agent you'll ever build, and once you see it, you can't unsee it. Every chapter after this one is just filling in the pieces of that loop.

Chatbot vs. Agent: The "Hands" Question

Here's the simplest way to draw the line. A chatbot takes text in and gives text out. That's it. It can be funny, helpful, even brilliant — but it lives entirely inside the conversation window. It can't reach outside.

An agent takes text in, thinks about what to do, takes an action in the real world, and then looks at what happened. Then it thinks again. The action is the whole point. An agent doesn't just talk about booking the flight — it books the flight.

Chatbot "Text in" "Text out" No actions. No reaching out. Agent "Text in" "Think" "ACT in the world" Books, searches, sends, writes...
A chatbot talks. An agent acts. The orange box is the whole difference.
Note "Action" doesn't have to be dramatic. Searching a database is an action. Reading a file is an action. Sending an email is an action. If the software reaches outside the conversation to do something, it's acting. That's the line.
There Are No Dumb Questions
Q: Wait — isn't ChatGPT an agent then? It can browse the web now.
A: Good instinct. When ChatGPT only answered from its training, it was a chatbot. When it browses, runs code, or calls tools, it's acting like an agent. The line isn't about the product — it's about what's happening in that moment. A chatbot with tools bolted on is an agent. Same brain, new hands.
Q: So is "agent" just a buzzword for "chatbot with plugins"?
A: Not quite — and the difference matters when you're building one. A plugin-equipped chatbot usually calls one tool when you explicitly ask. An agent decides on its own which tool to use, when to use it, what to do with the result, and whether to try something else. The autonomy — the loop — is what makes it an agent. We'll build that loop in Chapter 3.

The Agent Loop: The Heartbeat

Every agent — every single one, from a toy script to a production system — runs the same four-step loop. Burn this into your brain:

1. PERCEIVE See the task & the world 2. THINK Decide what to do 3. ACT Call a tool / do something 4. OBSERVE Look at what happened
The agent loop. It goes around and around until the task is done.

Let's walk through it with Maya's trip:

PERCEIVE Maya says: "Plan a 4-day Lisbon trip, under €1,500, October." The agent sees the request. THINK "I need flights and hotels. I should check flights first. I have a search_flights tool. I'll call it." ACT Calls search_flights(origin="London", dest="Lisbon", month="October", max_price=300) OBSERVE Tool returns: 3 flights found, cheapest €180 on Oct 12. THINK "Good, €180 leaves €1,320 for hotel and food. Now I need a hotel. I'll call search_hotels." ACT Calls search_hotels(city="Lisbon", checkin="Oct 12", ...) OBSERVE Tool returns: 5 hotels, best match €120/night in Alfama. THINK "€180 + €480 (4 nights) = €660. Under budget. I have everything. I'm done. I'll tell Maya."
// The loop ran three times. Each time, the agent observed the result and decided the next move.

Notice what just happened. Nobody told the agent to search for flights first. Nobody told it to check the budget after. It figured out the order on its own, looked at each result, and decided when it was finished. That's autonomy. That's what makes it an agent.

Sharpen your pencil

Before you read on, grab a piece of paper (or just think it through). Imagine an agent that helps you manage your email inbox. Trace one full pass through the loop for this task: "Find any unread emails from my boss and draft a reply to each."

Write down what happens at each step — PERCEIVE, THINK, ACT, OBSERVE. What tool might it call? What does it observe? When does it stop?

Why This Is a New Way to Build Software

Here's the part that takes a minute to click. For your whole career — or your whole life as a person who uses computers — software has worked one way: you decide what to do, and the software does exactly that. You click a button, it runs the code behind that button. Every branch, every if-statement, every path was written by a human who imagined it in advance.

An agent flips that. You give it a goal, and it decides the steps. The code doesn't say "if the user asks for flights, call the flight API." The code says: "here are some tools, here's a goal — figure it out." The LLM, in the THINK step, is choosing which tool to call and with what arguments, on the fly.

Traditional Software Human writes every if/else path User clicks → exact code runs Predictable. Rigid. Every path known. Agent Software Human gives goal + tools LLM decides which steps to take Flexible. Adaptive. Paths chosen at runtime.
Same building blocks. Who decides the path? That's the revolution.
Watch it! This is also why agents can go wrong in ways traditional software can't. If the LLM misjudges the THINK step, it might call the wrong tool, call it with bad arguments, or loop forever calling the same thing. You're trading predictability for flexibility. The whole second half of this book — guardrails, evals, testing — exists because of that trade.
There Are No Dumb Questions
Q: If the LLM decides everything, what do I actually build?
A: You build everything around the LLM. You write the tools it can call. You design the prompt that shapes how it thinks. You add the memory so it remembers. You build the loop that runs it. You add the guardrails that keep it safe. The LLM is the brain; you build the body, the hands, the nervous system, and the seatbelt.
Q: Does every agent need all four steps of the loop?
A: The useful ones do. A system that only perceives and acts (no thinking, no observing) is just a remote control. A system that thinks but never acts is a chatbot. The loop — all four steps, going around — is what gives an agent its agency. Some loops are tiny (one turn); some run for hours. But the shape is the same.

Where People Come Unstuck

Almost everyone new to agents trips on the same two things. Let's name them now so you can spot them later.

Mistake #1: "The LLM is the agent"

No. The LLM is the brain. The agent is the whole system — the brain plus the loop, the tools, the memory, the guardrails. When you say "I'm building an agent," you're not fine-tuning a model. You're wiring a brain into a body. We'll spend this whole book building that body.

Mistake #2: "Agents are just chatbots with a fancy name"

We addressed this, but it's worth a second hit because it's the one that sticks. The difference isn't the name. The difference is the loop and the autonomy. A chatbot responds. An agent decides, acts, observes, and decides again. If you take one thing from this chapter, take that.

Brain Power

Think about a task you do regularly that's annoying and repetitive — maybe sorting through job applications, summarising meeting notes, or checking whether your team's docs are up to date.

Now ask yourself: could an agent do this? What would it need to perceive (what info does it start with)? What tools would it need to act? How would it know when it's done? You don't need answers yet — just start thinking in the loop's shape. That's the habit this book builds.

Chapter Summary

  • A chatbot takes text in and gives text out. It lives inside the conversation and can't reach outside it.
  • An agent takes text in, thinks, takes an action in the world, and observes the result — then loops back and thinks again.
  • The agent loop is four steps: perceive → think → act → observe. It repeats until the task is done. This is the heartbeat of every agent.
  • The key difference is autonomy: an agent decides which steps to take, not you. You give it a goal and tools; it figures out the path.
  • This is a new way to build software: instead of writing every if/else path, you give a brain a goal and a set of tools, and let it choose.
  • The LLM is the brain. The agent is the whole system — brain, loop, tools, memory, and guardrails. You build everything around the brain.
Chapter Challenge

The Agent Spotter. Below are four software products. For each one, decide: is it a chatbot or an agent? If it's an agent, trace one pass through the loop — what does it perceive, think, act, and observe?

1. A customer support widget that answers FAQs from a knowledge base.
2. A coding assistant that reads your codebase, finds a bug, writes a fix, and opens a pull request.
3. A recipe app where you type ingredients and it suggests dishes.
4. A "research analyst" that reads today's news, picks the three most relevant stories for your industry, and emails you a summary with sources.

Hint: the question is always the same — does it just answer, or does it act, observe, and decide what's next?

Next →