Module 1 · Agent Loop, Harness & System DesignTopic 1.1

What turns an LLM into an agent

Context, Tools, Loop. What turns a model that writes text into an agent that does things.

About 15 minYour steps ↓

Watch first · 4 min

Chapters · 4:27

Remember

  • Memory is the conversation, resent.
  • The model asks. The app runs it.
  • It loops until the goal is met.

A chatbot answers. An agent acts.

Ask a chatbot "Where's my order?" and the best it can do is tell you how you might find out. An agent looks it up. The difference isn't a smarter model. It's three things wrapped around the same model. We call them CTL: Context, Tools, Loop.

C: Context

Context is everything the model sees on a given turn: the system prompt, the conversation so far, the descriptions of the tools it may use, and the results of any tools it already called. The model has no other memory (remember 0.3, How LLMs work), so context is the agent's entire world. Most "the agent is being dumb" problems are context problems: too little, too much, or the wrong stuff.

T: Tools

A tool is a function someone wrote, plus a description the model reads:

{
  "name": "lookup_order",
  "description": "Get status and shipping details for an order by its id.",
  "parameters": { "order_id": { "type": "string" } }
}

The model can't run the function. It can only reply with a request: "call lookup_order with order_id = 4721". The code around the model decides whether to run it, runs it, and hands back the result. That boundary is where permissions, validation and safety live, and it's why FDEs care so much about tool design.

L: Loop

One call isn't enough: the model needs to see the tool's result before it can answer. So you loop. In the book's words (Book §3.2):

  1. Read. The model gets the conversation plus attached context.
  2. Plan. It decides what to do next: call a tool, or answer.
  3. Act. The harness turns that into a real action.
  4. Observe. The result is appended to the conversation.
  5. Repeat until the model answers without asking for a tool, or you hit a step limit.
The agent loop. A customer message goes to the harness, which builds the context and calls the model. The model either asks for a tool, which the harness runs and sends the result back to the model, or it answers the customer. Every step is written to a trace.
Context, Tools, Loop. Teal is code you write (the harness); coral is the model. The model never runs a tool itself.

This pattern, reason then act then observe, is known as ReAct. Step through one real turn for Parcelly, a small delivery company, under this reading.

Reading a trace

A trace is the log of every step in that loop. When an agent misbehaves in production, the trace is the first thing you open: what did it see, what did it decide, what came back? Claude Code shows you its own loop as it works: every file it reads and every command it runs is a step, and you can ask it to explain any of them. In this topic's steps you give it a support ticket and then ask it to walk you back through what it did. In the bootcamp you'll be evaluating whole trajectories like that one.

Three things that follow

  • Agents cost more than chatbots. Every loop iteration resends the whole conversation.
  • Agents can get stuck. A bad plan leads to a confusing observation, which leads to a worse plan. Always cap the steps.
  • The loop is yours to shape. Which tools exist, what's in context, when to stop, when to ask a human. That's the design space of Module 1, and in Module 2 you build that loop yourself.

In the next topic, you'll see that Claude Code is this exact loop with a very good set of tools, plus permissions and memory. That wrapper is called the harness.

After this you'll be able to

  • Explain the difference between a chatbot and an agent with CTL: Context, Tools, Loop
  • Spot Read → Plan → Act → Observe in a real agent's work

Try it

Hands-on, in your browser.

The agent loop · step through one real turn
Context
Harness → model
System prompt + tool list + the user's question are packed into one request.
system: "You are a support agent for Parcelly. Use tools; never guess order data."
tools:  [lookup_order(order_id)]
user:   "Where's order 4721? Can I still change the address?"
Plan
Model
The model reasons that it can't answer without data, so it asks for a tool call instead of replying.
tool_call: lookup_order({"order_id": "4721"})
Act
Harness
Your code (the harness) runs the real function against the orders data.
lookup_order("4721")  # a function in your code
Observe
Harness → model
The result is appended to the conversation and sent back to the model.
tool_result: {"status": "packed", "ships": "tomorrow 9am", "address_editable": true}
Repeat
Model
With the new observation the model decides it has enough. No more tool calls, so the loop ends.
assistant: "Order 4721 is packed and ships tomorrow at 9am. You can still change the address. Want me to start that?"

C is for Context: everything the model will see this turn. It has no other memory.

1 / 5

Want more?

Optional.