Topic 1 of 5 · 4 min read
Model, tools and loop as one system
Goal: Label the model, tool, loop and environment parts in an agent's run log and name which part caused a given behaviour.
An agent is a model that chooses tool calls, plus a loop that runs those calls and feeds the results back, until the model decides the goal is met. Take any one of the three parts away and you have something else: a chatbot, a script or a stuck program.
Check yourself · 1 of 3
In an agent run log, which part actually executes the tool call the model asked for?
Why it matters
When an agent misbehaves, "the AI got it wrong" is not a diagnosis. Was the model's choice bad, did the tool return junk, or did the loop stop too early or never stop? You can only fix what you can name. The definition used by most practitioners is short: an LLM running tools in a loop to achieve a goal.
The parts
- The model (Claude, GPT, Gemini, an open-weight model) reads the goal and the history so far, then outputs either a final answer or a request such as "call
read_filewith this path". It never runs anything itself. It only writes text. - The tools are functions your code exposes: read a file, run a shell command, search the web, query a database. Each has a name, a description and a parameter schema. The model sees those descriptions and picks from them.
- The runtime is the code between the two. It parses the model's request, checks it, runs the tool and captures the output.
- The loop appends that output to the conversation and calls the model again. It repeats until the model answers without a tool request, or a limit such as a step budget, a timeout or a human stop is hit.
- The environment is whatever the tools touch: the repo, the browser, the database. It is covered in the next topic.
The loop is the part people forget. A single model call that uses one tool and answers is tool use. It becomes an agent when the model sees the result and decides what to do next, several times.
Before and after
A weak mental model: "I asked the AI to fix the failing test and it did." The better one, read from the run log:
step 1 model -> tool: run_tests result: 1 failed (test_total)
step 2 model -> tool: read_file src/cart.py result: <120 lines>
step 3 model -> tool: edit_file src/cart.py result: ok
step 4 model -> tool: run_tests result: all passed
step 5 model -> answer: "Fixed rounding in total()."
The model chose steps 1 to 5 and wrote the final text. The runtime executed each tool. The loop fed every result back. Step 4 matters most: the agent checked its own work against the environment instead of trusting its edit.
What goes wrong
- The model picks the wrong tool or wrong arguments. A vague tool description is often the cause, not a weak model.
- A tool fails quietly. It returns an empty string and the model carries on as if it worked.
- The loop has no sensible stop. The agent retries the same failing call, burning time and money, because nothing caps steps.
- The context fills up. Long tool outputs push the original goal out of focus and the model drifts.
Examples
Reading a run log by part
step 1 model -> search_docs("rate limit") tool -> 0 results
step 2 model -> search_docs("rate limit") tool -> 0 results
step 3 model -> search_docs("rate limit") tool -> 0 results
The model repeats the same call and the loop allows it. Two fixes live in different parts: a tool that says "no results, try a broader term" and a loop rule that stops identical consecutive calls.
Tool use versus agent
A support bot looks up one order with get_order(id) and writes a reply. That is one tool call, no decision about what to do next: tool use. A bot that looks up the order, sees it shipped late, checks the carrier, then decides between a refund and an apology is running a loop with decisions between steps: an agent.
Key points
- An agent is a model choosing tool calls inside a loop that feeds each result back until a stop condition.
- The model only writes text; the runtime is the code that actually runs the tool and returns the output.
- One tool call followed by an answer is tool use; repeated decide, act, observe cycles make it an agent.
- In a run log, bad behaviour traces to one part: the model's choice, the tool's result or the loop's stop rule.
- A loop needs hard limits such as a step budget, a timeout and a way for a human to stop it.
Common mistakes
- Blaming the model for every failure when the tool description, the tool's output or the missing step limit caused it.
- Assuming the model runs the tool; it only requests it, and your runtime decides whether to run it.
- Calling any app with an LLM and one API call an agent, when nothing feeds results back for a next decision.
- Shipping a loop with no step budget, timeout or repeated-call check.
Check yourself · 2 of 3
A bot calls one tool to fetch an order, then writes a reply and stops. How is this best described?
Check yourself · 3 of 3
An agent calls the same search with the same query five times and gets no results each time. Which fix targets the loop rather than the model or tool?
Practice items, not counted towards your mastery.
Start here
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Separates fixed workflows from agents and shows the simple loop most agents are built on.
- I think "agent" may finally have a widely enough agreed upon definition (Simon Willison) (opens in a new tab)ArticleFree
The working definition used here: an LLM running tools in a loop to achieve a goal.
- Levels of Autonomy for AI Agents (Feng, McDonald, Zhang) (opens in a new tab)PaperFree
Defines autonomy levels by the role the user plays, so autonomy is a design choice, not a given.
More for this topic
- Tool use overview (Claude docs) (opens in a new tab)DocsFree
How a model requests a tool call and how your code runs it and returns the result.