---
title: "What is an AI agent? How AI agents work"
description: "An AI agent is a system where a language model runs in a loop, calling tools and reading results until a task is done. See how agents work and when to use one."
type: "glossary-term"
canonical_url: "https://theaiengineering.com/glossary/ai-agent"
markdown_url: "https://theaiengineering.com/glossary/ai-agent.md"
topic: "AI agents"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
updated: "2026-11-06"
keywords: ["AI agent","LLM agent","AI agents","autonomous agent"]
citation: "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"
---

# What is an AI agent? How AI agents work

Also called LLM agent, AI agents, autonomous agent.

> **Definition of AI agent:** 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](https://theaiengineering.com/glossary/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](https://theaiengineering.com/glossary/tool-calling). 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](https://arxiv.org/abs/2210.03629) (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](https://theaiengineering.com/glossary/model-context-protocol); [agent memory](https://theaiengineering.com/glossary/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](https://www.anthropic.com/engineering/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](https://theaiengineering.com/glossary/llm-evaluation) and tracing before they reach production.

For a longer treatment, read [what AI agents are and how they are built](https://theaiengineering.com/articles/what-are-ai-agents), or compare the main [AI agent frameworks](https://theaiengineering.com/articles/ai-agent-frameworks).

## Related terms

- [Agentic AI](https://theaiengineering.com/glossary/agentic-ai): Agentic AI is the class of AI systems that pursue a goal through multiple steps, using a language model to plan, call tools, and act on the results with limited human input.
- [Tool calling](https://theaiengineering.com/glossary/tool-calling): Tool calling is an LLM capability in which the model, given a list of tool definitions, outputs a structured request naming a tool and its arguments, which the application executes and returns.
- [Agent memory](https://theaiengineering.com/glossary/agent-memory): Agent memory is the set of mechanisms that let an AI agent keep and retrieve information beyond a single model call, from the current context window to external stores that persist across sessions.
- [Multi-agent system](https://theaiengineering.com/glossary/multi-agent-system): A multi-agent system is an AI architecture in which several language-model agents, each with its own prompt, tools, and context, work on parts of a task and pass results to one another.
- [Model Context Protocol (MCP)](https://theaiengineering.com/glossary/model-context-protocol): Model Context Protocol (MCP) is an open protocol, introduced by Anthropic in November 2024, that standardizes how AI applications connect to external tools, data sources, and prompts through MCP servers.
- [ReAct agent](https://theaiengineering.com/glossary/react-agent): A ReAct agent is an AI agent that alternates a written reasoning step, an action such as a tool call, and an observation of the result, repeating the cycle until it can answer.
- [Agent sandbox](https://theaiengineering.com/glossary/agent-sandbox): An agent sandbox is an isolated execution environment in which an AI agent runs code, shell commands, or a browser, with enforced limits on the files, network hosts, and credentials it can reach.
- [Human-in-the-loop](https://theaiengineering.com/glossary/human-in-the-loop): Human-in-the-loop (HITL) is an agent design in which the run pauses at defined checkpoints, such as before a sensitive tool call, so a person can approve, edit, or reject the action.

## Guides that cover ai agent

- [What are AI agents? How agents work and when to use one](https://theaiengineering.com/articles/what-are-ai-agents): AI agents are LLM systems that call tools in a loop until a task is done. Learn how the loop works, agents vs agentic AI, examples, failure modes, and limits.
- [AI agent frameworks compared: LangGraph, CrewAI, ADK, and more](https://theaiengineering.com/articles/ai-agent-frameworks): An AI agent frameworks comparison of LangGraph, LangChain, CrewAI, the OpenAI, Claude, and Google SDKs, Pydantic AI, Mastra, and more, by language and license.
- [What is tool calling? How LLM function calling works](https://theaiengineering.com/articles/tool-calling): Tool calling lets an LLM request actions from your code through structured calls. Learn the request loop, parallel calls, structured outputs, security, and MCP.
- [How to build an AI agent: a step-by-step guide in Python](https://theaiengineering.com/articles/how-to-build-an-ai-agent): Learn how to build an AI agent from scratch in Python: when you need one, tool schemas, the agent loop, stop conditions, guardrails, evals, and tracing.
- [Agentic workflows: five patterns and when to use each](https://theaiengineering.com/articles/agentic-workflows): Agentic workflows run LLM and tool calls through steps fixed in code. Learn five patterns, their cost and latency, failure modes, and when to use an agent.
- [AI coding agents: how they work and how the major tools compare](https://theaiengineering.com/articles/ai-coding-agents): AI coding agents compared: how they differ from autocomplete, the four main categories, a comparison table of major tools, and how to evaluate and secure them.
- [AI agent evaluation: metrics, graders, and how to test agents](https://theaiengineering.com/articles/ai-agent-evaluation): AI agent evaluation guide: measure task success, tool use, safety, cost, and pass^k reliability with code graders, LLM judges, eval sets from traces, and CI.
- [LLM benchmarks explained: what they measure and how to read them](https://theaiengineering.com/articles/llm-benchmarks): LLM benchmarks explained: what MMLU-Pro, GPQA, SWE-bench, LiveCodeBench, ARC-AGI, and LMArena measure, why scores saturate, and how to read a leaderboard.
- [A2A protocol vs MCP: differences and when to use each](https://theaiengineering.com/articles/a2a-vs-mcp): A2A protocol vs MCP: A2A connects AI agents to other agents, and MCP connects an agent to tools and data. Compare agent cards, tasks, transports, and security.
- [LLM evaluation: a practical guide to evals, metrics, and judges](https://theaiengineering.com/articles/llm-evaluation): LLM evaluation for engineers: build eval datasets, pick metrics, calibrate LLM-as-a-judge, evaluate RAG and agents, and gate every release in CI.

Part of the [AI agents](https://theaiengineering.com/topics/ai-agents) topic hub.

## 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: 2026-11-06
- URL: https://theaiengineering.com/glossary/ai-agent
- Markdown: https://theaiengineering.com/glossary/ai-agent.md
