Skip to main content

What Is an AI Agent? Definition, Examples, Costs

An AI agent pursues a goal in several steps and uses tools. How the loop works, what it costs, where agents fail, and what agentic AI means. With examples.

FHFinn Hillebrandt
Last updated:
Technology
What Is an AI Agent? Definition, Examples, Costs

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

  1. Perceive: The model receives the goal and everything that has happened so far as text in the prompt.
  2. Plan: It works out which step makes sense next and picks a tool.
  3. Act: The program around the model actually runs the tool, for example a search or a test.
  4. 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:

Chatbot
Who decides the flow?
You, with every message
Good for
Questions, texts, ideas
Price of autonomy
Low. Each answer is a single call.
Workflow
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.
Agent
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, Building effective agents
gradually.ai

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:

text
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.

Step 1
Input tokens
5,000
Cost (input and output)
$0.013
Step 2
Input tokens
7,000
Cost (input and output)
$0.017
Step 5
Input tokens
13,000
Cost (input and output)
$0.029
Step 10
Input tokens
23,000
Cost (input and output)
$0.049
Total (10 steps)
Input tokens
140,000
Cost (input and output)
$0.31
Own calculation, price of Claude Sonnet 5.5
gradually.ai

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.

Frequently Asked Questions

An AI agent gets a goal instead of a single question and works through it in several steps. It looks at the situation, plans the next step, calls a tool (search, files, code, a browser) and checks the result. Then it decides whether to continue or stop. A language model does the thinking, and the tool does the work in the real world.

Generative AI produces content such as text, images or code in response to a request. Agentic AI uses such models to complete tasks on its own: it plans, calls tools, checks intermediate results and keeps going until the goal is reached. So agentic AI builds on generative AI and wraps a loop of actions around it. A chatbot that only answers is generative AI. A system that searches your inbox, coordinates appointments and sends invitations is agentic.

“Agentic” describes a system that acts toward a goal on its own rather than just answering. It decides which step to take next, uses tools and adjusts when something goes wrong. The word comes from “agent”. It 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.

At its core, no. A normal chat is a dialogue: you ask, the model answers. It turns agentic as soon as the model uses tools and steers several steps itself, for example when it researches on the web, runs code or works through a task in many intermediate steps. Then it acts as an agent. The line is blurry. What matters is whether the model decides the next step itself or whether a fixed sequence simply runs.

There are agents for different jobs. Coding agents write and test code in your project. Our harness directory currently lists 35 of them. Research agents such as Deep Research search many sources and write a report. Computer-use agents operate programs through the screen and mouse. On top of that come voice agents for phone and customer service, and personal agents that manage emails, calendars and files on your behalf.

There is no fixed price. It depends on how you use the agent. With a subscription you pay a flat fee, and through the API you pay for the tokens used. An agent needs far more of them than a chat, because it resends the history so far at every step. In our worked example with Claude Sonnet 5.5, a run of 10 steps costs about $0.31, while a single answer with the same start costs $0.013. You can compare subscription prices in the AI subscription comparison.

For a start, the agent features many chatbots already include are enough: research across several sources, analyzing files, working through tasks in steps. If you want to build programs or websites, you can try a coding agent. Several are open source and listed in the harness directory. Agents that reach into your emails or files need more caution. More on that in the article about personal AI agents. Building your own costs nothing for the software, but it does cost tokens or hardware for a local model.
Sources and References
FH

Finn Hillebrandt

AI Expert & Blogger

Finn Hillebrandt is the founder of Gradually AI, an SEO and AI expert. He helps online entrepreneurs simplify and automate their processes and marketing with AI. Finn shares his knowledge here on the blog in 50+ articles as well as through the AI Business Club.

Learn more about Finn and the team, follow Finn on LinkedIn, join his Facebook group for ChatGPT, OpenAI & AI Tools or do like 17,500+ others and subscribe to his AI Newsletter with tips, news and offers about AI tools and online business. Also visit his other blog, Blogmojo, which is about WordPress, blogging and SEO.