Module 1 · Lesson 5 · 14 min read

Types of agents

Types of Agents

Introduction

Not all agents are alike; some react with simple rules, while others plan, weigh options and learn from their mistakes. In this lesson we review the classical classification of agents and link it to modern language agents, then compare the types in practice on a single problem.

Learning objectives

  • Describe the main types: reactive, deliberative, goal-based, utility-based and learning
  • Explain the role of the utility function in choosing between options
  • Link the concept of the learning agent to the idea of Reflexion
  • Choose the right type for a given problem

Why classify agents?

Classification is not an academic luxury. When you know the type of agent you need, you know how much complexity your solution deserves. The classical classification in AI textbooks orders agents from the simplest to the most complex, and each type adds a capability to the one before it. We present each type and then link it to modern language agents.

The main types

The simple reactive agent

It acts only on the current perception through "if ... then ..." rules. No memory and no planning. Example: a mail filter that deletes every message containing a certain word. Fast and predictable, but it fails when the decision needs knowledge of what happened before.

The model-based reflex agent

It keeps an internal state describing what it cannot currently see of the environment. Example: a robot vacuum that remembers the rooms it has cleaned.

The deliberative agent

It builds a representation of the world and thinks about the consequences of actions before carrying them out, that is, it plans. Slower than the reactive agent, but it handles multi-step problems.

The goal-based agent

It chooses its actions according to whether they bring it closer to a specific goal. It asks: "Does this action get me to the goal?" Most language model agents today are of this type: you give it a goal and it looks for a way to reach it.

The utility-based agent

It is not content with reaching the goal; it compares different routes through a utility function that gives each outcome a score. Example: a booking agent that does not look for any flight but for the flight that balances price, duration and arrival time.

The learning agent

It improves its performance over time from feedback. In language agents this usually does not mean retraining the model, but saving written lessons in memory and using them later. The Reflexion paper (Shinn and colleagues, 2023) is an example of this: the agent writes a verbal reflection on its mistakes and benefits from it in the next attempt.

The autonomous agent

A description of a degree of autonomy more than an architectural type: an agent that works for long periods and makes a chain of decisions without continuous human intervention. It is the subject of the autonomous agents module.

1. AssistantOnly suggests2. Executor with approvalEvery action is approved3. Semi-autonomousSensitive actions are approved4. AutonomousLimits, monitoring and an immediate stop
Autonomy levels: the more autonomy, the less human intervention and the greater the need for monitoring and limits.

A practical example: choosing a study room

A group of four students wants a room to study in. Let us see how each type behaves:

  • Reactive: books the first empty room it finds.
  • Goal-based: looks for an empty room that seats at least four.
  • Utility-based: balances capacity, closeness to the library and having a whiteboard.

The following code compares the three types on the same data:

python
rooms = [
    {"name": "A1", "free": True,  "seats": 2, "distance": 1, "board": False},
    {"name": "B4", "free": True,  "seats": 6, "distance": 5, "board": True},
    {"name": "C2", "free": True,  "seats": 4, "distance": 2, "board": True},
    {"name": "D7", "free": False, "seats": 8, "distance": 1, "board": True},
]

def reactive(rooms):
    return next(r["name"] for r in rooms if r["free"])

def goal_based(rooms, group=4):
    return next(r["name"] for r in rooms if r["free"] and r["seats"] >= group)

def utility(room, group=4):
    if not room["free"] or room["seats"] < group:
        return float("-inf")
    return 2 * room["board"] - 0.5 * room["distance"] - 0.1 * (room["seats"] - group)

def utility_based(rooms):
    return max(rooms, key=utility)["name"]

print("Reactive:", reactive(rooms))            # A1 is not big enough for the group
print("Goal-based:", goal_based(rooms))  # B4 is big enough but far away
print("Utility-based:", utility_based(rooms))  # C2 is the best balance

Notice that each type gave a different answer. The reactive agent missed the goal, the goal-based agent reached it but with a less than ideal option, and the utility-based agent balanced the criteria.

How do you choose the right type?

If the problem...The suitable type is usually
Has clear, fixed rulesSimple reactive
Needs to remember what cannot be seen nowModel-based reflex
Has a clear goal and several routesGoal-based
Involves trade-offs between criteriaUtility-based
Recurs, and its mistakes can be learned fromLearning

Summary

The classical classification orders agents from the simple reactive agent that follows fixed rules, to the model-based agent that keeps state, then the deliberative agent that plans, then the goal-based agent, then the utility-based agent that balances criteria, and finally the learning agent that improves from feedback. Most language model agents are goal-based, and they may add a utility function or a learning mechanism such as Reflexion. Choosing the type determines how much complexity your solution justifies.

Terms

TermEnglishDefinition
Reactive agentReactive AgentAn agent that acts by rules on the current perception without memory or planning
Deliberative agentDeliberative AgentAn agent that builds a representation of the world and plans before acting
Goal-based agentGoal-based AgentAn agent that chooses its actions by how close they bring it to a specific goal
Utility functionUtility FunctionA function that gives each outcome a score for choosing between options
Learning agentLearning AgentAn agent that improves its performance from feedback over time
ReflexionReflexionA technique in which the agent writes a verbal reflection on its mistakes to benefit from later

Review questions

  1. What is the difference between a goal-based agent and a utility-based agent?
  2. Why did the reactive agent fail in the study room example?
  3. How does a language agent "learn" without retraining the model?
  4. Propose a utility function for an agent that chooses a restaurant for students in university housing.

References