Lesson 21 of 36 · Track 3: Build with AI

What is an AI agent? How agents think, act and check their work

Beginner10 min5 steps2 videosFree · no login
The short answer

An AI agent is an AI system that works toward a goal on its own: it decides the next step, uses a tool such as web search or code, looks at the result, and repeats until the job is done. A workflow follows steps you fixed in advance; an agent chooses its own steps. Agents suit open-ended tasks, but they need limits, approvals and testing.

  1. 1

    What makes something an agent?

    A chatbot answers. An agent gets things done. OpenAI’s practical guide defines agents as "systems that independently accomplish tasks on your behalf".

    Think of the difference between a friend who explains how to renew your passport and a travel agent who fills the form, books the appointment and only calls you when a document is missing. The second one is acting for you.

    Every agent has three parts, according to the same guide: a model that reasons, tools that let it look things up and take actions (the tool calling from lesson 12), and instructions that set its job and its limits.

    1. Model (the brain)
    2. Tools (the hands)
    3. Instructions (the rules)
  2. 2

    Workflow or agent: what is the difference?

    Anthropic’s "Building effective agents" draws a clear line. In a workflow, the model and tools follow "predefined code paths": you wrote the steps. In an agent, the model "dynamically directs" its own process and decides which tool to use next.

    Example workflow: every support email is sorted into a category, a reply is drafted, and a human approves it. Same steps every time. Example agent: "find out why this customer was charged twice and fix it", where the steps depend on what it discovers.

    Anthropic’s advice is to find the simplest thing that works. Often one well-written model call with good context is enough. Workflows suit tasks with clear steps; agents suit tasks where the steps can’t be known in advance.

    Key idea

    Start simple. Reach for an agent only when the steps can’t be planned ahead.

  3. 3

    How does the agent loop work?

    An agent runs in a loop. It thinks about the next step, acts by calling a tool, observes the result, and repeats. Anthropic stresses that at each step the agent should get "ground truth" from the real world, such as a search result or a test run, to check its progress.

    The loop needs a way to stop. OpenAI lists common exit conditions: the agent produces its final answer, it replies without asking for any tool, an error occurs, or it hits a maximum number of turns.

    1. Goal
    2. Think: choose next step
    3. Act: call a tool
    4. Observe: read the result
    5. Repeat or finish
    An agent’s trace (simplified)
    Goal:  Compare 3 free beginner Python courses
    Think: I need options. Search first.
    Act:   web_search("free beginner Python course")
    See:   10 results
    Think: Open the top 3, check length and certificate.
    Act:   open_page(...) x3
    See:   Course details
    Think: I have enough. Write the table.
    Done:  Comparison table with links
  4. 4

    Where are agents used today?

    Coding agents like Claude Code, Codex and Cursor’s agent read your code, make changes, run tests and fix what fails. You will try them in the next track. Research agents search many pages and write a report. Support agents look up an order and issue a refund within set limits.

    OpenAI’s guide says agents fit best where older automation struggles:

    • Decisions that need judgment, like approving an unusual refund.
    • Rules that are too many or change too often to code by hand.
    • Lots of unstructured data, such as documents, emails or chats.
  5. 5

    What can go wrong, and what guardrails help?

    More freedom means more risk. Agents cost more, take longer, and small mistakes can pile up over many steps. A web page or email the agent reads can also contain hidden instructions trying to hijack it (prompt injection).

    Both Anthropic and OpenAI recommend layers of protection, and testing in a safe sandbox before real use:

    • Limit power: give only the tools and access the job needs.
    • Rate tools by risk, and require a human to approve sensitive, irreversible or high-value actions like payments.
    • Set a maximum number of turns or retries, then hand over to a person.
    • Filter inputs and outputs: block off-topic requests, injection attempts and personal data leaks.
    • Show the agent’s plan and steps so people can see what it did.
    Key idea

    Give an agent the least power it needs, a turn limit, and a human check before anything you can’t undo.

From the people who built it

Straight from the source

The original idea, then the same idea taken apart, then how you use it today.

Shunyu Yao and colleagues (Princeton University and Google)
Authors of ReAct, the paper behind the think, act, observe loop that most AI agents still use.
ReAct: Synergizing Reasoning and Acting in Language Models (paper, 2022)
1 · Understand
Let the model write its reasoning and its actions in turns: a thought, then a tool call, then the result, then the next thought. The reasoning keeps the plan on track, and the actions bring in real information so the model is not left guessing.
2 · Break it down
  • Thought: the model writes down what it needs next, in plain words.
  • Action: it calls a tool. In the paper this was a simple Wikipedia search, and it cut down the made-up facts that reasoning alone produced.
  • Observation: it reads what came back and plans again. With only one or two examples in the prompt, ReAct beat earlier methods by 34 points on ALFWorld (a text game of household tasks) and 10 points on WebShop (an online shopping test).
  • Because the thoughts are written out, a person can read the trace and see why the agent did what it did.
3 · Use it
When an agent goes wrong, read its trace step by step: thought, action, result. You will usually spot the exact step where it guessed instead of checking.
Erik Schluntz and Barry Zhang (Anthropic)
Anthropic engineers who wrote "Building effective agents" after working with dozens of teams building agents.
Building effective agents (Anthropic engineering post, December 2024)
1 · Understand
The most successful teams were not using complex frameworks. They built with simple, composable patterns, starting from one "augmented LLM": a model that can search, use tools and remember.
2 · Break it down
  • Start with the simplest thing that works, and add steps only when they clearly help. Agents trade speed and cost for better results on hard tasks.
  • Their three principles: keep the design simple, show the agent’s planning steps, and put real care into tool descriptions and testing.
  • Frameworks can speed you up but can hide the actual prompts. They suggest starting with the model’s API directly, since many patterns are only a few lines of code.
3 · Use it
Before you build an agent, try one model call with good context and one or two tools. If you do need an agent, spend your time on clear tool names and descriptions, and watch the first runs closely.
6 terms

Words to know

AI agent
An AI system that works toward a goal by choosing and using tools in a loop, with little step-by-step direction.
Workflow
A fixed sequence of model calls and tools that you design in advance. Predictable, but not flexible.
Agent loop
The cycle of think, act with a tool, observe the result, and repeat until done.
Exit condition
The rule that ends the loop, such as a final answer, an error or a maximum number of turns.
Guardrail
A check that keeps an agent safe, such as an input filter, a tool limit or a human approval step.
Human in the loop
A person reviews or approves certain steps before the agent continues.
2 videos · plays here

Watch

Hand-picked from the people who explain this best. The video loads only when you press play.

What are AI Agents?
IBM Technology · 12 min

Shows how we moved from single model calls to systems that reason and act. Focus on the reason, act, observe part.

Tips for building AI agents
Anthropic · 18 min

Anthropic engineers on when to build an agent and when not to. Good after you finish this lesson.

Hands-on · 10 minutes or less

Try it

Watch an agent loop, then design its guardrails

  1. 1Open ChatGPT, Claude or Gemini with web search turned on.
  2. 2Give it a multi-step task: "Find three free beginner Python courses from well-known sources. For each, check the length and whether it gives a certificate. Give me a comparison table with links."
  3. 3Open the activity or thinking panel if it shows one. Write down each think, act and observe step. How many searches or page visits did it make?
  4. 4Open one link yourself and check one fact. Was the agent right?
  5. 5Now imagine this agent could also read your email and pay with UPI. Write three guardrails you would insist on before letting it.
Read Anthropic’s "Building effective agents"
3 questions · instant feedback

Check yourself

Pick an answer to see if you are right, and why.

Question 1

Question 1 of 3

Which of these is a workflow rather than an agent?

Question 2

Question 2 of 3

Why give an agent a maximum number of turns?

Question 3

Question 3 of 3

Your support agent can issue refunds. Which action should need human approval?

Lesson 21 of 36

Done? Keep going

Mark this lesson complete to keep your place. Progress is saved on this device, no login.

Up next · Lesson 22 · 12 minWhat are Agent Skills?An Agent Skill is a folder with a SKILL.md file inside: a name, a one-line description of when to use it, and step-by-step instructions, plus optional scripts and reference files. The agent sees only the name and description until a task matches, then reads the rest. Anthropic introduced Skills in October 2025 and published the format as an open standard (agentskills.io) in December 2025; Cursor, Gemini CLI, GitHub Copilot in VS Code and OpenAI Codex use it too.← Previous: What is MCP?
People also ask

Questions people ask

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

A chatbot replies to your message. An agent works toward a goal: it plans steps, calls tools like search or code, checks results, and keeps going until the task is done or it needs your input.

What is the difference between an AI agent and an AI workflow?

In a workflow, you write the steps and the model fills them in. In an agent, the model decides the steps itself. Anthropic recommends starting with the simplest option and using agents only when the steps can’t be planned in advance.

Are AI agents safe to use?

They can be, with guardrails. Give agents only the access they need, require human approval for payments or anything irreversible, set turn limits, filter inputs for prompt injection, and test them in a sandbox first.

3 sources · checked Nov 2026

Sources and further reading

Free · No signup to start

Going for an AI role? Practise the interview.

Talk to an AI interviewer about what you just learned and get feedback on every answer.

Start a free mock interview