An AI agent is a system in which an LLM repeatedly chooses the next action towards a goal, carries it out through tools, and looks at the result, until the goal is reached or it stops. A chatbot answers once, and an agent acts over many steps.
Chatbot and agent
| Point | Chatbot | Agent |
|---|---|---|
| Work | You ask, it replies once | Works towards a goal over many steps |
| Tools | None | Searches, adds to cart, pays |
| A mistake is | A wrong sentence that you can ignore | A wrong action, such as money spent or an order placed |
Remembering tip
A chatbot is a knowledgeable friend on the phone. An agent is a new intern who has been given the company credit card, so it needs training, checking, a spending limit and supervision.
Parts of an agent
| Part | Role |
|---|---|
| LLM | The brain, which chooses the next action |
| Tools | The hands, which act on the world |
| Memory | The notebook, which keeps what happened |
| Loop | Keeps going until the goal is reached |
| Goal | Says when to stop |
Workflow or agent
The difference is who decides the next step (Anthropic, 2024):
| Type | Who decides the next step | Example in a shop |
|---|---|---|
| Workflow | Your code, fixed in advance | Always search, then filter, then show the top 3 |
| Agent | The LLM, while it runs | Search again, compare, or go to checkout |
Use the simplest option that works. An agent is more flexible, but it is slower, costlier and riskier.
Notation
| Symbol | Meaning |
|---|---|
| The goal, in the words of the user | |
| The action at step : a tool call, or "finish" | |
| The observation at step : what the tool returned | |
| The history: everything seen and done so far | |
| The policy: the LLM, with weights , that picks actions | |
| The step limit |
Parts of the formula:
- the LLM reads the goal and the history, and writes the next action
- means the action is sampled from the probabilities of the LLM, so 2 runs can differ
- the environment, such as the shop, carries out the action and returns an observation
- the loop stops when the LLM writes "finish", or after steps
- the history grows at every step, because each step adds one action and one observation, which matters for cost
The LLM only decides, and the code does. That gap is where every safety control lives, see Guarded Agent Loop.
The next question is how the LLM should choose its actions, see ReAct.