Skip to content
AI Dev Toolkit.
Esc
  • Loading…

AI glossary · Agents and tools

What is an AI agent?

Also called: LLM agent, agentic loop, agent loop

Definition

An AI agent is a program in which a language model works towards a goal by repeatedly choosing a tool to call, reading the result and deciding the next step, until the task is done or a stop condition is reached.

Explained

How does an AI agent work?

Anthropic draws a useful line between workflows, where your code fixes the sequence of model and tool calls in advance, and agents, where the model decides its own steps and which tools to use. Underneath, an agent is a loop: send the goal and the available tools, let the model ask for a tool call, run it, send back the result, and repeat.

The model never runs anything itself. Your code, often called the harness, executes each call and returns real results from the environment, such as test output or a file’s contents. That feedback is what lets an agent notice a mistake and fix it. The loop ends when the model replies without asking for a tool, or when a limit you set, such as a maximum number of turns, stops it.

Coding agents such as Claude Code are this loop with file, search, shell and web tools, plus context management: project instructions in CLAUDE.md, subagents for side tasks, and compaction when the context window fills up.

Example

Token growth in a 7-request coding loop

Claude Code’s docs walk through “fix the failing tests” as six tool calls: run the tests, read the error, search for the source, read it, edit it, and run the tests again. Each call is a new request, and each request sends the original messages, every earlier reply and every tool result again.

Assume a 15,000-token start (system prompt, tool definitions, project instructions and your message) and about 2,000 tokens added per tool round trip. These sizes are illustrative; the shape is not. The last request carries 27,000 tokens, but the seven together send 147,000, which is 5.4 times as much. At Claude Sonnet 5.5’s input price of $2 per million tokens that is $0.29 of input for one small fix, before output and before any prompt caching discount.

Input tokens sent per request (illustrative sizes)
RequestWhat the agent doesInput tokens sent
1Run the test suite15,000
2Read the failure output17,000
3Search for the relevant source files19,000
4Read those files21,000
5Edit the code23,000
6Run the tests again25,000
7Reply with the fix (no tool call)27,000
Total147,000

Price from our daily data, 2026-11-28. Output tokens are not included.

Cost and quality

Why does an agent’s token cost grow every turn?

Because every turn re-sends the conversation, an agent’s input bill grows roughly with the square of its number of turns when each turn adds a similar amount. Long tasks, large tool results and many tool definitions all multiply it. Prompt caching, shorter tool outputs and fewer turns are the main levers.

Quality depends on the feedback the agent can get. Anthropic stresses that agents need ground truth from the environment at each step, such as tests that pass or fail, and recommends starting with the simplest solution and adding an agent only when a fixed workflow falls short.

Don’t mix up

AI agent vs chatbot: what’s the difference?

AI agent vs chatbot
A chatbot answers from what it was given in one reply. An agent takes actions through tools and loops on the results, so it can run code, edit files or query systems before it answers.
Agent vs workflow
In a workflow, your code decides the order of steps and the model fills in each one. In an agent, the model decides the steps. Workflows are more predictable and cheaper; agents handle tasks whose steps you can’t list in advance.

FAQ

Questions people ask

Is ChatGPT an AI agent?

A normal ChatGPT reply is an assistant answering a message, sometimes after a built-in tool such as web search, not an open-ended agent loop. OpenAI has offered agent features in ChatGPT that plan and carry out multi-step tasks with a browser and other tools, and its help centre now points longer multi-step tasks to ChatGPT Work. Product names and plans change often, so check OpenAI’s help centre for what is current.

What are the main parts of an AI agent?

A language model that decides the next step, a set of tools it can ask for (search, code execution, file edits, APIs), a harness that runs those calls and sends back the results, and a stop condition such as a turn limit. Coding agents add project instructions, such as CLAUDE.md for Claude Code, and ways to manage the context window as it fills.

Go deeper

Try it and read more

Related

All 41 terms in the AI glossary

Keep exploring