What is an AI agent? How AI agents work
Also called LLM agent, AI agents, autonomous agent
Definition
An AI agent is a software system in which a large language model runs in a loop, calling tools, reading their results, and repeating until the task is complete or a stop condition is reached.
An AI agent is a software system in which a large language model runs in a loop: it receives a goal, emits a tool call, reads the result, and repeats until the task is complete or a stop condition is reached. The tools can be search APIs, code interpreters, databases, or other services. What separates an agent from a single model call is that the model's output, not a fixed script, determines the next step.
How an AI agent works#
An AI agent works by cycling through three steps. The model reads its current context. The model outputs either a final answer or a structured tool call. The application runs that tool and appends the result to the context. The loop repeats until the model returns an answer, the run hits an iteration limit, or a human stops it.
The pattern traces back to ReAct (Yao et al., 2022), which interleaved reasoning traces with actions so a model could gather information from external sources partway through a task. Production agents add three supporting pieces: a tool layer, often exposed through the Model Context Protocol; agent memory for state that outlives one context window; and guardrails that stop sensitive tools from running without approval.
AI agent vs agentic workflow#
An AI agent differs from an agentic workflow in who controls the sequence of steps. Anthropic's Building effective agents defines workflows as systems where LLMs and tools are orchestrated through predefined code paths, and agents as systems where the LLM directs its own process and tool usage.
| Agentic workflow | AI agent | |
|---|---|---|
| Control flow | Written by developers in code | Produced by the model at run time |
| Predictability | High | Lower |
| Best fit | Well-defined, repeatable tasks | Open-ended tasks whose steps are unknown in advance |
Workflows are cheaper to test and debug. Agents handle problems whose steps cannot be listed ahead of time. Many production systems combine the two, running a workflow for the outer process and an agent for one open-ended step inside it.
Why AI agents matter#
AI agents matter because they let one model complete multi-step tasks, such as debugging code, researching a question, or triaging a support ticket, that a single prompt cannot finish. The cost is variance: each extra loop adds latency, tokens, and another chance for error, so agents need evaluation and tracing before they reach production.
For a longer treatment, read what AI agents are and how they are built, or compare the main AI agent frameworks.
Related terms
Guides that cover ai agent
- What are AI agents? How agents work and when to use one
- AI agent frameworks compared: LangGraph, CrewAI, ADK, and more
- What is tool calling? How LLM function calling works
- How to build an AI agent: a step-by-step guide in Python
- Agentic workflows: five patterns and when to use each
- AI coding agents: how they work and how the major tools compare
- AI agent evaluation: metrics, graders, and how to test agents
- LLM benchmarks explained: what they measure and how to read them
- A2A protocol vs MCP: differences and when to use each
- LLM evaluation: a practical guide to evals, metrics, and judges
Cite this definition
The AI Engineering Editors. "What is an AI agent? How AI agents work." The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/ai-agent
- Title
- What is an AI agent? How AI agents work
- Author
- The AI Engineering Editors
- Publisher
- The AI Engineering
- Updated