Hands-on Artificial Intelligence
My learning DE

Lesson15 min

AI agents

A language model that uses tools in a loop to reach a goal: what sets an agent apart from a chatbot, what it is made of, when a fixed workflow is better, and what can go wrong when it acts with your permissions.

Topics:AI agents

See first: A brief history of AI

What you will learn

This lesson shows you what turns a language model into an agent, and afterwards you can:

  • explain the difference between a chatbot and an agent, using the working definition of an agent that runs tools in a loop to achieve a goal
  • name the parts of an agent, the model, the tools, the loop, the context, the plan and the sub-agents, and say what each one does
  • decide whether a task needs an agent or whether a fixed workflow is the better choice
  • explain what can go wrong when an agent acts with your permissions, and how asking for its plan keeps you in control
In a new window As PDF

A chatbot answers, and you take the next step yourself: you copy the code, run it, paste back the error. An agent takes those steps on its own. Under the hood it is the same language model; the difference is what is built around it. A working definition: an LLM agent runs tools in a loop to achieve a goal.

Everything else, the plan, the instructions it loads, the sub-agents, the context it keeps in mind, is built around that loop. This page answers:

  • What is the difference between a chatbot and an agent?
  • What are the parts of an agent, and what does each one do?
  • When is an agent the right choice, and when is a fixed workflow better?
  • Why are agents suddenly everywhere?
  • What can go wrong when an agent acts with your permissions?

You play an agent yourself in the experiment Be the agent, with cards and without a computer.

The model, the tools, the loop

The language model can only produce text. It cannot open a file or load a web page. What it can do is write down which tool it wants to call, and with which arguments: read a file, write a file, run a command, search the web. A program on your computer, the harness, executes the call and hands the result back to the model. Then the model decides what to do next. This loop, think, act, observe, repeats until the goal is reached. In research the pattern is known as ReAct (Yao et al., 2022).

Context, plans and sub-agents

Everything the agent "knows" during a task sits in its context window: the goal, every tool result, every intermediate thought. When it fills up, the agent has to summarise or forget. To stay on track, agents write themselves a plan, a to-do list they tick off, and read instructions stored in text files when they need them. For big tasks they can start sub-agents: copies of themselves, each with a fresh context window, working in parallel.

Workflow or agent?

Not everything with AI inside is an agent. A workflow follows predefined steps; an agent decides the next step itself. The advice from Anthropic: keep it as simple as possible, and use agents only where the task needs that freedom.

Handle with care

An agent acts with your permissions. It can read every file you can read, run every command you can run, and publish to the internet. Whoever gives an agent access hands over their own keys. Asking it to show its plan before it acts is where you stay in control.

Quiz: AI agents

You ask a chatbot to fix a script that stops with an error. It suggests a change, you run the script yourself and paste the new error message back. What changes if you give the same task to an agent?

  • It uses a larger language model that makes fewer mistakes when programming.
  • It runs the script itself, reads the error and decides on the next change until the script works.
  • It solves the task in one step, because it plans the whole solution before writing anything.
  • It asks for permission before each suggestion but otherwise works like the chatbot.

An agent reads the file fields.csv. What exactly does the language model contribute to this step?

  • It opens the file on the disk and loads its content into its memory.
  • It writes text that names the tool and its arguments; a program around it reads the file and returns the content.
  • It sends a request to the operating system, which checks the permissions and delivers the file.
  • It recalls the file from training, because tables like this occur there frequently.

Which of these tasks is better solved with a fixed workflow than with an agent?

  • Every morning an LLM reads the new delivery notes, a program matches them with the orders and flags differences.
  • A dairy's main supplier of packaging has gone bankrupt; find alternatives, compare offers and draft a recommendation.
  • Find out why the yield on one field dropped last year, using all data and sources available.
  • Build a small web app showing the bookings of the farm machinery, from a short description.

Which of these jobs does the harness do rather than the language model?

  • carry out the tool calls and return the results
  • decide which tool to call next
  • ask the user for permission before a command runs
  • manage the context window, for example by summarising when it fills up
  • write the plan for the task

After two hours of work an agent suddenly repeats a step it had finished long ago. Which explanation fits best?

  • The model learned from the previous steps and adjusted its weights, which overwrote the earlier result.
  • The context window was full; earlier results were summarised or removed, so the step is no longer in it.
  • A tool reported an error, and the harness repeats failed calls on its own.
  • The language model only ever keeps the last tool result, so every earlier step is lost after one round.

An agent is asked to research 40 milestones in the history of AI and starts eight sub-agents for it. What is the main advantage?

  • Each sub-agent has a fresh context window, so the many sources do not fill the main agent's context, and they work at the same time.
  • Sub-agents use a smaller model that specialises in searching the web.
  • Sub-agents may access files the main agent has no permission for.
  • Several sub-agents vote on every answer, which rules out invented facts.

You use Claude Code on your laptop, and it creates files in your project folder. Where does the language model run?

  • On your laptop, inside the program you installed.
  • On a server of the provider; only text travels back and forth, while the harness and the files stay on your laptop.
  • Partly on the laptop and partly in the cloud: small steps locally, large ones on the server.
  • In the browser, which downloads the model at the start of the session.

Your agent works with your user account, and you have allowed it to run commands without asking. What can it do?

  • delete files in your personal folder
  • publish a website through your GitHub account
  • read files on a colleague's laptop on the same network that your account has no access to
  • read every file your account can read, private documents included
  • change the model's weights so that it remembers your project next week

Two agents use exactly the same language model but different harnesses. Which statement is correct?

  • They behave the same, because all decisions are made in the model.
  • They can behave differently, because the harness determines which tools, instructions, permissions and context the model gets.
  • They differ only in speed, because the harness sets how fast the model computes.
  • They give the same answers in a different layout, because the harness only formats the output.

An agent is asked to work out how much nitrogen may still be applied to a field. Its web search returns a current page and an archived page from 2009 with a different requirement, and it calculates with the 2009 value. What does this show?

  • The search tool made a mistake; a better one would only return current pages.
  • The model works only with what is in its context; whether it notices an outdated source depends on whether it reads and checks the result carefully.
  • The harness should have filtered out the old page, because it checks every result for correctness.
  • A larger model would have known the current value from training, so the mistake is down to the size of the model alone.

Which sequence describes the loop at the core of every agent?

  • plan, carry out all steps, deliver a report
  • prompt, answer, user feedback, new prompt
  • think, act, observe, and again until the goal is reached
  • search, read, summarise, and stop after one answer

METR reports a "time horizon" of several hours for current models. What does it measure?

  • How long a model can work before its context window is full.
  • The length of tasks, measured in the time a human needs, that a model completes on its own in half of the cases.
  • How many hours of human work a model saves on average per day.
  • How long the model needs for a task that a human completes in one hour.

Download with answers: CSV Anki

Back
More on this
Details
Level
Beginner
Modules
Applications of Artificial Intelligence
Code
7829
Updated
4 November 2026
Status
published

    A four-digit code takes you straight to the item.