In modern artificial intelligence, the central unifying concept is the Intelligent Agent. Rather than viewing AI merely as isolated algorithms for search or classification, the agent framework defines AI as an autonomous entity that interacts with its surrounding world through an ongoing perception-action cycle.
Figure 3.1: The Intelligent Agent Perception-Action Cycle — Processing Percept Sequences through Sensors and Executing Rational Actions via Actuators.
An Agent is anything that can view its environment through sensors and act upon that environment through actuators:
A rational agent is one that does the right thing. Concretely, for each possible percept sequence, a rational agent selects an action expected to maximize its performance measure, given the evidence provided by the percept sequence and whatever built-in knowledge the agent possesses.
An omniscient agent knows the actual outcome of its actions and can act accordingly (impossible in reality due to uncertainty). A rational agent maximizes expected performance based on available information, active exploration, and learning. If a pedestrian looks both ways, sees an empty road, steps onto a crosswalk, and is struck by a falling meteor, the decision to cross was completely rational despite the catastrophic outcome.
Before designing an AI agent, an engineer must rigorously specify the task environment using the PEAS acronym:
| Agent Type | Performance Measure (P) | Environment (E) | Actuators (A) | Sensors (S) |
|---|---|---|---|---|
| Autonomous Self-Driving Car | Safety, destination arrival time, legal compliance, passenger comfort, fuel efficiency | Roads, traffic, pedestrians, weather conditions, highway signs | Steering wheel, accelerator pedal, disc brakes, turn signals, horn | LiDAR, RADAR, video cameras, ultrasonic sensors, GPS, accelerometer |
| Automated Medical Diagnostic System | Diagnostic accuracy, minimized false negatives, patient recovery time, cost reduction | Hospital EHR database, patient physiological signs, clinical tests | Prescription generator, test order requests, referral notices | Patient symptoms input, lab results, vital signs monitor, MRI scans |
| Automated Vacuum Cleaner | Percentage of floor cleaned, battery consumption, time efficiency, low noise | Carpets, hardwood floors, room walls, furniture obstacles, stairs | Drive wheels, vacuum suction motor, rotating brushes, dirt bag ejector | Infrared distance bumper, cliff fall sensors, dirt particle sensor |
| Algorithmic High-Frequency Trader | Portfolio return on investment (ROI), Sharpe ratio, maximum drawdown risk | Global stock exchanges (NASDAQ, NYSE), news feeds, economic reports | Buy/Sell trade orders, portfolio rebalancing transactions | Real-time tick data feeds, order book depth (L2), news APIs |
The difficulty of designing an AI agent is determined by the properties of its environment:
| Environment Property | Definition & Comparison | Example (Easy vs Hard) |
|---|---|---|
| Fully Observable vs Partially Observable | In a fully observable environment, sensors detect the complete world state at each point in time. In partially observable environments, sensors have noise, occlusion, or blind spots. | Chess (Fully Observable) vs Poker or Driving (Partially Observable). |
| Deterministic vs Stochastic | In a deterministic environment, the next state is completely determined by the current state and the agent's action. A stochastic environment involves randomness or probabilities. | Tic-Tac-Toe (Deterministic) vs Dice games or Real-world Traffic (Stochastic). |
| Episodic vs Sequential | In an episodic environment, the agent's experience is divided into independent atomic episodes; past actions do not affect future episodes. In sequential environments, current actions dictate future states. | Part defect image classification (Episodic) vs Chess or Self-Driving (Sequential). |
| Static vs Dynamic | A static environment does not change while the agent is deliberating. A dynamic environment changes continuously over time while the agent thinks. | Crossword puzzle (Static) vs Taxi driving or RTS gaming (Dynamic). |
| Discrete vs Continuous | A discrete environment has a finite, countable number of distinct states, time steps, and actions. A continuous environment has continuous parameters (speed, coordinates). | Checkers (Discrete) vs Autonomous drone flight (Continuous). |
| Single-Agent vs Multi-Agent | A single-agent environment contains only one active agent optimizing a performance goal. Multi-agent environments contain competing or collaborating agents. | Crossword puzzle (Single-Agent) vs Football or Multi-player Chess (Multi-Agent). |
AI engineering recognizes five primary agent architectural templates, progressing from simple reactivity to deep goal deliberation:
IF condition THEN action. Ignores percept history. Fails entirely in partially observable worlds.Here is a complete, working Python implementation demonstrating a Model-Based Reflex Agent operating in a two-room environment:
class Environment:
def __init__(self):
# Room A and Room B states: 'Clean' or 'Dirty'
self.locations = {'A': 'Dirty', 'B': 'Dirty'}
def is_dirty(self, location):
return self.locations[location] == 'Dirty'
def clean(self, location):
self.locations[location] = 'Clean'
class ModelBasedVacuumAgent:
def __init__(self):
# Internal model of world state
self.model = {'A': 'Unknown', 'B': 'Unknown'}
self.last_action = None
self.score = 0
def perceive_and_act(self, current_location, status, env):
# 1. Update internal model based on percept
self.model[current_location] = status
print(f"[Percept] Location: {current_location} | Status: {status} | Internal Model: {self.model}")
# 2. Rule evaluation based on internal state
if status == 'Dirty':
action = 'SUCK'
env.clean(current_location)
self.model[current_location] = 'Clean'
self.score += 10
elif current_location == 'A':
action = 'MOVE_RIGHT'
elif current_location == 'B':
action = 'MOVE_LEFT'
else:
action = 'NO_OP'
self.last_action = action
print(f" -> Action chosen: {action} (Performance Score: {self.score})")
return action
# Simulation Execution
env = Environment()
agent = ModelBasedVacuumAgent()
# Step 1: Agent starts at Room A
agent.perceive_and_act('A', env.locations['A'], env)
# Step 2: Agent moves to Room B
agent.perceive_and_act('B', env.locations['B'], env)
# Step 3: Agent verifies Room B is clean
agent.perceive_and_act('B', env.locations['B'], env)
Broaden your foundational and advanced AI knowledge across our curriculum:
State space exploration, frontier expansion, and search strategies.
Admissible heuristics, priority queues, and optimal pathfinding.
Modern ReAct loops, tool calling, and cognitive agent architectures.
Top exam questions on agents, rationality, environments, and PEAS.