Types of Agents in AI Explained With Simple Examples

Last Updated 20 Aug, 2026
Quick Answer

What are the main types of agents in AI?

The five main types of AI agents are simple reflex, model-based, goal-based, utility-based, and learning agents. They vary in how they perceive their environment, store memory, make decisions, and improve over time.

  • How reflex, model, goal, utility, and learning agents function
  • Python code demonstrations for each agent type
  • How agent types compare and group into reactive and deliberative categories

There are many types of agents in AI, and each one thinks and acts in a different way. Some agents just react to what they see. Others plan ahead or even learn from mistakes. In this guide, you will learn about all the main types of agents in AI with easy examples and simple code.

Simple Reflex Agents

This part explains the most basic type of agent, which reacts without thinking deeply.

A simple reflex agent looks at the current situation only. It does not remember the past. It just follows a fixed rule: "if this happens, do that."

This type of agent works well in simple, clear situations. But it fails in tricky situations because it cannot think or plan.

Example: A thermostat is a simple reflex agent. If the room is cold, it turns the heater on. If the room is warm, it turns the heater off.

def thermostat_agent(temperature):
    if temperature < 18:
        return "Turn heater ON"
    else:
        return "Turn heater OFF"

print(thermostat_agent(15))
print(thermostat_agent(22))

This code checks only the current temperature. If it is below 18, it turns the heater on. It does not look at any past temperature, which is why it is called a simple reflex agent. 

Simple Reflex Agent

How a simple reflex agent works: it only reacts to what it sees right now.

Model-Based Agents

This part explains an agent that keeps a memory of the world to make better choices.

A model-based agent keeps an internal "model" or memory of the world. This means it remembers what it cannot fully see right now. It uses this memory along with new information to decide what to do.

This type of agent works well when the agent cannot see everything at once.

Example: 

A robot vacuum cleaner is a model-based agent. It remembers which rooms it already cleaned, even if it cannot see them right now.

cleaned_rooms = set()

def vacuum_agent(current_room):
    if current_room in cleaned_rooms:
        return f"{current_room} already clean, move to next room"
    else:
        cleaned_rooms.add(current_room)
        return f"Cleaning {current_room} now"

print(vacuum_agent("Kitchen"))
print(vacuum_agent("Kitchen"))

The code stores cleaned room names in memory using cleaned_rooms. When the agent visits a room again, it checks its memory first before deciding what to do. 

Goal-Based Agents

This part explains an agent that thinks about the future goal, not just the current step.

A goal-based agent has a clear goal in mind. It picks actions that move it closer to that goal, instead of just reacting to the present.

This type of agent can plan several steps ahead to reach its target.

Example: 

A GPS navigation app is a goal-based agent. Its goal is to reach the destination, so it picks the best route to get there.

def navigation_agent(current_location, destination):
    if current_location == destination:
        return "Goal reached!"
    else:
        return f"Move from {current_location} toward {destination}"

print(navigation_agent("Home", "Office"))
print(navigation_agent("Office", "Office"))

This code compares the current location with the goal (destination). If they do not match, the agent keeps moving toward the goal. 

Utility-Based Agents

This part explains an agent that picks the best possible action, not just any action that reaches the goal.

A utility-based agent does not just try to reach a goal. It tries to reach the goal in the best way. It gives a score, called utility, to each possible action and picks the action with the highest score.

This type of agent is useful when there are many ways to reach a goal, and some ways are better than others.

Example: 

A ride-sharing app is a utility-based agent. It picks the route that is fastest and cheapest, not just any route that reaches the destination.

routes = {"Route A": 8, "Route B": 5, "Route C": 9}

def utility_agent(routes):
    best_route = max(routes, key=routes.get)
    return f"Choose {best_route} with score {routes[best_route]}"

print(utility_agent(routes))

Each route has a score, called utility. The code picks the route with the highest score, which means the best possible choice.

Learning Agents 

This part explains an agent that gets smarter over time by learning from experience.

A learning agent starts with basic knowledge and improves itself over time. It learns from its mistakes and successes, so it performs better in the future.

This type of agent has four main parts: a learning part, a performance part, a critic (which checks results), and a problem generator (which tries new ideas).

Example: 

A spam email filter is a learning agent. It gets better at spotting spam emails as it sees more examples over time.

spam_words = ["free", "winner", "offer"]

def learning_agent(email_text, feedback_word=None):
    if feedback_word and feedback_word not in spam_words:
        spam_words.append(feedback_word)
    for word in spam_words:
        if word in email_text.lower():
            return "Marked as SPAM"
    return "Marked as SAFE"

print(learning_agent("You are a winner!"))
print(learning_agent("Cheap loan offer today", "loan"))

The code keeps a list of spam words. When new feedback is given, it adds a new word to the list, so the agent learns and improves over time. 

Learning Agents

The five main types of agents in AI, from simplest to smartest.

Comparison Table: Types of Agents in AI 

This part gives a quick side-by-side view of all agent types to help you compare them fast.

Agent TypeUses Memory?Has a Goal?Picks Best Option?Learns Over Time?
Simple Reflex AgentNoNoNoNo
Model-Based AgentYesNoNoNo
Goal-Based AgentYesYesNoNo
Utility-Based AgentYesYesYesNo
Learning AgentYesYesYesYes

Reactive, Deliberative, and Hybrid Agents 

This part groups the above agent types into three bigger families based on how they think.

  • Reactive Agents: These agents act only on the current situation, with no memory or planning. Simple reflex agents belong here.
  • Deliberative Agents: These agents think, plan, and use memory before acting. Model-based, goal-based, and utility-based agents belong here.
  • Hybrid Agents: These agents mix fast reactions with deep planning. Learning agents often work as hybrid agents because they react quickly but also plan and improve using memory.

Example: A self-driving car is a hybrid agent. It reacts fast to sudden obstacles, but it also plans the full route ahead of time.

Every AI system you use is built using one of these types of agents in AI. Simple reflex agents react fast but cannot think ahead, while learning agents grow smarter with time. As the agent type gets more advanced, it gains more memory, planning, and decision-making power. Knowing these types of agents in AI helps you understand how any smart system, from a thermostat to a self-driving car, actually makes its decisions.

Frequently Asked Questions

A simple reflex agent acts only on current sensory input using predefined if-then rules, without using past memory or planning ahead.

A model-based agent keeps an internal memory or model of the world, allowing it to track parts of the environment it cannot currently see.

A goal-based agent acts to reach a specific destination or objective, whereas a utility-based agent evaluates different paths to pick the best and most optimal route.

A learning agent starts with basic knowledge and continuously improves its performance by learning from mistakes, using a learning element, performance element, critic, and problem generator.