In this article
Before you start
Why interviewers ask this
Agent-type questions test whether a candidate can say what an agent knows and what it can do about the future. "Is a language-model agent goal-based?" and "When would you not use planning?" both start here. A weak answer recites the textbook list of agent types. A strong answer says what the goal-based agent adds to a simple reflex agent, a goal and look-ahead search over a model, and what that costs: search time and a model that can be wrong.
The ladder comes from Artificial Intelligence: A Modern Approach (AIMA) by Russell and Norvig, and teaching slides built on it list four basic types "in order of increasing generality": simple reflex, reflex with state, goal-based and utility-based (Chalmers course slides, 2013). The goal-based agent is the third rung, and the one where planning starts.
Goal-based agents from first principles
- Goal-based agent
- A goal-based agent is an agent that selects actions by searching ahead for a sequence of actions that leads from its current state to a state satisfying a stated goal, using an internal model of what its actions do.
- Goal test
- A goal test is a yes-or-no check that an agent applies to a state to decide whether the goal has been reached, such as "is my position the exit cell?".
- Plan
- A plan is an ordered list of actions that, if carried out in the agent's model of the world, leads from the current state to a state that passes the goal test.
In plain words
Think of planning a walk across a town with a paper map. Before you take one step, you trace routes with a finger, ignore the ones that hit a river and pick one that reaches the station. A reflex agent has no map. It just steps toward the station and hopes. The analogy breaks in one place. A finger on a map assumes the map is right. If a road is closed that the map shows open, the plan fails, so the agent has to look again.
In one precise sentence: a goal-based agent keeps a state, a model of what its actions do and a goal, and picks the action whose predicted result leads towards the goal. The Chalmers slides draw it as the reflex-with-state agent plus a box for goals, feeding the question "what it will be like if I do action A".
Step 1: State the goal as a test
A goal-based agent starts from a goal written as a test it can run on any state. For a robot on a grid the goal test is "my cell is the exit cell". The input is a description of success. The output is a function that answers yes or no for a given state.
Writing the goal as a test matters because the agent never compares plans to a picture of success. It only asks the test. This is also why the design needs the goal to be crisp. "Be helpful" cannot be run on a state, while "the file is saved and the tests pass" can. The next step gives the agent what it needs to try out actions without carrying them out.
Step 2: Model what the actions do
The agent needs a model, a small program that says what each action would do to a state. The slides label this part "what my actions do" and "how the world evolves". In our grid world the model is three lines: a move changes the position by one cell, a wall blocks the move, and each move costs one step.
The input is a state and an action. The output is the predicted next state. The model is the source of both the power and the weakness of the design. A correct model lets the agent test many futures without moving. A wrong model, such as a wall the agent does not know about, makes every plan built on it unreliable. Step 3 uses the model to search.
Step 3: Search for a plan, and choose between plans that reach the goal
Search tries action sequences in the model until one reaches the goal. Breadth-first search expands states by moves taken, so the first goal it finds uses the fewest moves. A* adds a guess of the remaining distance, a heuristic, and expands promising states first. The A* paper by Hart, Nilsson and Raphael (1968) proves that A* returns a cheapest path when the guess never overestimates the remaining cost, and the row-plus-column distance used here never does. On our grids both found equally short paths, and A* expanded fewer states, 37.5 on average against 46.4.1
Now the follow-up. If two plans both reach the goal, the goal test cannot tell them apart. A path cost, one step per move here, lets the search prefer the cheaper plan, as breadth-first search and A* did. A cost cannot weigh a fast but risky route against a slow, safe one. The slides' utility-based agent adds that score, "how happy I will be in such a state", for goals that conflict or outcomes that are uncertain. That is the border between the two types.
Step 4: Act on the first step of the plan
The agent carries out the first action of the plan, not necessarily all of it. Taking one step and then looking again keeps the plan honest, because the world may have moved. The input is the plan. The output is one change in the world.
In a fully known, deterministic world like our grid, an agent can run the whole plan without looking again; in practice agents replan from the new state after each step or short stretch. The consequence is a loop, not a single calculation. Many practical agents commit to a short stretch of the plan and check again.
The more the world changes between steps, the shorter the stretch should be: a robot in a quiet corridor can follow many steps, while a web agent on a page that reloads should check after each click. Acting on the first step also limits the damage of a bad plan, because one wrong step is cheap to undo and a whole wrong plan may not be. Step 5 covers what happens when the check finds something new.
Step 5: Observe, then replan if the world changed
After acting, the agent senses the world again and compares it with what the model predicted. If they match, it continues. If a path is blocked or the goal moved, it searches again from the new state. Anthropic's agent guide (December 2024) describes agents as systems where language models dynamically direct their own process and tool use, and says the task often ends when it is complete, and it is also common to add a stopping condition such as a maximum number of iterations.
The output of this step is either a finished task or a new plan. The stopping rule is part of the design: a goal-based agent whose goal can never be reached will search forever unless it is told when to give up.
Step-by-step description
- State the goal as a yes-or-no test.
- Say what each action does to a state.
- Search the model for a plan that passes the test.
- Carry out the first step of the plan.
- Observe, and search again if the world changed.
- The goal is written as a yes-or-no test on a state.
- The agent acts on the first step of its plan, then observes and replans if the world changed.
Knowing it is half the job. Saying it is the other half.
Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.
Start Free Trial →Worked example
The script builds 1,000 random 8 by 8 grids, each cell other than the start and the goal being a wall with probability 0.25 (seeded, so the run is repeatable). The start is the top-left cell and the goal the bottom-right cell. It compares a greedy reflex rule with a goal-based agent that searches a full map of the walls, so search finds a path whenever one exists. The reflex rule steps to the first free neighbour that is one move closer to the goal, counting rows plus columns, trying down, then right, then up, then left. It stays put if no neighbour is closer. The wall density is our choice and illustrative.1
One layout from the run, with S the start, G the goal and # a wall, shows the difference:
S..#....
..#...#.
..##...#
...#....
.#...#.#
...###..
.###.#..
#......GThe reflex rule walked six steps down the left edge, reached the cell just above a wall at the bottom of the left column, and stopped, because no neighbour was closer to the goal. Breadth-first search found a path of 16 steps around the walls, after expanding 39 states, and A* found the same length after expanding 29.1
| Measure over 1,000 random grids | Value |
|---|---|
| Grids with a path from start to goal | 697 |
| Greedy reflex rule reaches the goal | 162 (23.2%) |
| Search (breadth-first) reaches the goal | 697 (100%) |
| A* path length equals the breadth-first length | 697 of 697 |
| Mean shortest path length | 14.1 steps |
| Mean states expanded, breadth-first | 46.4 |
| Mean states expanded, A* | 37.5 |
The mean shortest path of 14.1 steps is close to the floor of 14 steps, 7 rows plus 7 columns, since most grids have an easy route.1 Other reflex rules do better, trying right first reached the goal on 175 grids and a straight-line-distance rule on 382, but none reaches 697.1 The reflex rule fails not because the route is long but because a wall can sit exactly where it cannot see around. The core of the search is short:
from collections import deque
def plan(start, goal_test, successors):
# breadth-first search: returns a list of states from start to a goal, or None
frontier, parent = deque([start]), {start: None}
while frontier:
state = frontier.popleft()
if goal_test(state):
path = []
while state is not None:
path.append(state); state = parent[state]
return path[::-1]
for nxt in successors(state): # the model: what each action leads to
if nxt not in parent:
parent[nxt] = state; frontier.append(nxt)
return None # the goal cannot be reachedText description of the diagram
- The greedy reflex rule reached the goal on 162 of 697 solvable grids.
- Search reached the goal on all 697 solvable grids.
Trade-offs and edge cases
A goal-based agent wins when the route to the goal is not obvious from the current view. Mazes, route planning, scheduling and multi-step tool use all fit. Its price is search time, which grows quickly as plans get longer because the number of states to try multiplies at every step, and a model that has to be right. If the percept already shows what to do, a simple reflex agent is cheaper and easier to test.
A goal says whether, not how well. When several plans reach the goal and they differ in risk or in trade-offs a single cost cannot rank, the goal test is silent. That is the case for a utility function, the next rung of the ladder.
A wrong model breaks the plan. Plans are only as good as the model, so the agent has to watch the world and replan, as in Step 5. A person can also approve risky steps, as in human-in-the-loop agents.
Language-model agents are not automatically goal-based. The ReAct paper (Yao et al., 2023) has a model alternate reasoning steps and actions, and reports gains of 34 and 10 percentage points in absolute success rate on ALFWorld (text-based household tasks) and WebShop (simulated online shopping) over imitation and reinforcement-learning methods. Whether such an agent counts as goal-based depends on whether it models what actions do and searches ahead, or only follows a prompted loop. The label depends on the definition, so say which sense you mean.
Text description of the diagram
- A reflex agent with state already keeps a model of how the world changes and what its actions do.
- A goal-based agent adds a goal and uses that model to look ahead.
- A utility-based agent scores how good a state is, so it can rank plans that all reach the goal.
How to answer it in an interview
What is a goal-based agent, and how is it different from a reflex agent?
A goal-based agent has a goal it can test and a model of what its actions do, and it searches for a sequence of actions that reaches the goal before it moves. A reflex agent only maps the current percept, what its sensors report right now, to an action. On a grid with walls, my reflex rule got stuck on most layouts, while search reached the goal on every solvable one. The cost is search time and a model that can be wrong, so the agent acts on one step and replans. The goal says whether, not how well, so for cost trade-offs I would add a utility.
The spoken structure is: the definition, the contrast with reflex, then the cost and the utility follow-up.
Common mistakes
- Saying a goal-based agent has a fixed answer. (wrong) "It stores the right action for each situation." (right) "It searches a model for a sequence that reaches the goal."
- Confusing goal-based with utility-based. (wrong) "A goal-based agent weighs safety against speed." (right) "It can prefer the cheapest plan that reaches the goal; weighing conflicting or uncertain outcomes needs a utility."
- Forgetting that the model can be wrong. (wrong) "Once it has a plan it just runs it." (right) "It acts on a step, observes and replans."
- Calling every language-model agent goal-based. (wrong) "Any agent with a goal in the prompt is goal-based." (right) "It depends on whether it models actions and searches ahead."
- Leaving out a stopping rule. (wrong) "It keeps searching until it succeeds." (right) "It needs a limit, because some goals cannot be reached."
Follow-up questions
What is the difference between a goal-based agent and a utility-based agent?
A goal-based agent only distinguishes states that meet the goal from states that do not. A utility-based agent also scores how good a state is, so it can choose between plans when goals conflict, such as speed against safety, or when outcomes are uncertain.
What is the difference between a simple reflex agent and a goal-based agent?
A simple reflex agent answers from the current percept alone, with no look-ahead. A goal-based agent adds a goal and uses a model of its actions to search ahead. In our grid run that was the difference between 162 and 697 successes on 697 solvable grids.1
Is an LLM agent a goal-based agent?
Sometimes. A large language model (LLM) agent loop that holds a goal and chooses actions from it is goal-directed, but the textbook sense needs a model of what actions do and look-ahead (search or planning). See agentic AI interview questions and the Model Context Protocol for how tools are wired in.
Does a goal-based agent always find the best plan?
Only when its search is optimal for the cost it uses, not merely complete: depth-first search finds some path on a finite grid, but not the shortest. Breadth-first search finds the cheapest plan when every move costs the same. For other costs it needs uniform-cost search, or A* with a guess that never overestimates.
When is a goal-based agent the wrong choice?
When the percept already shows what to do, or the model is too poor to trust. Then a rule-based agent or a human check is safer; see prompting and the AI engineer interview questions for neighbouring topics.
- A goal-based agent searches a model of its actions for a plan that passes a goal test, then acts.
- It adds a goal and look-ahead to a simple reflex agent, and pays in search time and model risk.
- A goal says whether, not how well; weighing conflicting or uncertain outcomes needs a utility.
- In our grid run, search reached the goal on all 697 solvable grids and the greedy reflex rule on 162.
- Act on one step, observe, replan, and set a stopping rule.
Sources
- Artificial Intelligence: A Modern Approach, 4th US edition (companion site) — Russell and Norvig, UC Berkeley (date = site last modified), 22 Aug 2022
- Intelligent Agents, Chapter 2 slides (spring 2013, based on the AIMA slides of 2004) — Chalmers University of Technology (Ljunglof), 19 Mar 2013
- A Formal Basis for the Heuristic Determination of Minimum Cost Paths — IEEE Transactions on Systems Science and Cybernetics 4(2) (Hart, Nilsson and Raphael), 1 Jul 1968
- Building effective agents — Anthropic, 19 Dec 2024
- ReAct: Synergizing Reasoning and Acting in Language Models (arXiv 2210.03629 v3) — arXiv (Yao et al.), 10 Mar 2023