Agents are behind coding assistants, research tools and 'AI agent' steps in automation platforms; knowing the loop demystifies them.
A single tool call answers one question. An agent keeps going. Given a goal ("Find out why last week's sales dropped and draft a short report"), it works in a loop:
1. The model looks at the goal and everything so far, and decides the next action: call a tool, or finish. 2. The tool runs (search, read a file, query a spreadsheet, send a message). 3. The result is added to the conversation. 4. Back to step 1, until the model decides it is done or a limit is hit.
The program that runs this loop, passes tool results back and enforces limits is often called the harness. The model supplies the decisions; the harness supplies the hands.
What makes an agent different from a fixed automation is that the model chooses the steps. Nobody wrote "first search, then open the third result". That flexibility is the point, and also the risk: it can take a wrong turn, repeat itself, or do something you did not expect.
Agents need:
- Good tools with clear descriptions,
- A clear goal and stopping condition,
- Limits: a maximum number of steps, time or spend,
- Room in the context window: every step adds tool results, so long tasks fill it quickly.
Examples you may know: coding agents such as Claude Code or OpenAI's Codex, and the "AI agent" features of automation platforms such as Zapier, Gumloop and n8n, where you pick which apps the agent may use. Under the hood they all run this loop. Later lessons cover when an agent is the right choice and how to keep it safe.
Example
Goal: "Is order A-4471 late? If so, apologise to the customer."
Step 1 model -> call get_order_status(order_id="A-4471")
result: "Promised 10 May, still in warehouse"
Step 2 model -> call get_customer(order_id="A-4471")
result: "Ana Ruiz, ana@example.com"
Step 3 model -> call send_email(to="ana@example.com", body="Sorry, Ana...")
result: "sent"
Step 4 model -> finish: "The order was late; I emailed Ana an apology."Remember
- Agent = model + tools + a loop until the goal is reached
- The model chooses the steps; the harness runs tools and enforces limits
- Every step uses context, so long tasks need limits and care
Watch out for
- Running an agent with no step or spending limit; a confused agent can loop for a long time.