# AI agent

> An AI agent is a system where an LLM decides, in a loop, which tools to use (fetch data, call APIs, run code) to reach a goal, until it finishes or asks for help.

## Chat vs. agent

In chat, the model only answers. An agent **acts**: it picks a tool, observes the result and decides the next step.

## Building blocks

- **Model:** the LLM that makes decisions.
- **Tools:** functions with well-defined inputs and outputs.
- **Memory:** the context the agent carries between steps.
- **Guardrails:** max steps, budget, actions that require human approval.

## The risk

The more power the tools have, the bigger the damage from a mistake or a prompt injection. Production agents need least-privilege permissions, audit logs and a clear way to stop.