What makes a loop an agent and not a chat bot

L1ScreenConcept5 minScreenML breadth

RolesAgent Systems EngineeringDeveloper Experience and EducationCustomer AI Deployment

The question

A teammate says that their chat application is an agent because it calls a model inside a while loop. Name the parts that a real agent loop needs, and say what goes wrong when each one is missing.

Answer it first, aloud or on paper. Then open the answer.

The answer

Show short answer

An agent loop needs five parts: a message buffer that grows with each turn, a tool registry that the model calls by name, a stop condition, a turn budget, and an observation formatter. The model is the same in a chat bot and in an agent. The difference is that the agent can pause, call a tool, read the result and continue. Without the five parts, the loop is a chat bot with extra steps.

Show full answer

The loop

The pattern is the one from the ReAct paper. The model writes a thought, picks an action, reads an observation, and repeats until it decides to finish. Modern models move the thought to a separate reasoning channel, but the control flow is the same. Observe, think, act, observe, think, act, stop.

The five parts

PartWhat it doesFailure when missing
Message bufferHolds the user turn, the assistant turns, the tool turns and the final turn in orderThe model forgets what it already did and repeats work
Tool registryMaps a tool name to a schema and a callableThe model names tools that do not exist, and nothing runs
Stop conditionEnds the run on an explicit finish, on a turn with no tool call, on a budget, or on a guardrailThe run never ends, or ends only when the context is full
Turn budgetCaps the number of iterations for this task classOne bad decision at step 38 becomes an endless run
Observation formatterConverts every tool output, including every error, into a string the model can readA failed call becomes a crash instead of a correction

The formatter is the part that people forget. The lesson says that every 400 error in the stack must become an observation string, not an exception. A model that sees the error can correct the next call. A model that never sees it cannot.

Why the parts matter now

Agents run 40 to 400 steps per task. Every framework in use today builds the same loop under its own names. The things that differ live around the loop: checkpoints, actor messaging, role templates, tracing. The loop itself does not change.

Follow-ups

  1. L1ScreenWhat is an observation?

    Show expected answer

    the string form of a tool result that the loop appends to the buffer for the next model call.

  2. L2WorkingWhy is a turn budget a separate part from the stop condition?

    Show expected answer

    the stop condition depends on what the model emits, and the budget protects the run when the model never emits a stop.

  3. L2WorkingWhere does the thought go in a model with a native reasoning channel?

    Show expected answer

    in a separate field that the runtime passes between turns, so the transcript shows tool calls and results without inline thought text.

  4. L3SeniorWhat changes when two tool calls in one turn return out of order?

    Show expected answer

    each result needs a correlation id that ties it to its call, or the model reads the wrong result for a call.

Wrong answers

Show the wrong answers that interviewers hear
  • “An agent is a model with a long system prompt.”

    A prompt cannot run a tool or read a result, so the model still stops at its first wrong guess.

  • “The loop ends when the model says it is done.”

    A model can say it is done too early or never, so the loop also needs a turn budget and a no-tool-call stop.

  • “Tool errors should raise so that the developer sees them.”

    An error that raises ends the run, while an error that becomes an observation lets the model fix the call.

Taught in

The agent loop lesson builds the five parts with a scripted model and three tools.