Basic

What are AI agents?

An agent is a model that takes action toward a goal, not one that just answers. A chatbot tells you the shipping status. An agent checks the order, calls the carrier, and emails you the tracking number on its own.

What you will see

act: read order act: call carrier act: email tracking Agent finished 3 steps

About 2 min of reading

Try It

An agent is a model that takes action toward a goal, not one that just answers. I run a small observe-think-act loop, pick a tool by what I read, then keep working until the goal is done to see why agents differ from plain chatbots.

1

Every agent runs the same small loop: observe the world, think about the next step, then act with a tool. I simulate that loop and print what happens each round until the goal is met.

goal_done = False rounds = 0 while not goal_done: rounds += 1 if rounds >= 3: goal_done = True print(f"Round {rounds}: observe -> think -> act") print("Goal reached")

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Round 1: observe -> think -> act Round 2: observe -> think -> act Round 3: observe -> think -> act Goal reached
The loop checks the goal after each act, so it keeps working until the task is truly done instead of stopping after one reply.
2

An agent picks a different action depending on what it reads. I pass it a refund request and print that it investigates the order instead of only answering, showing the difference from a chatbot.

message = "I want a refund" if "refund" in message.lower(): print("check order -> call carrier -> email tracking") else: print("just answer the question")

Before you run it, say out loud what it will print. Then open the answer.

What it prints
check order -> call carrier -> email tracking
A chatbot would just answer; an agent does the work the message implies, which is why the output is a chain of steps.
3

An agent keeps going until every task on its list is finished, then reports how many it completed. I loop over the tasks and count them to show the loop that drives an agent.

tasks = ["read order", "call carrier", "email tracking"] done = 0 for t in tasks: print(f"act: {t}") done += 1 print(f"Agent finished {done} steps")

Before you run it, say out loud what it will print. Then open the answer.

What it prints
act: read order act: call carrier act: email tracking Agent finished 3 steps
Counting the steps also tells you when the agent is done. A loop that never finishes its list is not a real agent.

Put it in order

Before you write anything, put these lines back in the right order. Click a line to move it up one step. This support step is easier than writing code from scratch, and it is here to make the last example stick.

Data Flow

An agent watches a trigger, decides a step, runs a tool, and repeats until the goal is met.
1 Receive a message or event
↓
2 Decide what the goal is
↓
3 Pick the next step and run a tool
↓
4 Check the result and repeat until done
Why this works
The loop behind every agent

Almost every agent runs the same small loop:

  1. **Observe*: read the situation.
  2. **Think*: decide the next step.
  3. **Act*: use a tool.
  4. Repeat until the goal is done.

Observe -> Think -> Act -> (see result) -> Think ...

This is called the agent loop. Even a basic auto-reply is a tiny version of it.

Where agents are used
AreaWhat the agent does
SupportAnswer and fix common questions
SalesBook meetings, qualify leads
CodingFix bugs, write tests
AdminSort email, schedule tasks

The common thread? Give a goal, let the agent figure out the steps.

Auto-reply chatbots are the first step most people take toward agents.

Examples

Chatbot vs agent

A chatbot only answers questions. An agent takes action to reach a goal.

Chatbot:  "Your order shipped."
Agent:    "Checked order -> called carrier -> emailed tracking."

Why it works: an agent gets a goal, then picks and runs steps on its own.

A simple auto-reply

if message.contains("refund"):
    reply("I can help with a refund.")
    start_refund_flow()
else:
    reply("Thanks! Someone will follow up.")

Auto-reply systems read an incoming message and choose a response. The simplest ones use rules; smarter ones use a model.

Small examples everywhere

Agents are already around you

# A smart search does not just list links
query = 'best refund policy'
results = search(query, answer=True)
# It reads the page and gives you the answer

Agents show up in tools you use daily: smart search, voice assistants, auto-fill. They combine a model with a few actions.

Why it works: the model understands, the tools do the work.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

Next Lesson
How auto-reply works
How auto-reply works →