What is a learning agent?
A learning agent is an agent that improves its own performance through experience. Instead of relying only on the knowledge its designer built in, it observes the results of its actions, judges how well it did, and changes its future behaviour.
Every other agent type can be turned into a learning agent: a simple reflex agent can learn better condition-action rules, a model-based agent can learn a more accurate model of the world, and a utility-based agent can learn better utility estimates. Learning matters most when the environment is unknown or changing, one of the properties of environments that decide how an agent must be built. The four-part architecture below is the one given by Russell and Norvig in Artificial Intelligence: A Modern Approach.
Architecture of a learning agent
Performance standard
|
v
Sensors ------> [ CRITIC ] ---- feedback ----+
^ |
| v
ENVIRONMENT [ LEARNING ELEMENT ]
| | |
| changes | | learning goals
| v v
Actuators <---- [ PERFORMANCE ELEMENT ] [ PROBLEM GENERATOR ]
^ (knowledge) |
+------ suggested experiments -+
A learning agent is divided into four conceptual components:
- Performance element: the part that selects actions. It takes percepts and decides what to do. This is what we would call "the agent" if it did not learn.
- Critic: tells the learning element how well the agent is doing, by comparing behaviour against a fixed performance standard. The standard has to come from outside the agent; if the agent could change it, it could simply lower the bar instead of improving.
- Learning element: uses the critic's feedback to decide how the performance element should be changed, and makes those changes to its knowledge (rules, model, weights or utility estimates).
- Problem generator: suggests exploratory actions that may be worse in the short term but lead to new, informative experiences. Without it, the agent would keep repeating whatever looks best now and might never discover a better option.
Worked example: an automated taxi
Russell and Norvig use a self-driving taxi to show how the four parts work together:
| Component | What it does for the taxi |
|---|---|
| Performance element | Holds the driving knowledge and chooses actions: steer, brake, change lane, pick a route. |
| Critic | Watches the result of each action against the performance standard. After a sharp lane change across three lanes, it notices the shocked reaction of other drivers and reports that the action was bad. |
| Learning element | Turns that feedback into a new rule, for example "do not cut across several lanes at once", or updates its estimate of braking distance on a wet road. |
| Problem generator | Suggests experiments, such as trying a different route at rush hour or testing the brakes on a new road surface, to learn things the current behaviour would never reveal. |
A learning agent in Python
This small program makes all four components explicit. The agent must pick one of three routes for a daily trip. It does not know how often each route arrives on time; it learns that by driving.
import random
random.seed(7)
TRUE_SUCCESS = {'route_A': 0.3, 'route_B': 0.8, 'route_C': 0.5} # hidden from the agent
class LearningAgent:
def __init__(self, actions, epsilon=0.1):
self.estimate = {a: 0.0 for a in actions} # knowledge used by the performance element
self.count = {a: 0 for a in actions}
self.epsilon = epsilon
def performance_element(self):
return max(self.estimate, key=self.estimate.get) # best action known so far
def problem_generator(self):
if random.random() < self.epsilon: # sometimes try something new
return random.choice(list(self.estimate))
return None
def critic(self, arrived_on_time):
return 1.0 if arrived_on_time else 0.0 # performance standard: on time = 1
def learning_element(self, action, feedback):
self.count[action] += 1
n = self.count[action]
self.estimate[action] += (feedback - self.estimate[action]) / n # running average
def step(self):
action = self.problem_generator() or self.performance_element()
percept = random.random() < TRUE_SUCCESS[action] # environment responds
self.learning_element(action, self.critic(percept))
return action
agent = LearningAgent(TRUE_SUCCESS)
for trip in range(1, 501):
agent.step()
if trip in (10, 100, 500):
est = {a: round(v, 2) for a, v in agent.estimate.items()}
print(f"after {trip:3} trips: estimates {est}, uses per route {agent.count}")
print("chosen route:", agent.performance_element())
Output:
after 10 trips: estimates {'route_A': 0.75, 'route_B': 0.67, 'route_C': 0.67}, uses per route {'route_A': 4, 'route_B': 3, 'route_C': 3}
after 100 trips: estimates {'route_A': 0.5, 'route_B': 0.83, 'route_C': 0.67}, uses per route {'route_A': 12, 'route_B': 82, 'route_C': 6}
after 500 trips: estimates {'route_A': 0.5, 'route_B': 0.82, 'route_C': 0.39}, uses per route {'route_A': 26, 'route_B': 451, 'route_C': 23}
chosen route: route_B
- Performance element:
performance_element()picks the route with the best estimated on-time rate. - Critic:
critic()applies the performance standard (on time = 1, late = 0). - Learning element:
learning_element()updates the running average for the route just used. - Problem generator:
problem_generator()picks a random route 10% of the time (an epsilon-greedy strategy).
Early on, the agent overrates route A by luck (0.75 after 4 trips). Because the problem generator keeps sampling the other routes, it finds out that route B is better and ends up using it for about 90% of trips. Set epsilon=0 and the agent can lock onto whichever route got lucky first; that is exactly why the problem generator exists. (Output shown is from Python 3 with random.seed(7).)
How learning agents learn
The kind of feedback the critic can give decides the type of learning:
| Type | Feedback available | Example |
|---|---|---|
| Supervised learning | The correct answer for each example | Learning to recognise stop signs from labelled photos |
| Reinforcement learning | A reward or penalty after acting, often delayed | The route agent above; game-playing agents |
| Unsupervised learning | No feedback; find structure in the data | Grouping customers by behaviour |
The difference between supervised and unsupervised learning is covered separately. In the learning-agent picture, the critic is what makes reinforcement learning possible: it converts raw percepts into a signal of "good" or "bad".
Advantages and limitations
- Works in unknown environments: the designer does not need to foresee every situation.
- Keeps improving as conditions change, such as new traffic patterns or new user preferences.
- Needs a good performance standard: a badly chosen standard teaches the wrong behaviour.
- Exploration has a cost: trying worse actions to learn can be expensive or unsafe, so real systems limit where exploration is allowed.
- Needs data and time: early behaviour can be poor until enough experience has been collected.
For the other agent types that a learning agent builds on, see intelligent agents and the basic kinds of agent programs. Learned rules are often stored as condition-action rules, the same form used in production systems. Agents, search and learning are covered in Uncodemy's Artificial Intelligence course.


