Watch a tiny agent work
So far in this course the model answered a prompt and stopped. In this lesson we watch a toy agent. The same kind of model sits in a loop with two tools, and its task is a question about a folder of meeting notes. The toy is small enough to read in one sitting. Its “model” is a script with a fixed list of replies. Every run below comes out the same way, and there is nothing for you to install or run. You read three transcripts. By the end you can label each line of one with the turn it belongs to, and you can say why the run stopped.
A model in a loop with two tools
Section titled “A model in a loop with two tools”A model takes text in and produces text out, once. It can’t open a file or look in a folder. An agent is software around a model that can. The software calls the model and reads the reply. When the reply asks for a tool, the software runs that tool and hands the result back to the model as more text, and then calls the model again [1]. The model supplies the judgment about what to do next, and the software supplies the hands.
The toy has two tools. Before anything runs, the model is told what they are, in plain text. Each tool has a name, one sentence on what it does, and its parameters, which are the details the model has to fill in when it asks for the tool.
list_dir: List the files in a directory. Parameter: path, the directory to list.read_file: Return the text of one file. Parameter: path, the file to read.That text is the whole of what the model knows about the tools. It never
sees the code behind list_dir, and it doesn’t need to. When it wants a
file listed, it writes a request that names the tool and fills in the
parameter, and the loop does the rest [2].
A tool with a vague description gets used badly, because the sentence
is all the model has to go on.
The folder the toy works in holds three short meeting notes, from 14, 21 and 28 March.
Read the transcript
Section titled “Read the transcript”The first task is a question about the notes. The transcript below is
the toy’s output, line for line. The lines that start with model: are
what the model produced, and the ones that start with loop: are what
the software around it did in response.
task: Which meeting note mentions the June delivery?1. model: call list_dir with path "notes" loop: ran list_dir, result: 2026-03-14-lantern.txt, 2026-03-21-budget.txt, 2026-03-28-lantern.txt2. model: call read_file with path "notes/2026-03-14-lantern.txt" loop: ran read_file, result: Project Lantern, 14 March. Sensor boards moved from April to June. Ana confirms the date by Friday.3. model: done. The note of 14 March: the sensor boards moved from April to June.loop: stopped, the model said it is done after 3 stepsRead step 1 slowly, because it is the whole idea. The model didn’t list
the folder. It wrote the words call list_dir with path "notes", which
is text like any other reply. The loop recognized that text as a request,
ran the real list_dir tool on the real folder, and put the three file
names into the conversation as the next thing the model reads. In step 2
the model, now knowing the file names, asked to read the one whose name
suggested the right project. In step 3 it had what it needed and wrote an
answer instead of a request, and the loop saw that and stopped.
The model’s text reached the folder only through the loop. In a real agent the loop is also where permissions are checked and where a request can be refused. When people say an agent “read a file”, this two-line exchange is what happened.
Observe, think, act
Section titled “Observe, think, act”The transcript has a rhythm, and the agent loop is that rhythm. Each step is one turn of it [1]:
- Observe. The model reads what’s in front of it: the task at the start, and after that the result of the last tool.
- Think. The model decides what to do next and writes it down, either
a tool request or an answer. In the transcript this is every
model:line. - Act. The loop runs the tool the model asked for and returns the
result. In the transcript this is every
loop: ranline.
Then the model observes the result, and the turn repeats. Step 1 of the
transcript is observe (the task), think (call list_dir), act (the
listing comes back). Step 2 is observe (the file names), think
(call read_file), act (the note comes back). Step 3 is observe (the
note) and think (done), with no act, because the model produced an
answer and there was nothing left to run.
The split matters when something goes wrong. A wrong answer after a correct file read is a think problem, and the fix is in the prompt or the model. A right request that returned an error is an act problem, and the fix is in the tool. An agent that read the wrong file did a reasonable think on a poor observe, and the fix is often a better tool description or a better folder name. Naming the turn tells you where to look.
Label the turns
Section titled “Label the turns”The lesson shows the transcript of a toy agent with two tools, list_dir and read_file. Lines that start with model: are what the model wrote, and lines that start with loop: are what the software around it did.
Is something being read, being decided, or being run?
Order one turn of the loop
Section titled “Order one turn of the loop”An agent is a model in a loop with tools. The question is the order of events inside one turn of the loop, from the moment a tool result comes back until the next result comes back.
- The model reads the result of the last tool
- The model writes a request that names a tool and its parameters
- The loop runs the tool
- The loop puts the result in the conversation
Which of these can happen before the model has read anything?
Which of these did the model do itself?
Section titled “Which of these did the model do itself?”An agent is a model placed in a loop with tools. The model is told each tool's name, purpose and parameters as text.
Looking at the transcript of an agent that found a fact in a folder of notes, which of these did the model do itself?
What can a model produce other than text?
How the loop ends
Section titled “How the loop ends”A loop with no end is a bug, so every agent has stop rules. The toy has two, and a real agent adds a third [1].
The model says it is done. This is the good ending, and the first transcript shows it: the model wrote an answer instead of a request, and the loop stopped after 3 steps.
The step limit is reached. The loop counts the steps and stops at a fixed number even when the model isn’t finished. The limit protects you from a model that keeps asking for tools without getting anywhere, which runs up the bill and, with tools that change things, keeps changing them. Here is the toy on a task with a step limit of 3, with a script that lists the folder twice and then reads the wrong file.
task: Who confirms the delivery date?1. model: call list_dir with path "notes" loop: ran list_dir, result: 2026-03-14-lantern.txt, 2026-03-21-budget.txt, 2026-03-28-lantern.txt2. model: call list_dir with path "notes" loop: ran list_dir, result: 2026-03-14-lantern.txt, 2026-03-21-budget.txt, 2026-03-28-lantern.txt3. model: call read_file with path "notes/2026-03-21-budget.txt" loop: ran read_file, result: Budget review, 21 March. Travel spend is under plan. The training budget is approved.loop: stopped, the step limit of 3 was reached, no answerThe answer was in the note of 14 March, and the model’s script would have read it in step 4. The loop didn’t allow a step 4. The transcript has no answer line, because the model never got to write one. The last thing it did was ask to read the budget note. A limit that stops a run always stops it in the middle of something.
A person stops it. In a real agent the loop pauses and asks before an action that’s hard to undo, and a person can say no, or close the window at any point [3]. A stop of this kind looks like the step limit from the model’s side: the last request was made, and no answer follows.
Why did the second run stop?
Section titled “Why did the second run stop?”A toy agent ran with a step limit of 3. Its transcript shows three tool requests, each with a result, and then a loop line that says the step limit was reached and there is no answer.
In the second transcript the run ends without an answer. Why?
Read the last line of the transcript. Who wrote it, and what does it say?
Which ending is this?
Section titled “Which ending is this?”An agent's loop ends in one of three ways: the model writes an answer instead of a tool request, the loop reaches its step limit, or a person stops it.
An agent’s transcript shows twelve tool requests, each with its result, and then one line from the loop: “stopped after 12 steps, no answer”. Nobody was watching the run. Which ending is this?
Did the model get to write an answer, and who decided to stop?
Exercise
Here is a third transcript, on a different task over the same three notes. Read it once. Then, on paper or in a note, write one line per step, in the form “step, tool used, which turns”, where the turns are observe, think and act. Step 1 of the first transcript would read “1, list_dir, observe (task), think (request), act (listing)”. Finish with one line that names how the run ended and how you know. Ten minutes is enough.
task: How many of the meeting notes are about project Lantern?1. model: call list_dir with path "notes" loop: ran list_dir, result: 2026-03-14-lantern.txt, 2026-03-21-budget.txt, 2026-03-28-lantern.txt2. model: call read_file with path "notes/2026-03-14-lantern.txt" loop: ran read_file, result: Project Lantern, 14 March. Sensor boards moved from April to June. Ana confirms the date by Friday.3. model: call read_file with path "notes/2026-03-21-budget.txt" loop: ran read_file, result: Budget review, 21 March. Travel spend is under plan. The training budget is approved.4. model: call read_file with path "notes/2026-03-28-lantern.txt" loop: ran read_file, result: Project Lantern, 28 March. The Utrecht pilot moves to July. Bram writes the short install guide.5. model: done. Two of the three notes are about project Lantern: 14 March and 28 March.loop: stopped, the model said it is done after 5 stepsA good result has five lines, four of them naming a tool and the fifth
naming none, because step 5 has a think and no act. The ending line says
the model wrote an answer, and points at the done line and the loop’s
last line as the evidence. As you write, notice that the model read the
budget note even though its name gave the answer away. A model in a loop
does what its judgment tells it, one step at a time, and a step it could
have skipped costs the same as one it needed. Where in this transcript
would a better tool description, or a better file name, have saved a
step?
Stretch: Write the transcript a fourth run would produce for the task 'Which note names Bram?', with the fewest steps a model that read the file names carefully could take, and mark the three turns of each step.
Recap
- An agent is a model in a loop with tools. The model produces text, and when that text is a request the loop runs the tool and returns the result as more text. The model never runs anything itself [1].
- A tool is described to the model by name, purpose and parameters, in plain text, and that description is all the model has to decide when and how to ask for it.
- Each step of the loop is observe (read the task or the last result), think (write a request or an answer) and act (the loop runs the tool). Naming the turn tells you where a mistake came from.
- The loop ends when the model writes an answer, when the step limit is reached, or when a person stops it. A run that ended on a limit or a stop was interrupted in the middle of a step, and its output has to be read that way.
You can now
- Describes the observe, think, act loop and the tools in it
References
Section titled “References”- Addy Osmani, Ivar Soares Urdalen, Leo Simons. What are AI agents: model versus agent, autonomy levels, when a prompt suffices. Agent Engineer Course. Course.
AEC-01 - Anthropic. Claude Platform 101. Claude Academy. Course.
Academy claude-platform-101 - DeepLearning.AI. Agentic AI: M1 workflows and autonomy, M2 reflection, M4 evals and error analysis, M5 autonomous agents. DeepLearning.AI. Course.
DLAI-11