DEVELOPER GUIDE REASONING + ACTION

How AI agents actually work

Not a buzzword walkthrough — the actual loop running underneath: how a model decides what to do, calls a tool, reads the result, and decides again, until the task is done.

01
CONCEPT

What makes something an "agent"

A plain call to a language model is a single round trip: you send a prompt, it sends back text, and that's the end of it. It has no way to check a fact, look something up, or take a second attempt if the first answer was wrong.

An AI agent wraps that same model in a loop. Instead of answering once, the model is given a goal, a set of tools it's allowed to use, and the ability to keep going: read the result of one action, decide what to do next, and repeat until the goal is met or it decides to stop. The "agent" part isn't a different kind of model — it's the loop, the tools, and the decision-making wrapped around it.

Your prompt Model one answer, done
A plain LLM call: one request, one response, no way back in.
02
THE LOOP

The core agent loop

Nearly every agent framework, however it's branded, runs some version of the same four-stage loop. The model thinks about what to do, takes an action, observes what happened, and decides whether to act again or stop.

Reason decide next step Act call a tool Observe read the result Continue? or return answer
The loop repeats — sometimes once, sometimes dozens of times — until the model decides the goal is met.
03
ARCHITECTURE

What an agent is built from

Strip away the branding and every agent has the same four parts. The model is the reasoning engine; everything else exists to feed it information and let it affect the world.

Model reasoning + planning Instructions goal + system prompt Memory history + context Tools search, code, APIs, MCP Environment files, web, user, data
Instructions and memory feed the model; the model calls tools, which act on the environment and feed results back.
04
WALKTHROUGH

Step by step: giving an agent a task

Example task: "Find last quarter's revenue in our spreadsheet and email a summary to the finance team."

  1. The agent receives the goal

    The task, plus a system prompt describing what tools it has and how it should behave, is passed to the model as the starting context.

  2. It reasons about a first step

    The model decides it can't answer directly — it needs the spreadsheet data first — and picks a tool suited to that: a file-reading or spreadsheet tool.

  3. It calls the tool

    The agent framework executes that tool call for real — opening the file, running the query — and captures whatever comes back.

  4. It observes the result

    The tool's output (say, a table of revenue figures) is fed back into the model's context as the newest piece of information.

  5. It reasons again

    Now that it has the numbers, the model decides the next step: draft a summary, then use an email tool to send it — or it might realize it needs one more lookup first.

  6. It stops when the goal is met

    Once the model judges the task complete, it stops calling tools and returns a final answer or confirmation instead of continuing to loop.

05
PATTERNS

Common agent patterns

ReAct (Reason + Act)

The model alternates explicitly between writing out its reasoning and taking an action, one step at a time, checking results before deciding what's next.

Plan-and-execute

The model first writes a multi-step plan up front, then works through it step by step, adjusting the plan if a step's result changes what's needed.

Tool-calling loop

The simplest and most common pattern: the model is given a list of tools and just keeps calling them and reading results until it's satisfied — no separate planning stage.

Multi-agent orchestration

One orchestrator agent breaks a large task into pieces and delegates each to a specialized sub-agent — a researcher, a coder, a reviewer — then combines their outputs.

06
MULTI-AGENT

Single agent vs. multiple agents

A single agent handles everything itself, cycling through the loop with all the tools it has. A multi-agent system splits the work: an orchestrator hands off sub-tasks to smaller, more focused agents, then assembles what they return.

Orchestrator Research agent Coding agent Review agent own tools + loop own tools + loop own tools + loop
Each sub-agent runs its own reason → act → observe loop; the orchestrator only sees their final results.
07

Agent vs. chatbot vs. plain automation

AspectChatbot / single LLM callAI agentTraditional script
Decides its own stepsNo — one response per inputYes — chooses actions as it goesNo — steps are fixed in code
Uses toolsRarely, if at allYes, dynamically, as neededYes, but in a hard-coded order
Handles the unexpectedCan't react mid-taskCan re-plan after a bad resultFails or errors on the unplanned case
PredictabilityHigh — same input, same shape of outputLower — path can vary between runsHighest — always the same steps
Best fitQ&A, drafting, single-shot tasksOpen-ended, multi-step, tool-dependent tasksWell-defined, repetitive, high-volume tasks
08

Where agents actually go wrong