# What is an AI agent?

> An AI agent is software that decides its own next step. A plain program runs the steps you wrote, in order. An agent runs a loop, and the model is in charge of the loop.

## The loop

```
while not done:
  1. look at the situation (context + memory)
  2. decide what to do next
  3. call a tool to act on the world
  4. observe the result
  5. repeat
# the model chooses steps 2-3 every time; the developer does not
```

## Agent vs workflow

The most common early mistake is calling everything an "agent." Most useful AI software is a **workflow**: a fixed chain of steps that may call a model along the way, but where the developer owns the control flow. Workflows are predictable and easy to test. Reach for a true agent only when the path genuinely cannot be known in advance — when the right next step depends on what the previous step turned up.

## The four primitives

Every agent is cut from the same four pieces:

1. **The model** — The reasoning engine. It reads context and decides what to do next. Everything else exists to feed it the right input and act on its output.
2. **Tools** — Functions the model can call to act on the world: search, run code, hit an API, read a file. Good tools are the difference between a chatbot and an agent.
3. **Memory** — What the agent carries between steps and sessions. Conversation history, summaries, retrieved facts. Without it, every turn starts from zero.
4. **Prompting** — The system prompt is code. It sets the agent’s role, rules, and how it should use its tools. Treat it with the same rigor as the rest of your stack.

## How to build one

There are four paths, chosen by where ownership should sit (who builds, who runs, who decides the architecture), not by what sounds most advanced:

- [Build it yourself](https://agentailor.com/paths/build-yourself): Code-first. You own the full stack.
- [Build it with a coding agent](https://agentailor.com/paths/coding-agent): You decide the architecture. The agent writes the code.
- [Deploy an open-source agent](https://agentailor.com/paths/open-source): It already exists. Clone, configure, run.
- [Use a managed service](https://agentailor.com/paths/managed): Someone else runs the harness. You configure via API.

---
Source: https://agentailor.com/what-is-an-agent
