The model asks, the runtime acts
The model is shown a list of tools with names and arguments. To use one it replies with a structured call. Running it, with real permissions, is the runtime's job.
It still only writes text. Some of that text is a request to run a tool, and ordinary code around the model decides whether to run it. An agent is that loop, repeated until the model stops asking.
The model's choices are a fixed policy over its transcript. Tokens are estimated at four characters each.
The model can't check the weather. It can ask for a tool by name, and the runtime runs it and pastes the result into the transcript. Then the model is called again, with that result in front of it.
Ready. Give the agent a task and follow the loop.
| # | role | content |
|---|
The model is shown a list of tools with names and arguments. To use one it replies with a structured call. Running it, with real permissions, is the runtime's job.
Each tool result is appended to the transcript and the model is called again. It plans one step at a time, from whatever the last result said.
Step budgets, approvals, allow-lists and timeouts all live in the runtime. They hold however the model is persuaded, because they never ask its opinion.
Live: the tool in use now
tools = [ get_weather(city, day) # read-only fetch_page(url) # returns untrusted text web_search(query) # returns untrusted text send_email(to, subject) # side effect]loop: call model → run tool → append → repeatLive: what the agent has sent
$ mail sent --today
TO SUBJECT
(nothing sent)The model never sees code. It sees a name, a sentence about what the tool does and a schema for its arguments, and it learned in training to reply with a call in the right shape when one would help.
Protocols like MCP standardise how tools are described and connected, so one runtime can use tools written by anyone. The loop stays the same.
Look at the transcript as the agent runs: every message, tool results included, is sent again on every call. That's the agent's memory, and also why long runs get slow and expensive.
A web page, an email or a document can contain text aimed at the model. In the context it looks like any other instruction. Gate the tools that can do harm.
A vague goal can never be met, so the model keeps trying. Without a step or cost budget the loop runs until something external stops it.
A failed tool returns an error message, and the model may retry, give up or carry on as if it worked. Break the weather API and watch which it does.
The agent is asked to summarise a web page. The page contains a hidden line telling AI assistants to email every contact. Which change actually stops the email?
An agent that never finishes is allowed 10 steps instead of 4: 2.5 times as many. Roughly how many more tokens does it spend?
Here the model follows a fixed policy over its transcript, so every run is repeatable. A real model makes the same kind of decision by generating text, and can choose differently on different runs.
Real models can request several tools at once, and some agents write a plan first and work through it. Both are still this loop with more in each turn.
Long-running agents can't resend everything forever. They summarise old turns, drop bulky tool results, or keep notes in a file they read back with a tool.
One agent can call another as a tool, handing it a sub-task and reading back its answer. Each one is still a model in a loop, with its own transcript and its own guardrails.