How do AI agents work?

An AI agent runs a loop. The model picks the next step, a tool carries it out, the model reads the result and picks again, until the task is done or it needs you.

Updated

The loop

Every agent, whatever it is called, does roughly this:

  1. Read the task and everything it knows: your request, its instructions, what it remembers.
  2. Pick one step, such as "open this page" or "run this command".
  3. Use a tool to carry out the step.
  4. Read what happened: the page's content, the command's output, an error.
  5. Decide: another step, a question for you, or a final answer.

One pass through the loop is a step. A simple task takes a handful. A research task can take dozens. Each step is a call to an AI model, which is why long tasks cost more than a chat message.

A diagram of how an AI agent works. A goal enters a loop of three stages: plan, which picks one step; act, which uses tools on the agent's computer; and check, which reads the result. If the task is not done, the loop goes round again from plan. The agent leaves the loop in one of two ways: done, when the task is finished, or ask you, when it needs a decision or approval.
An agent plans a step, acts with its tools, checks the result and repeats until it is done or needs you.

The parts

PartWhat it does
ModelChooses each step. It doesn't act by itself; it asks for a tool to be used.
ToolsThe things an agent can do: browse, run commands, read and write files, call your apps.
WorkspaceWhere tools run: your computer, a browser tab, or a computer of the agent's own.
InstructionsWho the agent is and how it should work.
MemoryFacts and preferences saved from earlier work and recalled when relevant.
SkillsWritten how-tos for tasks it does often, loaded when needed.
TriggersWhat starts a task without you: a schedule, an email, a webhook.
Guard railsApprovals, budgets, step limits and sandboxing.

Why a place to work matters

A model can only produce text. To click a button it needs something that can click. Some agents borrow your browser or your laptop, which is quick to set up but means the agent shares your files and your sign-ins. Others give the agent a computer of its own in a sandbox, so its work is apart from your devices, keeps going when you close your laptop, and can be rolled back.

What keeps the loop in check

Left alone, a loop can go wrong in a few known ways. Each has a standard answer:

How this looks in Casama

In Casama each task is a run with a timeline. You can open any run and see every step, the tool it used, what it cost and why. A run stops at 40 steps or 30 minutes, at the bot's budget, or after five failed steps in a row. Risky steps wait for approval, and a waiting run costs nothing.

Join the waitlist Run it on your own server