Lab / Explainer / 4 blocks

No. 03Explainer7 min

An agent is a loop with tools

Four building blocks of an AI agent, from a filled-in prompt to agents handing work to each other.

Short version

An agent is a model in a loop: it reads a prompt filled with your data, decides whether to use a tool, ask a question or answer, and can pass its result to the next agent.

"Agent" is one of the most stretched words in AI right now. Underneath it are four simple building blocks. This page follows an invented bike repair shop whose assistant answers customers. Every answer here is pre-written; nothing is sent to a model.

01 · Block 1, context

Your data fills in the prompt.

A prompt template is a form with blanks. Before anything goes to the model, your software fills the blanks from your own records. Same question, three customers, three different answers.

Customer record

Name
Noor
Bike
city bike, 7 gears
Last visit
chain replaced in March
Plan
has a service plan
Asks
My gears keep slipping. Can you fix it this week?

Prompt template

You help customers of a bike repair shop. Customer: Noor. Bike: city bike, 7 gears. Last visit: chain replaced in March. The customer has a service plan. Question: "My gears keep slipping. Can you fix it this week?" Answer in two sentences and offer a booking if a repair is needed.

The model answers

Slipping gears on a city bike usually means the cable has stretched since the new chain in March. Your service plan covers it: shall I book you in for Thursday?

pre-written for this page, nothing is sent to a model

Show as text
CustomerBlanks filled withAnswer
Noorcity bike, 7 gears; chain replaced in March; has a service planSlipping gears on a city bike usually means the cable has stretched since the new chain in March. Your service plan covers it: shall I book you in for Thursday?
Time-bike, mid motor; battery check in August; no service planOn an e-bike it can be the cable or a worn cassette, so we need to look at it. A check costs 25 euros; Wednesday morning is free.
Ellaracing bike, 22 gears; new tyres in May; has a service planWith 22 gears the derailleur probably needs adjusting, a quick job your service plan covers. Friday at 10:00 works.
fig. 1 The prompt is a form. Your software copies the customer's facts into the blanks before the model reads a word.

The model only knows what the prompt carries. Good answers start with the right facts in the right blanks.

02 · Block 2, tools

A tool is just a description the model reads.

To let the assistant look things up, you describe each tool in a sentence: its name, what it does, what it needs. That sentence goes into the prompt. When the model wants the tool, it writes a short request. Your software runs it and adds the result as more text.

Your tools

What the model reads, top to bottom

  1. Instructions You help customers of a bike repair shop.
  2. Tool check_agenda: Returns the free repair slots for a week.
  3. Customer "Can you fix my gears this week?"
  4. Model writes check_agenda(week: "2026-W47")
  5. Result added Thursday 14:00 and Friday 10:00 are free.
  6. Model writes We can do Thursday at 14:00 or Friday at 10:00. Which suits you?

Your software

Runs check_agenda against your own systems, then adds the result to the conversation.

Show as text
ToolCustomer asksModel writesResultAnswer
check_agendaCan you fix my gears this week?check_agenda(week: "2026-W47")Thursday 14:00 and Friday 10:00 are free.We can do Thursday at 14:00 or Friday at 10:00. Which suits you?
check_stockDo you have a gear cable for my city bike?check_stock(part: "gear cable")In stock: 4. Price: 12.50 euros.Yes, we have it for 12.50 euros and can fit it while you wait.
get_weatherCan you collect my bike on Thursday?get_weather(town: "Breda", day: "Thursday")Dry, 9 degrees, light wind.Thursday looks dry, so our cargo bike can collect it in the morning.
fig. 2 The model only writes a request. The tool runs in your software, and its result comes back as one more line to read.

The model never runs anything itself. It writes a request; your software decides whether to run it.

03 · Block 3, the loop

The loop decides: use a tool, ask, or answer.

An agent runs in a loop. Each round it reads everything so far and makes one move. Using a tool sends it round again with more to read. Asking or answering ends the turn. Pick a customer message and follow the dot.

"Can you fix my gears this week?" uses a tool, then answers

  1. Round 1. Reads the question.
  2. Needs the free slots, which it does not have. It asks for check_agenda.
  3. Your software runs check_agenda. The result goes back in: Thursday 14:00, Friday 10:00.
  4. Round 2. Reads everything again, now with the free slots.
  5. Has what it needs. Answers: "Thursday 14:00 or Friday 10:00?"

every lap is another call to the model: time and money

Read Decide Use a tool Ask back Answer the loop
Show as text

"Can you fix my gears this week?" uses a tool, then answers.

  1. Round 1. Reads the question.
  2. Needs the free slots, which it does not have. It asks for check_agenda.
  3. Your software runs check_agenda. The result goes back in: Thursday 14:00, Friday 10:00.
  4. Round 2. Reads everything again, now with the free slots.
  5. Has what it needs. Answers: "Thursday 14:00 or Friday 10:00?"

"Can you fix it?" asks back.

  1. Round 1. Reads the question.
  2. "It" could be anything, and a guess wastes a slot. Asks: "What needs fixing, on which bike?"

"Are you open on Sunday?" answers straight away.

  1. Round 1. Reads the question.
  2. Opening hours are already in its instructions. Answers: "We are closed on Sundays."
fig. 3 Read, decide, act. A tool call is one more lap of the track; asking back or answering leaves it.

The decision step is where an agent earns its name, and where it most needs clear rules.

04 · Block 4, handing on

Agents hand their work to the next one.

For bigger jobs you can chain agents, each with its own short prompt and tools. One reads the message, one plans, one writes. What travels between them is a short note, not the whole conversation, so each one has less to read and less to get wrong.

Customer writesHi! My gears keep slipping on my city bike and it is getting worse. Could you fix it this week? I can bring it in after work, any day except Wednesday.

  1. Intake agent

    Turns the message into a short note.

    Reads 31 words

    Hands onProblem: gears slipping. Bike: city bike. Wants: this week, after work, not Wednesday.

  2. Planning agent

    Finds the part and a free slot, with its own two tools.

    Reads 13 words, not 44

    Hands onPart: gear cable, in stock, 12.50 euros. Slot: Thursday 17:30. Work: 30 minutes.

  3. Message agent

    Writes the reply in the shop's voice.

    Reads 13 words, not 57

    Sends the customerGood news: we can fix it Thursday at 17:30. It takes about 30 minutes and the new cable costs 12.50 euros. See you then!

fig. 4 Each agent reads only the note before it. The grey outline shows how much it would read if you passed on everything.

Each agent gets a small, clear job. The note it hands on is the contract between them.

Questions

How does a model "use" a tool?

It reads a text description of the tool and writes a request in a fixed format. Your software runs the tool and gives the result back as more text.