A plain-English guide to AI agents

AI agents are loops, not magic.

An agent is a program that repeats five steps: look, choose, do, save, and ask “done?” A language model usually helps at Choose. The program runs the tools and sets the safety limits.

A five-step loop: look, choose, do, save, and check whether the job is done. Look chooser Choose Do Save Done? the program owns the loop; the model helps choose

The five-step loop

The names may change, but most agent runs do this. If the job is not done, the program goes around again.

Observe, Decide, Act, Update, then check Stop condition Look observe Choose LLM / rules Do call tools Save keep result Done? if not done, loop

Text equivalent of the diagram

  1. Look (Observe) — Gather the message, saved facts, and tool results.
  2. Choose (Decide) — Rules or a language model suggest the next move.
  3. Do (Act) — The program checks and runs a tool or API.
  4. Save (Update) — Keep the result so the next turn can use it.
  5. Done? (Stop) — Stop, ask a person, or go around again.

You already know this kind of loop

Automation tools, scripts, and agents all repeat steps. The big change is how they choose the next move.

  • Workflow tools

    Read an item, follow a branch, call an API, save the status, and repeat.

  • Rules

    Read known fields, match a rule, act, and record the result.

  • Scripts

    Check what happened, run the next command, save progress, then stop or retry.

The loop in code

Here is the whole idea in pseudocode. The exact language and framework do not matter.

# your program owns this loop
state = initial_observations()
while not should_stop(state):
    observation = observe(state)           # messages and tool results

    action = decide(observation, policy)    # rules or language model
    if action.requires_approval:
        action = wait_for_human(action)

    if not validate(action):              # allowed? correct inputs?
        state = record_error(state, action)
        continue

    result = execute_tool(action)           # APIs do the real work
    state = update(state, result)

    state = apply_guardrails(state)       # turn, money, permission limits

finalize(state)

What a language model changes

The loop is old. A language model makes Choose more flexible — and less predictable.

It reads messy words

It can read emails, tickets, and partial instructions, then suggest a clear next move.

Its answer can vary

The same input may get a different suggestion. Log runs and test many cases.

It can pick from more tools

It can choose among registered tools without a giant rule table. The program still checks each choice.

Game: swap the chooser

Run ticket #8842 with a Rule card, then swap in a Language card. Guess moves, handle a timeout, and decide when a person should step in. About 4 minutes; no login or network.

Bonus game: add safety locks

Turn program-owned checks on and off, then test five fixed suggestions. See which risky actions get blocked. No real model or network.

Pick the simplest thing that works

Many real systems mix these three.

Clear choices

Rules & scripts

Use for clear inputs and stable choices. Fast, cheap, and easy to test.

Pick this when you can write the decision table and trust it for a while.

Mixed choices

Hybrid loops

Rules handle common cases. A language model reads messy text. People approve sensitive moves.

Pick this when most work is simple but a few cases need judgment.

Open choices

LLM agent loops

Use for open-ended work with many tools and changing instructions.

Pick this when rules would become a maze — and you can add checks, logs, and review.

What can go wrong

Agent loops fail in ordinary ways. Plan for them.

  • Tools fail — APIs time out and return bad data. Save the error, then retry or ask a person.
  • Text can be hostile — A ticket or web page may contain bad instructions. Treat it as data and check every suggestion.
  • Turns cost time and money — Set budgets for model calls, tools, and total steps.
  • History gets too long — Keep useful facts and archive the rest.
  • Loops can spin forever — Set a turn limit and clear stop rules.
  • Tools have real power — Give each tool only the access it needs. Ask a person before sensitive actions.
  • Model answers can vary — Test many runs and keep logs, not just one happy path.

Takeaway

An agent is a loop. The language model usually helps Choose. Your program still owns the tools, saved facts, safety checks, and stop button.

Tiny glossary

Policy
The chooser. It can be rules, scores, or a language model.
Observation
What the chooser can see this turn: messages, facts, and tool results.
Tool
A function or API the program can check and run.
Guardrail
A program-owned check for steps, money, access, or content.
Stop condition
A rule that ends the loop: done, too many turns, an error, or a human halt.

Primary sources