← Agents & Agent Systems
08 · Agents & Agent Systems · NEW Topic

What is an Agent Loop?

An Agent Loop is the repeated cycle that lets an AI system work through a multi-step task instead of answering only once.

What is it?

An Agent Loop is the control cycle that allows an agent to continuously observe, reason, act, and react to new results.

A normal LLM interaction looks like User → LLM → Answer. An agent needs a loop around the model so it can pursue a goal, use tools, inspect what happened, and choose the next step.

Why it matters: An Agent Loop lets an agent carry out a task across multiple steps. Without the loop, the system usually stops after one response.

Think of it like...

A normal LLM answers one question once.

An Agent Loop is like an employee who keeps checking the situation, taking one step, checking the result, and choosing the next step until the work is done. This analogy describes a repeated workflow, not human-like thinking.

How it works

The loop begins with a goal and ends when the task is complete, a human needs to decide, or a safety limit is reached.

1 · GoalDefine the outcomeWhat should be accomplished?
2 · ObserveRead the situationCollect the task, context, and current state.
3 · ReasonUnderstand the next needInterpret what the latest information means.
4 · PlanChoose a next stepDecide how to move toward the goal.
5 · Choose ActionSelect an allowed actionPick a tool call, response, or request for review.
6 · ActUse a toolThe runtime executes the chosen action.
7 · Tool ResultObserve the resultThe output becomes new context for the loop.
8 · IterateReason againRepeat when more work is needed.
9 · FinishMeet the stop conditionReturn the result, ask for approval, or stop safely.

Core sequence: Goal → Observe → Reason → Choose Action → Use Tool → Observe Result → Reason Again → Repeat → Finish

Real-world examples

Software task · Fix an API error

User asks: “Find the API error in the project and fix the code.”

Agent Loop:

  1. Read the files
  2. Analyze the error
  3. Search related code
  4. Change the code
  5. Run the tests
  6. See the test fail
  7. Change the code again
  8. Pass the test
  9. Return the result

This is a loop, not one prompt: the failed test changes what the agent observes, so it reasons again and takes another action.

Business task · Resolve a customer issue

Goal: understand a support ticket and resolve it.

Observe: read the ticket and account status.

Act: query an approved system or draft a response.

Observe result: check whether the account update worked.

Finish: respond, request approval, or hand the case to a person.

What it is NOT

Agent Loop ≠ User → LLM → Answer

One-shot call: one input produces one output.

Agent Loop: the system can use intermediate results to choose more steps.

Agent Loop ≠ One Prompt

Prompt: instructions and context given to a model.

Loop: runtime behavior that repeats model decisions and actions.

Agent Loop ≠ Infinite Loop

Safe loop: has a stop condition, limits, and failure handling.

Infinite loop: keeps running without reaching a controlled end.

Remember this

An Agent Loop is the repeated cycle of Observe → Reason → Act → Observe Result. It is the foundation that lets an Agent complete multi-step work instead of returning only one answer.

Independent explainer

Video

visual explainer · captions included
observe · reason · tool use · iteration · stop conditionMP4 · H.264 + AAC
↑