Blog ·
What is an AI agent?
An AI agent is an AI model that works towards a goal in a loop: it takes a step with a tool, looks at the result, and decides what to do next until the job is done. Here is how that works, where you may already have met one, and a tiny agent written in plain Python.
The short answer
An AI agent is an AI model put to work in a loop. You give it a goal, such as "fix the broken link on my website". It picks a step, uses a tool to take it (opening a file, running a search, changing a line), looks at what happened, and picks the next step. It keeps going until the job is done, until it needs a decision from you, or until it reaches a limit.
The difference from a chatbot, in one line: a chatbot answers your message and waits; an agent takes steps until the job is done.
The companies that build agents describe them the same way. Anthropic calls them large language models (the kind of AI behind chat assistants) "using tools based on environmental feedback in a loop". OpenAI calls them "systems that independently accomplish tasks on your behalf".
| A chatbot | An agent | |
|---|---|---|
| You give it | a message | a goal |
| It gives back | a reply | a finished job, or a question for you |
| Between your messages | it waits | it works through steps |
| What it can touch | the conversation | the tools you allow it |
The line is blurry in practice, because many chat assistants now include agent features. "Is ChatGPT an AI agent?" is answered at the end of this page.
The loop that makes an agent
Ask Claude Code, Anthropic's coding agent, to "fix the failing tests", and its own documentation describes what it might do:
- Run the tests to see what is failing.
- Read the error.
- Search for the files involved.
- Read those files.
- Edit them to fix the problem.
- Run the tests again to check.
Nobody wrote that list in advance. Each step came from what the step before it showed. That cycle is the agent loop:
- Goal: what you asked for.
- Act: the model picks one step and asks for a tool to take it.
- Look: the tool's result comes back and is added to what the model can see.
- Repeat: with that new information, it picks the next step.
- Stop: when the goal is met, when it needs you, or when it reaches a limit, such as a maximum number of turns.
Claude Code's docs name the same cycle "gather context, take action, and verify results". Anthropic's engineers stress that an agent must get "ground truth" from the environment at each step: the real result of what it did, not a guess about it.
It works like making a sauce without a recipe: taste, add a little salt, taste again, and stop when it is right. The tasting is what keeps you from ruining it.
Tools, memory and planning
Three parts turn a model that writes words into an agent that gets things done.
Ask a model on its own for today's tide and the best it can do is guess, because all it produces is text. Claude Code's docs put it plainly: "Without tools, Claude can only respond with text. With tools, Claude can act." A tool is something the program around the model lets it use: a web search, reading a file, running a command. The model never runs a tool itself. It asks for one by name, with the details it needs, and the program runs it and hands back the result. It is like phoning a shop: you can't reach the shelves, so you ask the assistant to check, and they tell you what they find.
Everything the agent knows about the job so far sits in its context: your goal, each step it took and each result it got back. In Claude Code that also holds the files it read and your standing instructions. A new session starts with an empty record, unless the tool keeps longer-term notes, as Claude Code does. It is like the handover notes between hospital shifts: the night nurse knows only what the day nurse wrote down.
For a bigger goal, an agent can first break the work into steps, which is planning. IBM describes an agent that "creates a plan of specific tasks and subtasks to accomplish the complex goal". Claude Code's docs say that for complex tasks "it breaks work into steps, executes them, and adjusts based on what it learns". The adjusting matters. A plan is like a shopping list: you write it before you go, then swap the cream for yoghurt when the shop has run out.
Agents you may already have met
Each of these runs the loop above. They differ in where they work and what they can reach.
- Claude Code, from Anthropic, works in a folder on your computer. With its tools it can "read your code, edit files, run commands, search the web", and it helps with more than code: its docs list writing docs, searching files and researching topics. Our plain-English Claude Code guide starts you on an empty practice folder.
- Codex, from OpenAI, does the same kind of work on files. Its permission modes, the same ones the ChatGPT desktop app uses, decide which actions it may take without asking: "editing files, running commands, and using the internet". OpenAI suggests starting on Ask for approval, where it "pauses before reaching beyond that boundary" of the folder you are working in. See our Codex guide for beginners.
- Dots, also from OpenAI, are agents inside ChatGPT for ongoing jobs rather than one task. A dot is "an always-on agent" that "lives in the cloud and has its own computer and browser", so it keeps working between your conversations and comes back to you for decisions. Dots are rolling out to some paid ChatGPT plans only, and on Pro or Plus you must be 18 or over; our dots guide has the details.
The guides walk through several of these tools in plain words, starting somewhere nothing important can break.
A tiny agent you can read
Here is a whole agent loop in about 30 lines of Python. It needs no internet connection and no AI account. It has three parts:
- Two tools.
check_tideandcheck_lamplook up the tide and the harbour lamp on a given day, in a made-up harbour town. - A stand-in model. A real agent sends the goal and the history to an AI model. Here
modelplays that part with one fixed rule, so the result is always the same: ask for each tool the goal mentions, once, with the day taken from the goal's last word, then answer in words. - The loop.
run_agentasks the model what to do, runs the tool it asks for, writes the result intohistory, and goes round again, until the model answers ormax_turnsruns out.
def check_tide(day):
return {1: "2.4 m", 2: "2.8 m", 3: "3.1 m"}[day]
def check_lamp(day):
return {1: "lit", 2: "out", 3: "lit"}[day]
TOOLS = {"check_tide": check_tide, "check_lamp": check_lamp}
def model(goal, history):
# A stand-in for a real AI model, with one fixed rule: ask for each
# tool the goal mentions, once, then answer from what came back.
asked = [step["tool"] for step in history]
for name in TOOLS:
if name.replace("check_", "") in goal and name not in asked:
return {"tool": name, "day": int(goal.split()[-1])}
found = [step["tool"] + " said " + step["result"] for step in history]
return {"answer": "Here is what I found: " + ", ".join(found)}
def run_agent(goal, max_turns=5):
history = []
for turn in range(1, max_turns + 1):
reply = model(goal, history)
if "answer" in reply:
return reply["answer"]
print("Turn", turn, "asks for", reply)
tool = TOOLS[reply["tool"]]
result = tool(reply["day"])
print("Turn", turn, "gets", result)
history.append({"tool": reply["tool"], "result": result})
return "Stopped: out of turns"
print(run_agent("Check the tide and the lamp on day 3"))
print(run_agent("Check the tide and the lamp on day 2", max_turns=1))
Output
Turn 1 asks for {'tool': 'check_tide', 'day': 3}
Turn 1 gets 3.1 m
Turn 2 asks for {'tool': 'check_lamp', 'day': 3}
Turn 2 gets lit
Here is what I found: check_tide said 3.1 m, check_lamp said lit
Turn 1 asks for {'tool': 'check_tide', 'day': 2}
Turn 1 gets 2.8 m
Stopped: out of turns
Read the first run from the top:
- Turn 1: the goal mentions the tide, so the model asks for
check_tidewith day 3. Its request is data, not an action: the loop is what runs the tool. - Turn 2: the history shows the tide was checked, so it asks for
check_lamp. - Turn 3: nothing is left to look up, so it answers in words and the loop ends. No "Turn 3" line is printed, because the loop hands back the answer instead of printing a turn.
The second run gets one turn. It checks the tide, runs out before it reaches the lamp, and says so instead of carrying on. That limit is what keeps a confused agent from going round forever.
The stand-in is the one part that isn't real. A real model reads a description of each tool and decides for itself what to ask for, which is what makes agents useful, and also why they sometimes choose wrong.
Try this: change the goal to "Check the lamp on day 2" and work out what it will print before you run it.
Where agents go wrong
Agents suit jobs where nobody can say in advance how many steps it will take. Anthropic recommends them for "open-ended problems where it's difficult or impossible to predict the required number of steps", and advises "finding the simplest solution possible". A quick question is still better in a normal chat. Three things to keep in mind:
They make mistakes, and the mistakes add up. Each step builds on the one before, so a wrong step early on carries through. Anthropic warns of "higher costs, and the potential for compounding errors". It is like a wrong turn at the start of a drive: every turn after it can be right for the road you are on and still take you further from where you meant to go. Check the finished result yourself.
A loop needs a stop. IBM notes that an agent which can't make a full plan or reflect on its results can end up "repeatedly calling the same tools, causing infinite feedback loops". That is why builders set a limit on turns, as the example above does. Longer runs cost more, too: every turn is another request to the model.
They act with the access you give them. Claude Code's docs say that from your terminal it can run "any command you could run", which is why it and Codex both have settings that make them ask first. IBM's advice is "to require human approval before an AI agent takes highly impactful actions", and OpenAI says of dots that "stopping a task doesn't undo actions it has already completed". Lending an agent access is like lending a spare key: whoever holds it can open every door it fits, whether or not you meant them to. Start with ask-first settings, and give it only what the job needs.
Where to go next
To use an agent, pick one tool and follow a guide on a practice folder first: Claude Code, Codex, or all the guides.
To build one, you need some Python first. Agentale's sixth region, Agent District, has you build this loop, a tool call and a plan in real Python, after five regions that take you from your first line of Python: see the curriculum.
Questions people ask
Is ChatGPT an AI agent?
A normal ChatGPT chat is not: it gives you an answer, an explanation or a draft, and waits for your next message. But ChatGPT now has agent features. In the desktop app it can edit files and run commands in the folder you are working in, under the same permission modes as OpenAI's Codex, and a dot is "an always-on agent" with its own computer and browser in the cloud, which keeps working between your conversations.
What's the difference between an AI agent and a chatbot?
A chatbot replies to each message. An agent is given a goal and takes steps with tools, looking at each result, until the goal is met or it has to stop. IBM describes chatbots that are not agents as "ones without available tools, memory or reasoning", and OpenAI's guide to building agents says simple chatbots do not count.
Do I need to know how to code to use one?
No. Coding agents such as Claude Code and Codex take instructions in plain words, and both have settings that make them ask first: Claude Code's Manual mode asks before each file edit or command, and Codex's Ask for approval asks before it goes beyond the folder you are working in. Most need an account with their maker, and some need a paid plan (the Claude Code guide says which). Building an agent of your own is where you need to code.
Can an AI agent go wrong?
Yes. It can pick the wrong tool, misread a result or build on an early mistake, and Anthropic warns that errors can compound. It can keep going round a loop unless a limit stops it. And it acts with whatever access you give it, so start in a mode that asks before acting, give it only what the job needs, and check the result yourself.
Is an AI agent the same as an AI model?
No. The model is the part that reads, writes and decides the next step. The agent is the model plus the tools it may use and the loop that runs them. Claude Code's docs describe its loop as "models that reason and tools that act".
Sources
- How Claude Code works (Anthropic)
- Permission modes, for Codex and ChatGPT (OpenAI)
- Dots (OpenAI)
- Getting started with your dot (OpenAI Help Center)
- Building effective agents (Anthropic)
- A practical guide to building agents (OpenAI)
- What are AI agents? (IBM)
Checked against these sources on 24 November 2026.
Learn it by playing
Agentale is a game that teaches Python from zero, up to building your own AI agents. It runs in your browser, with nothing to install.