← Build an AI Agent Lesson 1 of 8

From chatbot to agent

Words that do things

I can only write text. So what if I write down what I want done… and someone else does it?

That someone is a small program. It reads everything the LLM writes.

You are the program. Click the line you must act on.

Two lines are just words. One asks for something to be done.

The program has the answer. But the LLM hasn't seen it yet.

Give back the result

Step through it. Watch who writes each line.

The program writes the result into the text, on a LOOK: line. The LLM reads all the text before it writes, so now it can use the result instead of guessing.
result → LOOK: line → the LLM reads it
LOOK: 1266871 → ANSWER: 4,817 × 263 = 1,266,871.

One tool was enough here. What if a task needs more?

The loop

Some tasks need several steps. So the program keeps going round: the LLM thinks, asks to act, the program writes what to look at. One trip round the loop is one round, and uses one tool.

Step through. Watch the loop go round twice.

The loop stops when the LLM writes ANSWER:. The LLM writes once in each round (its THINK: and ACT: lines together), then once more for the answer. Here: 2 rounds, so the LLM wrote 2 + 1 = 3 times.
times the LLM writes = rounds + 1

In case it never answers, the program also stops after a set number of rounds, called the step limit.

Try it on new numbers.

✏️ Practice 1.1

New numbers, same ideas.
Remember: one round = think, act, look. Each round uses one tool.
times the LLM writes = rounds + 1
The step limit is the most rounds the program allows. It stops there, even without an answer.

Work each one out. Type the answer, press Check.
“How much warmer is Kochi than Delhi?” The agent has a weather tool (one city at a time) and a calculator. How many rounds does it need?
Same task. How many times does the LLM write?
Same task. Each LLM write takes 2 seconds, and each tool takes 1 second. How many seconds in total?
The step limit is 4 rounds. A task needs 6 tool uses. How many times does the agent use a tool before the program stops it?

Lots of lines now. Who wrote which?

Who wrote what?

Who wrote each line? Tap its tag to change it: LLM, program or you.

The program only writes LOOK: lines. Everything else, the thinking and the asking, comes from the LLM. Together, they're an agent:
agent = LLM + a program running the loop

Quick check: did it all make sense?

Lesson 1 test

5 questions, one for each idea in this lesson. Answer them all right to pass. A wrong answer tells you why, and which page to look at again.

1. PredictThe LLM writes ACT: weather(Delhi). What happens next?
2. WhyWhy does the program write the result into the text, on a LOOK: line?
3. CountAn agent takes 4 rounds, then answers. How many times does the LLM write?
4. LoopWhen does the loop stop?
5. Spot the mistakeA friend says: “The LLM ran the calculator.” What's wrong?

What your agent still doesn't know.

What can it do?

Your agent can ask for things now. But how does the LLM know there's a calculator, or what to write to use it?

I can ask for anything… but what can I actually do?

This leaves a question
The agent wants to act. But what can it actually do?
Lesson 2 answers it.