esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Is an AI Agent?

What an AI agent is, how its loop of model, tools and results works, and how it differs from a workflow, explained simply for your AI interview.

In short

An AI agent is a system where a language model works toward a goal by calling tools and deciding its own next step after each result. It keeps looping until the goal is met or a stop rule ends the run, so it acts as well as answering.

11 min readBeginnerVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

An AI agent is a system built around a language model. It runs a loop. It reads my goal, picks a tool such as a policy lookup, sees the result, and decides the next step until the goal is met or a limit stops it. The key difference from a simple chatbot is that it takes actions through tools. Because it acts on its own, I put step limits, permission checks and a human approval step around it.

What is an AI agent, in plain words?

A simple chatbot reads your message and writes a reply. That is the end of it. An AI agent is a system built around a language model. It is given a goal and a set of tools, then works through the steps itself until the goal is met.

Think of a new claims handler in their first week at an insurer. They get a file, look up the policy, check the photos, call the garage, and only then decide. Each step depends on what the last one found. An agent works the same way, with a model as the one deciding and tools as its hands. In an AI claims agent, the model asks a tool for the policy, then asks a tool for a repair quote, and your code runs each tool.

Key words

Agent
A system that picks its own next step and uses tools to reach a goal.
Model
The language model that reads the goal and each result, then decides.
Tool
A function your code can run, such as looking up a policy or sending an email.
Loop
The repeat cycle: decide, call a tool, read the result, decide again.

How does an agent loop work, step by step?

OpenAI's 2026 guide says an agent has three core parts: a model, tools and instructions. The model is the part that decides. OpenAI's guide names the repeating cycle a run. A run is typically a loop that keeps going until an exit condition is reached.

One run of an agent

Your goal

e.g. settle one car claim

Model

reads the goal and each result

Each turn

Call a tool

your code runs it, not the model

Reply to the user

when the goal is met

Stop

the goal is met

  1. 1The goal goes in as the first message.
  2. 2The model asks for one tool, such as a policy lookup.
  3. 3The tool's result goes back into the model, and the loop repeats.
  4. 4Once the goal is met, the model writes its answer.
  5. 5The answer goes to the person, and the run ends.
One run of an agent. The model picks a tool, your code runs it, the result goes back in, and the loop repeats until the goal is met or a step limit stops it.
  1. 1

    Get the goal

    Your app gives the model the goal, its rules and the list of tools it may use.

  2. 2

    The model picks one tool

    It asks for a tool and the inputs it needs. It does not run the tool itself.

  3. 3

    Your code runs the tool

    Your code checks the request, runs the tool and collects the result.

  4. 4

    The result goes back in

    The model reads the result and decides the next step.

  5. 5

    Stop when done or at a limit

    The loop ends when the goal is met or a step cap is reached.

Here is the loop in a few lines of plain Python. The model is a stand-in, so the loop and its stop rule are easy to see. The step cap is the line that matters most.

Python
# A simplified claims agent loop. The "model" is a stand-in that picks the next tool.
MAX_STEPS = 15
PLAN = ["lookup_policy", "read_photos", "request_repair_quote"]
TOOLS = {
    "lookup_policy": lambda: "policy P-2291 is active",
    "read_photos": lambda: "3 photos, rear bumper damage",
    "request_repair_quote": lambda: "quote received: 1240 USD",
}

def model_pick(step):
    # Stand-in for the model: asks for the next tool, or None when it has enough.
    return PLAN[step] if step < len(PLAN) else None

def run_agent(goal):
    for step in range(MAX_STEPS):  # the step cap stops a runaway loop
        tool = model_pick(step)
        if tool is None:
            return "DONE: " + goal
        if tool not in TOOLS:
            return "STOPPED: unknown tool " + tool
        result = TOOLS[tool]()  # your code runs the tool, not the model
        print(step + 1, tool, "->", result)
    return "STOPPED: step limit reached, send to a human"

print(run_agent("settle claim 88712"))

Output

1 lookup_policy -> policy P-2291 is active
2 read_photos -> 3 photos, rear bumper damage
3 request_repair_quote -> quote received: 1240 USD
DONE: settle claim 88712

This demo finishes in three steps, so the cap never fires. If the model kept asking for the same lookup, the loop would stop at step 15.

How is an agent different from a workflow?

A workflow is a fixed path that developers write in code. An agent lets the model decide the path while it runs. Both can use language models and tools. The difference is who chooses the next step.

Workflow versus agent

New customer request

a refund or a claim, say

Workflow

Your code runs the steps

the order is fixed in your code

Agent

Model picks each step

picks each next tool itself

Predictable path

easy to test and audit

Path varies by case

needs limits and checks

  1. 1The request follows the fixed steps.
  2. 2The request goes to the model, which picks each step.
  3. 3The steps run in the order your code sets.
  4. 4The path changes with each case, so it needs limits and checks.
The same request, two ways. A workflow runs steps in an order your code sets, so its path is predictable and easier to test. An agent lets the model choose the next step, so the path changes with each case.

Three AI companies describe agents in similar words:

  • “Agents are systems that independently accomplish tasks on your behalf.”

    OpenAI

  • “Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.”

    Anthropic

  • “AI agents are software systems that use AI to pursue goals and complete tasks on behalf of users.”

    Google Cloud

Tip

Asked to define an agent, give the one-line test: does the model choose the next step? If not, it is a workflow, and a fixed script may be the better and cheaper choice.

What makes an agent risky to run?

An agent can take actions, so its mistakes cost more. Anthropic names two costs of this autonomy: higher costs, and the potential for compounding errors, because each extra step can build on a wrong one.

Take a claims agent with made-up numbers. On a normal claim it makes about 12 tool calls. One day a bad tool result leaves it stuck on the same policy lookup. Without a step cap, that lookup repeats hundreds of times. With a cap of 15, the run stops, is logged and goes to a human claims handler.

  • No stop rule

    The loop keeps going

    The stuck lookup repeats hundreds of times while the bill keeps climbing.

  • With a stop rule

    Stops at 15 steps

    The run ends, is logged and goes to a person. The claim waits, which costs time.

OpenAI's guide says actions that are sensitive, irreversible or high stakes should trigger human oversight until confidence in the agent's reliability grows. Its examples are cancelling user orders, authorising large refunds and making payments.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: a system that picks its own steps and uses tools to reach a goal.
  • Agent versus chatbot: an agent uses tools and reads their results, while a simple chatbot just replies.
  • Agent versus workflow: who chooses the next step.
  • The loop, with a stop rule such as a step limit.
  • Cost and risk: errors compound, so people approve risky actions.
  • Simplest first: a fixed script often beats an agent.

Common traps

  • Trap"An agent is just a chatbot with a longer prompt."

    BetterThe difference is the loop and the tools. A simple chatbot answers once, while an agent acts and reads the results.

  • Trap"The model runs the tools."

    BetterThe model only asks. Your code checks and runs each tool, so that is where limits and approvals go.

  • Trap"Every LLM app is an agent."

    BetterNot if the model only writes text. OpenAI says applications that don't use the model to control the workflow are not agents.

Can you spot the safe loop?

Spot the safe loop

Which option is the safest way to run a claims agent?

Quick check

An agent's bill jumps because a tool keeps failing and the loop keeps retrying. What should you add first?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q158Workflow vs agent?10 min
  2. Q160What is the agent loop?12 min
  3. Q172When and how do you add a human in the loop?12 min
  4. Q174What are common agent failure modes?12 min
  5. Q201What is prompt injection?12 min

Learn it in depth

Last updated on 26 November 2026

Building an agent that works through your tools and data?

I design and build AI agents, including the screens people use to run them and the limits and approvals behind them. Book a short call and tell me what your agent needs to do.