What Is an AI Agent?

An AI agent is a program in which a large language model (LLM) decides which tool to call next, reads the result, and repeats until the task is done or a limit is reached. It has four parts: a model, a set of tools, a loop, and a stop condition. A chatbot answers; an agent acts, then checks what its action produced.

This page describes the single agent as a unit of software. The broader idea of AI systems that act with some autonomy is covered in agentic AI.

How an AI Agent Works

Anthropic’s engineering guide describes agents as “LLMs using tools based on environmental feedback in a loop” and separates them from workflows, where the code path is fixed in advance (Anthropic, Building effective agents). The pattern goes back to research such as ReAct, which showed in 2022 that a model performs better when it alternates reasoning steps with actions and reads the result of each action before continuing (Yao et al., ReAct). In practice the loop looks like this:

  1. Input. The agent receives a goal, a system prompt with rules, and a list of tools with their descriptions and argument schemas.
  2. Decide. The model returns either a final answer or one or more tool calls. A tool call is a structured request such as “run this SQL query” or “fetch this ticket”. See function calling.
  3. Act. Ordinary application code executes the call. The model never touches a database or an API directly; the code does, with the permissions the code was given.
  4. Observe. The result goes back into the model’s context as a new message.
  5. Stop or continue. The loop ends when the model returns a final answer, when a maximum number of steps or a token budget is reached, or when a guard condition fires, such as an action that needs human approval.

The stop condition is part of the design, not an afterthought. Without a step limit an agent that misreads a tool error can retry the same call until the budget runs out.

The Four Parts

PartWhat it decidesTypical choices
ModelReasoning quality, cost, latencyHosted models from OpenAI, Anthropic, Google, or open-weight models
ToolsWhat the agent can read and changeAPIs, database queries, search, code execution, Model Context Protocol servers
LoopHow steps are sequenced and storedA framework such as LangGraph, or a short hand-written loop
Stop conditionWhen the run endsFinal answer, step cap, budget cap, approval gate

When to Use an Agent and When Not

Use an agent when the number and order of steps cannot be known in advance. Answering “why did revenue drop in the north region last month” may need two queries or eight, depending on what the first ones return.

Do not use an agent when the steps are known. Classifying an invoice, extracting fields and posting them to an accounting system is a fixed pipeline. A workflow with one model call per step is cheaper, faster and easier to test. Anthropic’s guide gives the same advice: start with the simplest solution and add agent behaviour only when it measurably helps.

Common Failure Modes

  • Wrong tool or wrong arguments. Vague tool descriptions are the most frequent cause. The fix is better descriptions and stricter argument schemas, often with structured outputs.
  • Loops. The agent repeats a failing call. A step cap and an explicit error message from the tool break the cycle.
  • Context overflow. Long tool outputs push the original instructions out of the context window. Tools should return summaries or the fields that matter.
  • Unclear errors. A tool that fails with a stack trace or an empty result gives the model nothing to correct. Errors should say what went wrong and what input would work.

Risks that come from how much autonomy and access an agent is given, such as excessive agency and acting on injected instructions, are covered under agentic AI.

A multi-agent system combines several agents. Agent orchestration is the control layer that runs them. Agent memory keeps information between steps and sessions. A computer-use agent is an agent whose tools are a screen, a mouse and a keyboard.

In Practice

Our AI agent development team writes the tool list before the system prompt. Each tool gets one narrow purpose, a typed argument schema and an error message the model can act on, and the loop gets an explicit step cap; many early failures trace back to two tools whose descriptions overlap. The report AI assistant case shows the pattern on a text-to-SQL task: the model writes the query, the database returns the figure, and the answer shows both.

Recorded runs, including the ones that went wrong, are kept as regression tests, so a new tool description or model version is checked against them before release. Tracing each step is covered under AI observability.

Back to Glossary

Let's talk about your project

We'll help you harness AI and ML technologies to create innovative software solutions

File requirements: pdf, doc, docx, rtf, ppt, pptx — max 15 MB

No file selected