An AI agent is a system in which a language model pursues a goal in several steps and uses tools along the way. It looks at the situation, plans the next step, acts and checks the result. It repeats that until the task is done or it gets stuck.
Picture an intern to whom you do not explain every move, only the goal: “Find out which competitors changed their prices.” They work out a route, open web pages, jot down results, notice that one page will not load and try another way. A chatbot would give you an answer from memory instead.
1. How an agent works
The core is a loop. A language model alone can only produce text. The loop around it is what turns it into an agent.
1.1 The loop
- Perceive: The model receives the goal and everything that has happened so far as text in the prompt.
- Plan: It works out which step makes sense next and picks a tool.
- Act: The program around the model actually runs the tool, for example a search or a test.
- Check: The result goes back into the history. The model decides whether to continue, take another route or stop.
The pattern comes from research. In 2022, a team around Shunyu Yao showed with “ReAct” that models work better when they alternate between reasoning and acting and fetch information from outside. In its guide to agents, Anthropic stresses another point: at each step the agent needs real feedback from its environment, such as a test result, so it can judge its progress. There is usually also a cap on the number of steps.
1.2 The tools
A tool is a function the model can request. You describe to the model what the function does and what inputs it needs. The model then writes not running text but a structured call, such as “search for this term”. This method is called function calling. Your program runs the call and returns the result. So the model itself never executes anything.
So that not every application has to wire up its tools from scratch, the Model Context Protocol (MCP) provides an open standard. It connects agents to data sources and services through a shared interface. Add knowledge sources that the agent searches via RAG, and instructions from the system prompt that set its role and limits. For coding agents, that is often a project file such as AGENTS.md.
2. Chatbot, workflow or agent?
Not everything called an “agent” is one. Anthropic distinguishes two designs. In workflows, a language model and tools run along predefined code paths. In agents, the model directs the process and tool use itself. The table sorts the three variants:
- Who decides the flow?
- You, with every message
- Good for
- Questions, texts, ideas
- Price of autonomy
- Low. Each answer is a single call.
- Who decides the flow?
- Your code, in fixed steps
- Good for
- Recurring tasks with a known flow, such as classifying and forwarding mail
- Price of autonomy
- Medium. Predictable, but rigid.
- Who decides the flow?
- The model, step by step
- Good for
- Open-ended tasks where the path is unclear in advance, such as finding a bug in code
- Price of autonomy
- High. More cost, and errors can compound.
Anthropic’s advice: take the simplest solution that works. A workflow is often better than an agent because it is cheaper and more predictable. An agent only pays off when the path to the goal cannot be set in advance.
3. What is agentic AI?
Agentic AI is the umbrella term for systems that work on this principle: they pursue a goal and choose their steps themselves. The term describes a property, not a single product. A system can be more or less agentic, depending on how much room for decisions the model has.
Two distinctions help:
- Versus generative AI: Generative AI produces content on request and is done afterwards. Agentic AI puts such models into a loop and lets them act. It is not an alternative but a layer built on generative AI.
- Versus workflows and classic automation: Automation follows a fixed plan that a person designed beforehand. An agentic system decides during the work which step to take next and adapts when something goes wrong.
4. Where agents are used today
- Coding agents: They read your project, write changes, run tests and fix errors until the tests pass. Our harness directory lists 35 active coding agents, 16 of them open source and 29 with a terminal interface.
- Computer use: The model sees the screen, moves the mouse and types on the keyboard. Anthropic introduced this in October 2024. It allows tasks in programs that offer no interface.
- Research agents: Tools such as Deep Research search, read and compare many sources and summarize them in a report.
For figures on how widespread agents are, see the article AI agent statistics.
5. Worked example: one run, step by step
An invented example: a coding agent is meant to repair a failing test. The log shows how the loop feels:
Goal: The test “calculate_discount” fails. Make it pass.
Step 1 Plan: First see the error.
Tool: run tests
Result: 1 failure, expected 90.0, got 100.0
Step 2 Plan: Read the function.
Tool: open file (discount.py)
Result: Discount is calculated but never subtracted.
Step 3 Plan: Add the subtraction.
Tool: edit file (discount.py, line 12)
Result: Change saved.
Step 4 Plan: Check whether it helps.
Tool: run tests
Result: 12 of 12 tests passed.
Done I added the missing subtraction in discount.py.
All tests pass.Note step 4. The agent does not claim that it works, it checks. This checking against reality is what separates a good agent from a model that merely suggests code.
6. A worked example: what the loop costs
In a chat, you pay for the question and the answer. An agent sends the complete history to the model anew at every step: instructions, tool descriptions, all earlier calls and results. The history grows, and with it the number of tokens that must fit into the context window.
An invented example with 10 steps: the start, made of system prompt, tool descriptions and task, comes to 5,000 tokens. Each step adds about 2,000 tokens (tool call and result), and the model writes about 300 tokens per step. The calculation uses the price of Claude Sonnet 5.5.
- Input tokens
- 5,000
- Cost (input and output)
- $0.013
- Input tokens
- 7,000
- Cost (input and output)
- $0.017
- Input tokens
- 13,000
- Cost (input and output)
- $0.029
- Input tokens
- 23,000
- Cost (input and output)
- $0.049
- Input tokens
- 140,000
- Cost (input and output)
- $0.31
Across all steps, 140,000 input tokens pass through the model, about 28 times the start. That costs $0.31. A single answer with the same start would come to $0.013. So the run costs a multiple of a single answer, even though each step is small on its own.
You can bring the bill down. With prompt caching, the provider remembers the unchanged beginning of the prompt, and cache reads cost at most a tenth of the normal input price at Anthropic. Since an agent’s beginning stays the same at every step, the effect is strong.
7. Limits and misconceptions
- Errors add up. An invented calculation: if each step succeeds with 95% probability and the steps are independent, ten steps in a row work in only about 60% of runs (0.95 to the power of 10 is about 0.6). Anthropic names higher costs and compounding errors as the price of autonomy and recommends extensive testing in sandboxed environments. The model can also hallucinate, for example misread a tool result or report a step as done that never ran.
- Prompt injection. An agent reads outside content, such as web pages, emails or documents. If a hidden instruction sits there, it may follow it as if it came from you. Researchers around Kai Greshake demonstrated this on real applications in 2023. More in the entry on prompt injection.
- Cost and runtime. See the worked example: more steps mean more tokens. Without a cap on the number of steps, an agent can get stuck in a loop and burn money.
- Access rights. What the agent can do depends on the tools you give it. An agent with write access to your files can also delete them. Grant only the rights the task needs, and have risky steps such as deleting, paying or sending confirmed by you.
- Misconception: “agent means autonomous”. In practice many agents run with a human in the loop who checks intermediate states. Full autonomy is not always the goal.
8. What does this mean for you?
- Ask first whether you need an agent. If the flow is known, a workflow is enough. It is cheaper and more predictable.
- Set a checkable goal. “All tests pass” works better than “Improve the code”. The agent needs a criterion against which to measure its result.
- Limit rights and steps. Set a cap on the number of steps and grant access only to what is needed. Test new agents in a sandboxed environment.
- Keep control over risky actions. Confirmations for deleting, paying and sending cost seconds and prevent expensive mistakes.
- Spot-check. Read the log of a run, not only the result. That shows whether the agent worked cleanly or just got lucky.
- Distrust outside content. If you let an agent read web pages or mail, treat their content as untrusted.
