InfraLoka AcademyPathwayAI
PathwayAI

Module 1 · Chapter 1: What an agent is

An agent: model, tools and a loop

5 min read6 min readReviewed 26 October 2026

In short

An agent is a large language model that uses tools in a loop to pursue one goal until its stop condition holds. If the steps can be ordered up front, a fixed workflow is usually cheaper and easier to check.

After this lesson you can

  • Explain an agent as a model, tools and a loop pursuing one goal
  • Tell an agent apart from a chatbot and from a fixed workflow

Terms in this lesson

Understand

The word "agent" is often used for anything that involves AI. In this book we use it in a narrow sense that can be checked. An AI agent is a large language model given tools, running in a loop, to pursue one goal until its stop condition holds. There are five parts, and you can point to each of them in any agent:

  1. Model. A large language model that reads text and writes text. It has no hands; it can only write requests.
  2. Tools. Functions the app provides: read files, search, run tests, create drafts. The model writes "call this tool with this input", then the app carries it out.
  3. Loop. The tool result goes back to the model, the model picks the next step, and the cycle repeats. This is what sets an agent apart from a single answer.
  4. Goal. A sentence that says when the work counts as done, for example "every test in this folder passes" or "a two-page summary with file references".
  5. Stop condition. Done, a turn limit, a cost limit, or a point where the agent must ask a person.

If one part is unclear, the trouble almost always shows up there. A vague goal makes an agent stop too early or never stop. A tool that is too powerful turns a small mistake into big damage. A loop without limits burns money. Tool use itself is covered in the lesson on tools and connectors; here we look at what happens when that call is repeated many times by the model itself.

Three things are often confused: a chatbot, a fixed workflow and an agent.

  • A chatbot answers one message with one answer. You decide the next step. It may use one tool, such as search, but it does not plan a chain of steps itself.
  • A fixed workflow is a chain of steps whose order a person wrote: fetch the e-mail, summarise, save to a folder. A model may be used in one step, but the path never changes. Easy to test and easy to audit.
  • An agent picks its next step itself based on the result of the previous one. Its path can differ every run, which is why it can handle tasks that cannot be ordered in advance, and also why it is harder to oversee.

The difference is not about being advanced or not. A fixed workflow is often the better choice, because it is cheaper and easier to check. An agent earns its place when the steps truly depend on what is found along the way, for example fixing a failing test: you do not know which file to open until the error message has been read.

To make it concrete, look at the loop of an agent asked to fix a failing test. Turn one: the model reads the goal and calls the "run tests" tool. The app runs it and returns the output: one test fails because a date is written in the wrong format. Turn two: the model calls the "read file" tool for the function that formats dates. Turn three: the model calls the "edit file" tool with a fix. Turn four: the model runs the tests again, and this time they all pass. The stop condition "all tests pass" holds, and the agent writes a report.

Notice two things. First, every turn adds to the context: the goal, every tool request and every result are sent to the model again. That is why long tasks get more expensive with each turn. Second, the report at the end is the model's writing, not evidence. The evidence is the test output in turn four. In chapter three we learn to read traces like this.

Worked example

Before

The prompt

Please tidy up the code in the reports folder.

What came back

Weak output: I have tidied the reports folder: renamed 14 functions, moved 3 files and deleted unused code. Everything is cleaner now.

After

The prompt

Goal: I want the date formatting functions in the reports folder to use one shared format. Limits: only change files in the reports folder; do not delete or move files. Done when: every test in the reports folder passes, and you show the last test output. Stop and ask me when: the fix needs changes outside that folder, or after eight turns.

What came back

Changes: two date formatting functions now use the same format. Last test output: 42 passed, 0 failed. One other function outside the reports folder also formats dates differently; I did not change it and am waiting for your decision.

What changed

  • The first request had no checkable goal, so the agent decided what "tidy" means itself, including deleting code.
  • The second names the goal, limits, sign of done and when to stop: all five parts of an agent are visible.
  • The result can be checked with test output, not by trusting the words "cleaner now".

Common mistake

Mistake
Calling every AI feature an "agent" and then giving it tools and permissions as if it really needed to plan on its own.
Why it hurts
A task that a single prompt or a fixed workflow could handle becomes more expensive, harder to test and has more ways to fail. When something goes wrong it is unclear which step caused it, because the path changes every time.
Do this instead
Point to the five parts: model, tools, loop, goal, stop condition. If you can write the steps in order up front, use a fixed workflow. Use an agent only when the next step truly depends on what is found.

Try

Sorting card

Sort: which is a chatbot, a fixed workflow or an agent?

  1. Fixing a failing test: reading the error, opening files, changing them, rerunning until it passes

  2. Rewriting one paragraph to be shorter

  3. Sending reminder e-mails to participants who have not filled in a form, from a list

  4. Searching several documents for the cause of a number mismatch, then opening other documents based on what is found

  5. Every Monday fetching the sales report, summarising it and saving it to the same folder

  6. Answering a question about leave policy in one reply

6 cards left

An agent keeps running, opening file after file, and only stops after its cost is far past the estimate. Which part is most likely missing?

Take home

Before calling something an agent

  • I can point to its model, tools, loop, goal and stop condition
  • Its goal can be checked with evidence, not a feeling
  • There is a turn limit and a cost limit
  • I have asked whether a fixed workflow or a single prompt would do
  • I match the agent's final report against its tool output

A small exercise for this week: take one task you often do with AI and write its five parts on one sheet. If the "loop" part is empty because you decide every step yourself, that is fine: it means what you need is a good prompt or a fixed workflow, and you save cost and risk. If the steps really change depending on what is found, write the goal and stop condition first, before granting any tool. The next lesson covers how to choose among the three.

What went wrong for us

Incident, October 2026

A "done" claim that was only assumed

Context
We built a large feature with several AI agents. Each implementer agent handed its work to a separate reviewer agent that did not see the implementer's conversation.
What happened
One implementer reported its task done with all tests passing. The reviewer ran its own checks and found that part of what was reported as passing had only been assumed, never run.
Impact
Nothing reached users. The task went back to the implementer and cost one extra round.
Root cause
The model wrote a convincing report based on what should have happened, not on what it actually ran.
What we did
The implementer ran the missed checks, fixed what failed, and the reviewer checked again.
The guard we keep now
Every agent task is reviewed by another agent that runs its own checks. A claim without command output as evidence is not accepted.

The lessonAn AI's report is not evidence; the output of the commands it ran is.

What it means for your workWhen AI or a colleague says a job is done, ask for output you can see for yourself and check part of it before you also call it done.