GyaanStack. Blog

Articles / agentsgenai-system-design

Types of AI agents: the five classic kinds, mapped to 2026 LLM systems

The five agent types from Russell and Norvig, each mapped to a real LLM product pattern, plus one runnable Python grid world that shows how each behaves.

By Raghunath · · 17 min read

The standard taxonomy of agents comes from chapter 2 of Russell and Norvig's Artificial Intelligence: A Modern Approach (AIMA). Section 2.4 lists five agent programs: simple reflex, model-based reflex, goal-based, utility-based and learning agents (AIMA contents). The list is decades old and still useful, because it sorts agents by what the program consults before it acts: the current input only, a remembered picture of the world, a goal, a score over outcomes, or feedback from past runs.

That question applies to LLM systems too. An LLM call inside a system does not make it a goal-based agent. A stateless classifier that labels each support ticket is a simple reflex agent, even if a frontier model does the labelling.

This post defines each type, maps it to a 2026 LLM pattern with a concrete example, and runs all five on one toy delivery robot so you can see the behaviour differ in the output. It does not cover LLM control-flow patterns such as ReAct, plan-and-execute and routers; those are in AI agent architectures explained. Systems with more than one agent are in Multi-agent architecture patterns.

The ladder in one picture#

Each type adds one thing to the one before it.

type                 what it consults before acting           added over previous
-------------------  ---------------------------------------  --------------------------
1 simple reflex      current percept -> rule                  (baseline)
2 model-based        percept + internal state of the world    memory of what it cannot see
3 goal-based         state + a goal + "what happens if I..."  search or planning
4 utility-based      state + a score over outcomes            trade-offs between goals
5 learning           any of the above + a critic's feedback   changes itself over time

AIMA treats "learning" differently from the other four. Types 1 to 4 describe how the agent picks an action. A learning agent is a wrapper that can improve any of them. AIMA splits it into four parts: a performance element (the agent that acts), a critic (scores how it did), a learning element (changes the performance element) and a problem generator (suggests exploratory actions). Those four parts map cleanly onto an LLM app with an eval loop, which comes up below.

The toy world#

One environment for all five, so only the agent program changes. A delivery robot starts at S and must reach G. # is a wall. ~ is mud: the robot can cross it, but entering a mud cell drains 6 units of battery instead of 1.

S....      row 0
##~#.      row 1
G....      row 2
#....      row 3

There are two sensible routes. The short one goes east two cells, down through the mud and back west: 6 moves, 11 battery. The long one goes along the top row, down the right edge and back along row 2: 10 moves, 10 battery. Which route an agent picks, or whether it arrives at all, depends on its type.

The robot always knows its own cell and senses which of its four neighbours are open. Only types 3 and 4 get the full map.

The code#

Pure Python 3, standard library only, no model calls. Each agent is a policy: a function from the current cell to a move (E, S, W, N).

"""Five classic agent types in one toy world: a delivery robot on a grid."""
import heapq
import random
from collections import deque

GRID = [
    "S....",
    "##~#.",
    "G....",
    "#....",
]
COST = {".": 1, "S": 1, "G": 1, "~": 6}        # battery used to ENTER a cell
MOVES = {"E": (0, 1), "S": (1, 0), "W": (0, -1), "N": (-1, 0)}
START, GOAL = (0, 0), (2, 0)


def free(cell):
    r, c = cell
    return 0 <= r < len(GRID) and 0 <= c < len(GRID[0]) and GRID[r][c] != "#"


def step(cell, move):
    dr, dc = MOVES[move]
    nxt = (cell[0] + dr, cell[1] + dc)
    return nxt if free(nxt) else cell


def percept(cell):
    """What the robot senses: which neighbours are open, and whether it is at the goal."""
    return {m: free((cell[0] + d[0], cell[1] + d[1])) for m, d in MOVES.items()}, cell == GOAL


def run(name, policy, max_steps=25):
    cell, battery, path, moves = START, 0, [START], ""
    for _ in range(max_steps):
        if cell == GOAL:
            break
        move = policy(cell)
        moves += move
        cell = step(cell, move)
        battery += COST[GRID[cell[0]][cell[1]]]
        path.append(cell)
    status = "reached goal" if cell == GOAL else "GAVE UP"
    print(f"{name:<22} {status:<13} steps={len(path)-1:<3} battery={battery:<3} "
          f"mud={sum(GRID[r][c] == '~' for r, c in path)} moves={moves}")


# 1. Simple reflex: condition-action rules on the current percept only.
def simple_reflex(cell):
    open_dirs, _ = percept(cell)
    for move in "ESWN":                    # rule: first open direction in fixed order
        if open_dirs[move]:
            return move


# 2. Model-based reflex: same rules, plus internal state (cells already visited).
class ModelBased:
    def __init__(self):
        self.visited, self.trail = {START}, [START]

    def __call__(self, cell):
        open_dirs, _ = percept(cell)
        for move in "ESWN":
            if open_dirs[move] and step(cell, move) not in self.visited:
                nxt = step(cell, move)
                self.visited.add(nxt)
                self.trail.append(nxt)
                return move
        self.trail.pop()                    # dead end: back up along the remembered trail
        back = self.trail[-1]
        return next(m for m in MOVES if step(cell, m) == back)


# 3. Goal-based: knows the map and the goal, searches for the fewest moves (BFS).
def plan_bfs():
    prev, q = {START: None}, deque([START])
    while q:
        cur = q.popleft()
        for m in MOVES:
            nxt = step(cur, m)
            if nxt not in prev:
                prev[nxt] = (cur, m)
                q.append(nxt)
    return backtrack(prev)


# 4. Utility-based: same map, but scores outcomes; here utility = -battery used (Dijkstra).
def plan_dijkstra():
    best, prev, pq = {START: 0}, {START: None}, [(0, START)]
    while pq:
        cost, cur = heapq.heappop(pq)
        for m in MOVES:
            nxt = step(cur, m)
            new = cost + COST[GRID[nxt[0]][nxt[1]]]
            if nxt != cur and new < best.get(nxt, 1e9):
                best[nxt], prev[nxt] = new, (cur, m)
                heapq.heappush(pq, (new, nxt))
    return backtrack(prev)


def backtrack(prev):
    moves, cur = [], GOAL
    while prev[cur]:
        cur, m = prev[cur]
        moves.append(m)
    plan = dict()
    cell = START
    for m in reversed(moves):
        plan[cell] = m
        cell = step(cell, m)
    return lambda c: plan[c]


# 5. Learning: starts with no map and no plan; learns from reward (tabular Q-learning).
def q_learning(episodes, seed=7, alpha=0.5, gamma=0.95, eps=0.2):
    rng = random.Random(seed)
    Q, log = {}, []
    for ep in range(episodes):
        cell, battery = START, 0
        for _ in range(100):
            qs = [Q.get((cell, m), 0.0) for m in MOVES]
            m = rng.choice(list(MOVES)) if rng.random() < eps else list(MOVES)[qs.index(max(qs))]
            nxt = step(cell, m)
            cost = COST[GRID[nxt[0]][nxt[1]]]
            battery += cost
            reward = -cost + (20 if nxt == GOAL else 0)
            future = 0 if nxt == GOAL else max(Q.get((nxt, a), 0.0) for a in MOVES)
            old = Q.get((cell, m), 0.0)
            Q[(cell, m)] = old + alpha * (reward + gamma * future - old)
            cell = nxt
            if cell == GOAL:
                break
        log.append(battery)
    greedy = lambda c: max(MOVES, key=lambda m: Q.get((c, m), 0.0))
    return greedy, log


if __name__ == "__main__":
    print("\n".join(GRID), "\n")
    run("1 simple reflex", simple_reflex)
    run("2 model-based reflex", ModelBased())
    run("3 goal-based (BFS)", plan_bfs())
    run("4 utility-based", plan_dijkstra())
    policy, log = q_learning(300)
    for a, b in [(0, 1), (1, 10), (10, 50), (290, 300)]:
        print(f"  learning episodes {a+1:>3}-{b:<3} mean battery while exploring: "
              f"{sum(log[a:b]) / (b - a):.1f}")
    run("5 learning (greedy)", policy)

Output from python3 agents.py:

S....
##~#.
G....
#.... 

1 simple reflex        GAVE UP       steps=25  battery=25  mud=0 moves=EEEESSSWEWEWEWEWEWEWEWEWE
2 model-based reflex   reached goal  steps=18  battery=23  mud=1 moves=EEEESSSWWWNEEWNSWW
3 goal-based (BFS)     reached goal  steps=6   battery=11  mud=1 moves=EESSWW
4 utility-based        reached goal  steps=10  battery=10  mud=0 moves=EEEESSWWWW
  learning episodes   1-1   mean battery while exploring: 120.0
  learning episodes   2-10  mean battery while exploring: 32.0
  learning episodes  11-50  mean battery while exploring: 14.6
  learning episodes 291-300 mean battery while exploring: 14.6
5 learning (greedy)    reached goal  steps=10  battery=10  mud=0 moves=EEEESSWWWW

The sections below walk through each line and the LLM system it corresponds to.

1. Simple reflex agents#

A simple reflex agent maps the current percept to an action through condition-action rules. It keeps nothing between steps.

In the grid, the rule is "move to the first open neighbour in the order east, south, west, north". It runs along the top, down the right edge to row 3, and then bounces between two cells (WEWEWE...) until the 25-step limit stops it. It cannot tell that it has been in a cell before, so it cannot break the loop. AIMA notes the same weakness: reflex agents work when the right action can be chosen from the current percept alone, and they tend to loop in environments that are only partly observable.

LLM mapping. Any component that decides from one input with no state:

  • A regex or classifier guardrail that blocks an outgoing reply containing a 16-digit card number.
  • An intent classifier that sends each incoming message to the billing, tech or sales queue. An LLM can be the rule here; it is still a reflex agent if each message is judged alone.
  • A webhook rule such as "when a PR gets the docs label, run the docs linter".

Reflex components are cheap to run, easy to test with a table of inputs and expected outputs, and fail the same way every time. The failure is the one in the grid: a message whose meaning depends on an earlier message ("yes, cancel that one") gets misrouted, because the rule cannot see the earlier message.

2. Model-based reflex agents#

A model-based reflex agent keeps internal state that tracks the parts of the world it cannot currently perceive, and updates that state after each percept. It still acts by rules; the rules can now read the state.

The grid version keeps a set of visited cells and a trail back to the start. It uses the same direction order as the reflex agent but skips cells it has seen, and when it hits a dead end it backs up along the trail. It reaches the goal in 18 moves and 23 battery. That is worse than either planner, and it walked into the mud once while exploring (N then S near the end), but it arrived, which the reflex agent never does.

LLM mapping. Anything that carries state between turns or steps and lets that state shape the next action:

  • A support chatbot that stores the order ID, the customer's tier and the last action taken, so "cancel that one" resolves to a real order. In LangGraph this state lives in a checkpointer keyed by thread (LangGraph persistence docs).
  • A coding agent that loads project memory files such as CLAUDE.md at the start of a session (Claude Code memory docs), giving it a picture of the repo before it has opened a single file.

The design questions are what goes into the state, how long it lives and who can write to it. Agent memory system design covers those in depth. The common failure is stale state: the model of the world says the order is open after another system has already closed it, and the agent acts on the old picture.

3. Goal-based agents#

A goal-based agent has an explicit description of the states it wants to reach, and chooses actions by considering what they will lead to. That requires a way to predict outcomes (a map, a simulator, or the model's own reasoning) and some form of search.

The grid version gets the map and runs breadth-first search for the fewest moves. It finds the 6-move route through the mud: EESSWW, 11 battery. It treats every path that reaches G as equally good and picks the shortest, because "reach G" is all its goal says. Mud is invisible to it as a cost.

LLM mapping. An agent loop with a stated task and a checkable stop condition:

  • A coding agent told "make test_refund_rounding pass". The goal state is a green test run. The model proposes edits, runs the test and repeats until the test passes or a step limit hits.
  • A research agent told "find three primary sources for this claim", which stops when it has three URLs that resolve and contain the claim.

LLM agents rarely search the way BFS does. The model proposes one action at a time and the environment reports back, which is the tool loop in AI agent architectures explained. The goal-based part is the stop condition. Anthropic's guidance on agents makes the same point from the other side: an agent needs to gain "ground truth" from the environment at each step, such as tool results or code execution, to assess its progress (Anthropic, Building effective agents). Without a checkable goal, an LLM agent either stops too early or keeps going until the step limit.

The failure mode matches the grid. A goal says nothing about cost, so the agent can satisfy it in a way you did not want: it deletes the failing test, or it gets there through the mud.

4. Utility-based agents#

A utility-based agent scores outcomes with a utility function and picks the action with the best expected score. Goals say "arrived or not"; utility says how good the arrival was, which lets the agent trade one thing against another.

The grid version uses the same map with Dijkstra's algorithm, scoring a route by battery used. It takes the long way: EEEESSWWWW, 10 moves, 10 battery. It is four moves slower than the goal-based agent and one unit of battery cheaper. If time also mattered, you would put it in the score, for example utility = -(battery + 0.5 * moves), and the answer could flip. Utility only means something once you write down what you are trading.

Change the price of mud and the choice changes with it. With mud at 2 instead of 6, the short route costs 7 and the utility agent takes it. The check further down asserts exactly that.

LLM mapping. Wherever a system picks among options by a score instead of taking the first one that works:

  • A model router that sends each query to the cheapest model expected to answer it well enough. RouteLLM trains such routers on preference data to trade cost against quality (Ong et al., RouteLLM).
  • Best-of-n sampling: generate several candidate answers and keep the one a reward model or judge scores highest.
  • A reranker in RAG that scores retrieved chunks and keeps the top k.

The failure is a utility function that measures the wrong thing. A router scored only on cost sends hard questions to the small model. A judge that rewards long answers picks the longest candidate. The agent optimises the number you gave it, so test the scoring function on its own before you trust the choices it drives.

5. Learning agents#

A learning agent improves its own behaviour from feedback. In AIMA's terms, a critic compares what happened with a performance standard, and the learning element uses that signal to change the performance element.

The grid version starts with no map and no plan, only the ability to try a move and see where it lands. It runs tabular Q-learning, an algorithm from reinforcement learning (Sutton and Barto, Reinforcement Learning: An Introduction), for 300 episodes. The reward is minus the battery used, plus 20 for reaching G. Here the four AIMA parts are easy to point at:

AIMA part             in the grid code                  in an LLM app
--------------------  --------------------------------  ---------------------------------
performance element   greedy policy over the Q table    the agent: prompt + model + tools
critic                reward = -battery (+20 at goal)   eval set, LLM judge, user thumbs
learning element      the Q update line                 prompt optimiser, fine-tune job
problem generator     random move 20% of the time       new test cases, exploration runs

The first episode wanders and burns 120 battery. Episodes 2 to 10 average 32. By episodes 11 to 50 the average is 14.6 and it stays there; that figure includes the 20% random moves. With exploration switched off, the learned policy takes EEEESSWWWW, the same 10-battery route the utility agent computed from the map. It found that route from reward alone, without being shown the map or the mud cost.

LLM mapping. Learning shows up at two levels:

  • Training the model. RLHF fine-tunes a model on human preference comparisons; InstructGPT is the standard reference (Ouyang et al.). The product team usually does not run this, but the model they call is the result of it.
  • Tuning the application. DSPy optimisers rewrite prompts and pick few-shot examples to maximise a metric on a training set (DSPy optimizers). Simpler versions are a nightly job that adds the week's failed conversations to the eval set, or an agent that writes a lesson to its memory file after a user correction.

Learning agents fail through the critic. If the reward is wrong, the agent learns the wrong thing efficiently; this is the same problem as a bad utility function, discovered later and at more cost. Learning from live traffic also lets one bad batch of feedback shift behaviour for everyone, so keep a fixed eval set that the learning loop never trains on and run it before each change ships.

Types mapped to real product patterns#

Type What it uses LLM product pattern Typical failure How to test it
Simple reflex Current input only Guardrail filter, intent router, webhook rule Misreads input that depends on context Table of inputs and expected outputs
Model-based reflex Input + stored state Chatbot with session state, coding agent with project memory Acts on stale or wrong state Multi-turn scripts that check state after each turn
Goal-based State + goal + prediction Agent loop with a test or checklist as stop condition Meets the goal in a way you did not want Tasks with known end states; check side effects too
Utility-based State + score over outcomes Model router, best-of-n with a judge, reranker Optimises a score that measures the wrong thing Test the scoring function alone on labelled pairs
Learning Any of the above + feedback RLHF-trained model, prompt optimiser, eval-driven fixes Learns from a bad critic Held-out eval set the loop never trains on

Real systems stack the types#

A production agent is rarely one type. A typical coding or support agent layers them:

            incoming request
                   |
        [reflex]   guardrail + intent router         (no state, fast, deterministic)
                   |
        [model]    load session state + memory        (what we know so far)
                   |
        [goal]     agent loop until the check passes  (tests green, ticket resolved)
          |   ^
          v   |    [utility] router picks the model; judge picks the best draft
          tools
                   |
        [learning] offline: failed runs -> eval set -> prompt or model update

Naming the layers helps when something breaks, because each type has its own failure and its own test. A wrong route is a reflex bug. "It forgot what I said" is a state bug. "It passed by deleting the test" is a goal-specification bug. "It always uses the expensive model" is a utility bug.

Checking the claims in code#

The output above is one run. These asserts pin the behaviour, so that changing the grid or a policy shows immediately which type stopped behaving as described.

import agents

def battery(policy, limit=25):
    cell, used = agents.START, 0
    for _ in range(limit):
        if cell == agents.GOAL:
            return used
        cell = agents.step(cell, policy(cell))
        used += agents.COST[agents.GRID[cell[0]][cell[1]]]
    return None                                   # never arrived

assert battery(agents.simple_reflex) is None     # reflex loops on this map
assert battery(agents.ModelBased()) is not None  # memory gets it out
assert battery(agents.plan_dijkstra()) <= battery(agents.plan_bfs())

agents.COST["~"] = 2                             # mud gets cheap
assert battery(agents.plan_dijkstra()) == 7      # utility agent now takes the mud
print("all checks passed")
all checks passed

The last assert is the useful one in practice: it checks that the utility agent responds to a change in prices. For an LLM router, the equivalent test lowers the cost of the large model in config and checks that more traffic goes to it.

For evaluating real agents rather than grid robots, Evaluating an AI agent in Python has a harness for tool-call and final-answer checks, and AI agent interview questions covers how this taxonomy comes up in interviews.

Sources#

Found this useful? You can buy me a coffee or support with any amount. It pays for hosting and keeps new articles coming.