← Lessons

quiz vs the machine

Silver1080

Machine Learning

The LLM Agent Loop

How a model turns into an agent by looping through tools.

4 min read · intro · beat Silver to climb

The LLM Agent Loop

A bare language model only predicts text. An agent wraps that model in a loop that lets it observe results, decide, and act repeatedly until a goal is reached.

The basic cycle

  • The model receives the task plus any context and decides on a next step.
  • If the step is a tool call, the runtime executes it and feeds the result back.
  • The model reads that observation and decides again, continuing until it emits a final answer.

Why the loop matters

A single forward pass cannot fetch live data, run code, or check its own work. The loop converts a static predictor into something that interacts with the world across many turns. Each turn appends new information to the running context, so the model effectively accumulates evidence over time.

Stopping conditions

The loop must terminate. Common stops include the model producing a final answer with no tool call, hitting a maximum step count, or tripping a budget limit. Without a guard, a confused agent can loop forever, so a step cap is a basic safety requirement.

Key idea

An agent is a language model placed inside a decide act observe loop that runs until a goal or a limit is reached.

Check yourself

Answer to earn rating on the learn ladder.

1. What converts a plain language model into an agent?

2. Why does an agent loop need a stopping condition?