# 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.

AI and LLM interview question Q157, Agents and tool use. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-an-ai-agent

## Say it in 30 seconds

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.

## Say it in 2 minutes

A simple chatbot reads your message, writes a reply and stops. An AI agent keeps going. It is a system built around a large language model (LLM) that works toward a goal by calling tools, such as looking up a record, reading a file or sending a message. It chooses its next step after each result. OpenAI describes agents as systems that independently accomplish tasks on your behalf.

Under the hood it is a loop. The model gets the goal and the list of tools. It asks for one tool, my code runs that tool, and the result goes back into the model. The loop repeats until the goal is met or a stop rule fires, such as a maximum number of steps. Anthropic says agents are typically just LLMs using tools based on environmental feedback in a loop.

In an interview, I draw the line between a workflow and an agent. A workflow follows a path that developers write in code. An agent lets the model pick the path while it runs. Anthropic recommends finding the simplest solution possible, so I would not build an agent for a job a fixed script can do.

Agents bring risk. They cost more per task, and errors can compound across steps. So I set a step limit, give each tool the least access it needs, and send risky actions to a person. In a claims agent, it can read the file and ask for a repair quote, but a human approves any payment.

## 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.

- **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.

*Diagram, One run of an agent: 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. The goal goes in as the first message.
2. The model asks for one tool, such as a policy lookup.
3. The tool's result goes back into the model, and the loop repeats.
4. Once the goal is met, the model writes its answer.
5. The answer goes to the person, and the run ends.

1. **Get the goal:** Your app gives the model the goal, its rules and the list of tools it may use.
2. **The model picks one tool:** It asks for a tool and the inputs it needs. It does not run the tool itself.
3. **Your code runs the tool:** Your code checks the request, runs the tool and collects the result.
4. **The result goes back in:** The model reads the result and decides the next step.
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:

```text
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.

*Diagram, Workflow versus agent: 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.*
1. The request follows the fixed steps.
2. The request goes to the model, which picks each step.
3. The steps run in the order your code sets.
4. The path changes with each case, so it needs limits and checks.

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." Better: The 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." Better: The 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." Better: Not 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?

A. Loop 15 times and run whatever tool the model asks for.
B. Loop without an end, running each tool the model asks for.
C. Loop 15 times, and run each chosen tool only if allowed(tool) says yes.
D. Send the model's reply to the customer without any check.

**Answer:** C. It has a step cap and checks each tool before it runs. The first option runs any tool the model asks for, the second never stops, and the last sends the reply with no check.

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

A. A longer system prompt
B. A step limit and a cost cap in code
C. A bigger model
D. Switch to a cheaper model

**Answer:** B. A stop rule in code ends a runaway loop, and the model cannot switch it off. A longer prompt, a bigger model or a cheaper model do not stop the loop.

## Can you answer these from memory?

**Flash cards**

- **What is an AI agent?** A system that picks its own steps and uses tools to reach a goal.
- **Agent versus chatbot?** A simple chatbot replies. An agent acts through tools and reads the results.
- **Agent versus workflow?** In a workflow your code sets the path. In an agent the model picks it.
- **What is the agent loop?** Decide, call a tool, read the result, decide again, until done or stopped.
- **Why a step limit?** A loop can repeat forever or cost too much. A cap ends the run.
- **Is an agent always the answer?** No. Anthropic advises the simplest solution that works first.

## Likely follow-up questions

- Q158 Workflow vs agent? https://designervenkat.online/interview/ai/workflow-vs-agent
- Q160 What is the agent loop? https://designervenkat.online/interview/ai/what-is-the-agent-loop
- Q172 When and how do you add a human in the loop? https://designervenkat.online/interview/ai/human-in-the-loop-for-ai-agents
- Q174 What are common agent failure modes? https://designervenkat.online/interview/ai/common-ai-agent-failure-modes
- Q201 What is prompt injection? https://designervenkat.online/interview/ai/what-is-prompt-injection

## Learn it in depth

- [AI Agents](https://designervenkat.online/learn/ai-engineering/ai-agents)
