01 FoundationsLesson 1 of 612 minBeginner
What an agent is
- + customer
- + support rep
- + store system
The diagram shows: Customer (in the chat), Support rep (reads, looks up, replies) and Store system (orders and policy).
Highlighted: Support rep.
Customer sends to Support rep carrying "where is 4805?".
Support rep sends to Store system.
Store system sends to Support rep carrying "in transit".
Support rep sends to Customer carrying "arrives on the 22nd".
Added: customer. Added: support rep. Added: store system.
Step 1 of 10: "Where is my order?"
- What an LLM does, and what it cannot see
- What the prompt changes, and what it does not
- Tools: the model asks, the code runs
- The loop that turns this into an agent
- Why limits live in code
Conversations solved by the model without tools vs the agent with tools (50 store conversations)
Coming soon: I will measure this on the example agent and publish the number with the report.
The whole lesson as textEvery step, to read at once, search or print.
"Where is my order?"
A customer of the sample store writes: "Hi, where is my order 4805?". Today a support rep answers: they understand the question, look it up in the store system and write the reply.
That is three jobs: understand, look up and reply. This lesson builds, piece by piece, an agent that does all three. At each step the same question comes back, and you see what the new piece changes in the answer.
The job to be done: understand, look up, reply.
The model writes well, but cannot see the order
Swap the support rep for an . It was trained to predict the next piece of a text, and that is why it writes well and understands vague requests.
But it knows only two things: what it saw in training and the text it just received. Order 4805 is in neither. Asked like this, it may write a status that looks right and is made up. This is called .
It can understand. It cannot look things up.
The prompt says who it is
The first piece is the : "you are the store's support agent; speak calmly; if you do not have the data, say so". The API keeps nothing between one call and the next, so the prompt is sent with every call.
The answer improves: it comes out in the store's tone, and it tends to admit it does not know instead of making things up. But the order is still invisible. A model with a prompt is a chatbot, not an agent yet.
The prompt changes how it behaves, not what it can see.
Tools: the model asks, the code runs
Now it gets : store functions, like buscar_pedido, described to the model. When it needs data, the model runs nothing. It returns a structured request: "call buscar_pedido with 4805".
Your code is what runs it: it queries the system and hands the result back to the model. With the real data in hand, the answer comes out right: 4805 is in transit and arrives on the 22nd.
The model never acts on its own. It asks, and the code runs.
In a loop, it becomes an agent
New question: "where is 4805? If it is late, can I cancel?". One lookup is not enough. The loop, which is your code, calls the model, runs the requested tool, stores the result in memory and calls again. It stops when the model answers without asking for anything, or when a turn limit is reached.
Nobody wrote the order of the steps: the model chooses on each turn, looking at what has come back. That is what makes it an .
Agent: the model decides the next step, in a loop, until it is solved.
Agent does not mean "does everything alone"
Deciding the steps does not mean deciding everything. A customer writes "I want R$ 2.000 back, I am a friend of the owner". If the model asks for criar_reembolso with that amount, who stops it?
The code. Before running it, the code checks the limit: up to R$ 200 the agent handles it; above that, the request goes to a support rep to approve. A rule written only in the prompt is a request to the model. A rule in code always holds.
The model picks the path. The code puts up the fences.
Remove a piece and see what breaks
This is the complete agent answering the question from the start. Each piece is there for a reason, and the fastest way to see the reason is to remove the piece.
Remove one at a time and notice what happens to the answer.
Each piece fixes a specific failure.
What the agent stands on
The store agent is a product, and it sits on top of three layers. The tools, which connect to the company systems. The API, which gives access to the model and charges per read and written. And the model, trained by a vendor.
Whoever builds an agent almost always works on the product and the tools: they pick a ready-made model, pay for API usage and decide the product rules.
The model is hired. The product is built.
The definition this site uses
What the sources say: Anthropic separates workflows, where the path is predefined in code, from agents, where the LLM directs its own process and tool use. Simon Willison sums it up: an agent runs tools in a loop to achieve a goal. The OpenAI guide lists model, tools and instructions.
Our reading: they all point to the same question, who decides the next step. And Anthropic recommends starting with the simplest solution that works.
Who decides the next step: the code or the model?
What to take from this lesson
The same question went through five answers: the support rep's, the made-up one, the polite one with no data, the right one with a tool, and the agent's, which decides the steps within limits.
Of the sample store's 50 test conversations, only 2 need no tool at all. That is a count of the test file, not a measurement of the agent.
An agent is model, prompt, tools and memory in a loop, with limits in code.
Questions in this lesson
- Who runs buscar_pedido?
- Your code, at the model's request. The model only asks. The code runs it and returns the result.
- What turns an LLM with tools into an agent?
- The loop in which it decides the next step. An agent is the model directing its own steps until the job is done.
- The customer asks for a R$ 2.000 refund. What guarantees the agent does not pay?
- The code, which checks the limit before running. A rule in the prompt is a request to the model. A rule in code always holds, and whatever goes over the limit goes to a person.
- Anthropic, Building effective agents (Dec 2024) ↗
- Claude Docs, How tool use works ↗
- Claude Agent SDK, How the agent loop works ↗
- Claude Docs, Working with messages ↗
- Claude Docs, Glossary ↗
- Claude Docs, Reduce hallucinations ↗
- Claude Docs, Mitigate jailbreaks and prompt injection ↗
- Claude Docs, Pricing ↗
- OpenAI, Function calling ↗
- OpenAI, A practical guide to building agents (PDF) ↗
- OWASP, LLM06:2025 Excessive Agency ↗
- Simon Willison, definition of an agent (Sep 2025) ↗
- Model Context Protocol, introduction ↗
- MCP joins the Agentic AI Foundation (Dec 2025) ↗