Try this first
Before you read on, write down your own answer to this question:
When an AI coding tool reads a file from your project, who opens the file?
Take ten seconds. Write it down. We come back to this in Lesson 1.4.
The shape of the thing
Here is the whole mechanism. Read it once. You will not understand every line yet, and that
is fine.
messages = [{"role": "user", "content": "Read notes.txt and summarise it."}]
while True:
reply = llm.send(messages, TOOLS)
messages.append({"role": "assistant", "content": reply.text,
"tool_calls": reply.tool_calls})
if not reply.wants_tool:
break
results = run_the_tools_it_asked_for(reply)
messages.append({"role": "tool_results", "results": results})
That is an agent.
We send a message. The model replies. If the reply is “please run this tool”, we run it, tell
the model what happened, and send everything again. If the reply is anything else, we stop.
What is doing the work
Look at what is in that loop, and what is not.
There is no planning engine. There is no reasoning module. There is no framework. There is a
while loop, a list called messages, and one function call.
The intelligence is in the model. The agency — the ability to do things — is in these ten
lines. You are about to write them.
An agent is a model, a list of tools, and a loop that runs until the model stops asking
for tools.
About that llm.send
You may have noticed llm and wondered where it comes from. We build it in Lesson 1.3, out
of the differences between two real providers, once you have seen those differences yourself.
It is about eighty lines and it is the only file in this course that knows the name of any
company. Everything else — every tool, every guard, every lesson from here to the end — works
the same whichever model you point it at.
Why so many people find this surprising
Agent tools feel much more complicated than this when you use them. They show plans. They
show progress. They pause and ask permission. They remember your project.
All of that is real, and all of it is built on top of the loop above. Module 3 adds the
permission step. Module 6 adds the memory. Every one of them is an addition to this loop, not
a replacement for it.
That is why we start here. If you learn the loop properly, the rest of the course is small
changes to something you already understand.
Try this before the next lesson
Pick a model to work with. Any of these is fine, and you can change your mind later:
| Option | Cost | Set up |
|---|---|---|
| Local (Ollama) | Free | Install Ollama, then ollama pull gemma4. Needs about 10 GB of disk |
| Google Gemini | Free tier | An API key from Google AI Studio |
| OpenAI | Paid | An API key, a few dollars covers the course |
| Anthropic | Paid | An API key, a few dollars covers the course |
Then install what you need:
pip install openai # also drives a local Ollama model
pip install anthropic # only if you chose Anthropic
pip install google-genai # only if you chose Gemini
If you have no card and no key, take the local option. Everything in this course was tested
that way, and it costs nothing.