How AI works

What is an AI agent? A simple explanation with examples

An AI agent is an AI that takes actions toward a goal: it plans, uses tools like search or code, checks the results and keeps going. How agents work, real examples and the risks.

4 min read

Short answer

An AI agent is an AI system that works toward a goal by taking actions, not just answering questions. It's usually a large language model running in a loop: it decides on a step, uses a tool such as web search, code or an app, looks at the result and decides what to do next, until the task is done. A answers; an agent acts.

Chatbot vs agent

Ask a chatbot "what's a good flight to Rome next Friday?" and it gives you advice. Ask an agent, and it might search flight sites, compare prices, check your calendar and come back with options, perhaps even book one if you've allowed it. The difference is action: an agent can do things in the world through tools, over several steps, on its own.

How an AI agent works: think, act, observe

Most agents follow a simple loop, described in the 2022 ReAct research paper:

  1. Think. The language model reads the goal and everything so far, and decides the next step.
  2. Act. It calls a tool: searches the web, runs some code, reads a file, sends a request to an app.
  3. Observe. The tool's result is added to the model's context.
  4. Repeat until the goal is met, or it decides to ask you.

The model never touches the outside world directly. It writes a structured request, like "search: flights Rome Friday", and the surrounding program carries it out. Open standards such as the Model Context Protocol (MCP) make it easier to plug the same tools into different AI apps. The agents in depth lesson goes further.

What "tools" means

  • Search and browsing: find and read current information.
  • Code: run calculations, analyse data, test software.
  • Files and documents: read your reports, spreadsheets or a company knowledge base, often through RAG.
  • Apps: calendars, email, shops, project trackers, through their APIs.
  • The computer itself: some agents can look at a screen and click and type like a person.

Examples of AI agents

  • Coding agents that read a codebase, make changes, run the tests and fix what fails.
  • Research agents that search many sources and write a summary with citations.
  • Customer support agents that look up an order, check the policy and issue a refund within set limits.
  • Personal assistants that sort your inbox, draft replies and schedule meetings.
  • Data agents that query a database, make charts and explain the trend.

Why agents are hard to get right

  • Errors compound. A small mistake at step 3 can derail step 10. Long tasks fail more often than short ones.
  • Hallucinations can turn into actions. A made-up fact in a chat is annoying; an agent acting on it can cost money.
  • Prompt injection. A web page or email an agent reads can contain hidden instructions trying to hijack it. See prompt injection.
  • Cost and speed. Many steps means many model calls.

Agents vs workflows

Not everything needs a fully independent agent. Anthropic's guide "Building effective agents" separates workflows, where the steps are fixed in code and the model fills them in, from agents, where the model decides the steps itself. Workflows are more predictable; agents are more flexible. Many good products start simple and add autonomy only where it helps.

To see how agents fit with retrieval and reasoning, read RAG and agents and reasoning models. New to the basics? Start with how ChatGPT works.

Key takeaways

  • Agents = a language model + tools + a loop of plan, act and observe.
  • Tools let agents search, run code, read files and use apps.
  • Mistakes can add up over many steps, so oversight matters.
  • Give agents only the access they need, and check before anything irreversible.

Learn it properly, free

Terms in this post

Questions

What is the difference between an AI agent and a chatbot?

A chatbot answers in conversation. An AI agent works toward a goal by taking actions with tools, such as searching, running code or using apps, over several steps, deciding what to do next based on the results.

Is ChatGPT an AI agent?

Plain ChatGPT chat is a chatbot. When it searches the web, runs code or completes multi-step tasks with tools on its own, it is acting as an agent. Many AI assistants now have both modes.

What are examples of AI agents?

Coding agents that edit and test software, research agents that search and summarise sources, support agents that look up orders and process refunds, and assistants that manage email and calendars.

Are AI agents safe?

They can be, with limits. Give agents only the permissions they need, keep logs, watch for prompt injection in content they read, and require human approval for actions that can't be undone.

Sources and further reading

Read next

Spotted a mistake? Suggest an edit