AI-470 · Lesson 1 of 12 · 25 min
What makes a system an agent
The word agent is everywhere in AI today: coding agents that edit repositories, browser agents that book travel, customer service agents that resolve tickets, research agents that search and summarize, and robots that act in the physical world. The idea is much older than large language models. Since the early days of AI, researchers have studied systems that perceive an environment, decide what to do and act to achieve goals, often over many steps and in the presence of uncertainty and other agents. This course connects the classical foundations, such as search, planning, decision theory, reinforcement learning and game theory, with modern agents built on language models, and it covers how to evaluate and control them. This first lesson defines agents, describes the environments they operate in, and introduces the main agent designs.
Agents and environments
An agent is anything that perceives its environment through sensors and acts on it through actuators. A thermostat senses temperature and switches a furnace; a robot vacuum senses obstacles and dirt and drives its wheels; a software agent receives text, files and tool results and acts by calling tools, writing files or sending messages. Russell and Norvig describe the agent function as a mapping from the history of percepts to an action, and the agent program as the concrete implementation of that mapping on some hardware.
An agent is judged by a performance measure defined by its designer or user: how clean the floor is and how much energy is used, how many tickets are resolved correctly and how satisfied customers are, how many tests pass and how readable the code is. A rational agent chooses actions expected to maximize its performance measure given what it has perceived and what it knows. Rationality is not omniscience: an agent can act rationally and still fail because of information it could not have had. Specifying the performance measure well is surprisingly hard, and many failures of real agents come from measures that reward the wrong thing, a theme that returns in Lesson 12.
Describing tasks: PEAS
A useful way to specify an agent's task is PEAS: performance measure, environment, actuators and sensors. For a warehouse picking robot, performance includes items picked per hour, errors and safety incidents; the environment is the warehouse with shelves, bins, people and other robots; actuators are wheels, an arm and a gripper; sensors are cameras, depth sensors, encoders and barcode readers. For a software engineering agent, performance includes correct, tested changes delivered within budget without breaking other functionality; the environment is a code repository, a terminal, tests and documentation; actuators are file edits and commands; sensors are file contents, command outputs and test results. Writing a PEAS description before building an agent clarifies what success means and what the agent must be able to observe and do.
Properties of environments
Environments differ in ways that determine how hard the agent's problem is:
- Fully or partially observable: can the agent see everything relevant? A chess program sees the whole board; a poker agent cannot see opponents' cards; a coding agent sees only the files it opens.
- Deterministic or stochastic: do actions have predictable results? A file write is deterministic; a web request may fail; a robot's grasp may slip.
- Episodic or sequential: are decisions independent, or does each affect the future? Classifying images is episodic; navigating, negotiating and multi-step tasks are sequential.
- Static or dynamic: does the environment change while the agent deliberates? A crossword is static; traffic and markets are dynamic.
- Discrete or continuous: are states, time and actions countable? Board games are discrete; driving is continuous.
- Single-agent or multi-agent: are there other agents whose actions matter, cooperative or competitive?
- Known or unknown: does the agent know the rules of how the environment works, or must it learn them?
The hardest environments are partially observable, stochastic, sequential, dynamic, continuous, multi-agent and unknown, which describes the real world and many open-ended software tasks.
| Task | Observable | Deterministic | Sequential | Agents |
|---|---|---|---|---|
| Chess with a clock | Fully | Yes | Yes | Multi (competitive) |
| Medical diagnosis assistant | Partially | No | Yes | Single (with humans) |
| Image classification | Fully | Yes | No (episodic) | Single |
| Coding agent in a repository | Partially | Mostly | Yes | Single or multi |
| Autonomous driving | Partially | No | Yes | Multi |
| Online advertising auction | Partially | No | Yes | Multi (competitive) |
Agent designs
Agent programs range from simple to sophisticated:
- Simple reflex agents choose actions from the current percept using condition–action rules: if dirty, clean; if obstacle, turn. They work only when the right action can be determined from the current percept alone.
- Model-based reflex agents maintain an internal state, a model of the parts of the world they cannot currently see, updated from percepts and knowledge of how actions change the world.
- Goal-based agents consider the future, choosing actions that lead to states satisfying a goal, using search and planning (Lessons 2 and 3).
- Utility-based agents rank outcomes by a utility function, trading off goals, risks and costs, and handle uncertainty with expected utility (Lesson 4).
- Learning agents improve their performance from experience, adjusting their models, policies or utility estimates (Lesson 5).
Modern language model agents combine these ideas: they keep state in a conversation and memory, pursue goals set in natural language, weigh options implicitly or explicitly, and can be improved through training and feedback.
Reflex versus model-based behaviour
The value of internal state is easy to demonstrate. In the following simulation, two agents clean a corridor of ten squares, each initially dirty with probability one half. The reflex agent sees only its current square: it cleans if dirty and otherwise moves randomly. The model-based agent remembers which squares it has visited and the shape of the corridor, so it sweeps systematically and stops when its model says everything is clean.
import numpy as np
# Reflex versus model-based agents cleaning a 1 x 10 corridor
rng = np.random.default_rng(1)
def run(agent, steps=60, trials=500):
cleaned, moves = [], []
for _ in range(trials):
dirt = rng.random(10) < 0.5
pos, visited, mv = 0, np.zeros(10, bool), 0
direction = 1
for t in range(steps):
visited[pos] = True
if dirt[pos]:
dirt[pos] = False
continue
if agent == "reflex":
step = rng.choice([-1, 1]) # no memory: wander randomly
else:
if visited.all():
break # model says everything is clean
if pos + direction < 0 or pos + direction > 9:
direction = -direction # remembers the corridor layout
step = direction
pos = int(np.clip(pos + step, 0, 9)); mv += 1
cleaned.append(1 - dirt.mean()); moves.append(mv)
return np.mean(cleaned), np.mean(moves)
print("agent share_clean moves_used")
for a in ("reflex", "model-based"):
c, m = run(a)
print(f"{a:12s} {c:11.2f} {m:10.1f}")agent share_clean moves_used reflex 0.90 56.0 model-based 1.00 9.0
The reflex agent cleans about 90 % of the dirt but uses all 56 of its available moves wandering back and forth, and still misses some squares. The model-based agent cleans everything in 9 moves and then stops, because it knows the task is complete. Memory and a model of the environment turn an aimless policy into an efficient one. The same principle applies to software agents: an agent that keeps track of which files it has inspected, which tests have run and what remains to do wastes far fewer steps than one that reacts only to its latest observation.
Autonomy and the spectrum of agency
Agency is a matter of degree. A chatbot that answers one question at a time has little autonomy; a workflow that calls a language model at fixed points in a predefined sequence has more structure than agency; a system that decides for itself which tools to call, in what order, and when it is done, over dozens or hundreds of steps, is strongly agentic. Anthropic's guidance on building agents distinguishes workflows, where code orchestrates model calls along predefined paths, from agents, where the model dynamically directs its own process and tool use. Workflows are more predictable and easier to test; agents are more flexible for open-ended tasks. Good practice is to use the simplest design that solves the problem and add autonomy only where it clearly helps, because each additional degree of freedom adds cost, latency and new ways to fail.
Why agents now?
Language models made general-purpose agents practical because they can interpret instructions in natural language, reason about many kinds of tasks, use tools described in text, read the results and adapt. Benchmarks such as SWE-bench for software engineering, WebArena and OSWorld for web and computer use, and GAIA for general assistant tasks track rapid progress. Yet agents remain unreliable over long horizons, can take harmful or costly actions, and are hard to evaluate. This course aims to give you both the classical tools to reason about agent behaviour and the practical techniques to build, evaluate and control modern agents responsibly.
Worked problem
Writing a PEAS description
Write a PEAS description for an agent that triages incoming IT support tickets, resolving simple ones and routing others.
Show solution
- Performance: share of tickets resolved correctly without escalation, time to resolution, routing accuracy, user satisfaction, and zero unauthorized changes.
- Environment: the ticketing system, knowledge base, user directory, device management tools and users who may reply.
- Actuators: posting replies, running approved scripts (password resets, software installs), assigning tickets to queues, asking clarifying questions.
- Sensors: ticket text and attachments, user and device records, script outputs, knowledge base search results.
- Environment properties: partially observable, stochastic, sequential, multi-agent (users and staff), mostly known.
Answer: A PEAS description clarifies measurable goals, the tools the agent may use and what it can observe.
Agents and their principals
An agent usually acts for someone: a user, a team or an organization, called its principal. The principal's goals, preferences and constraints define what good behaviour means, but they are never fully specified. A user who asks an agent to "clean up the test failures" probably wants the underlying bugs fixed, not the tests deleted; a manager who asks for "the cheapest flight" probably does not want a 30-hour itinerary with three overnight layovers. Good agents infer reasonable intent, respect implicit constraints, and ask when the intent is genuinely unclear and the stakes are significant. This gap between what is said and what is meant, sometimes called the principal–agent problem in economics, runs through the whole course, from reward design in reinforcement learning to approval rules for consequential actions.
A brief history
The agent perspective has deep roots. Early AI systems such as Shakey the robot (1966 to 1972) combined perception, planning and action in one loop. The 1980s and 1990s brought expert systems, distributed AI and multi-agent systems research, including the belief–desire–intention (BDI) architectures that model agents as having beliefs about the world, desires they want to achieve and intentions they commit to. Russell and Norvig's textbook made the rational agent the unifying idea of AI in 1995. Reinforcement learning, game-playing systems and robotics developed agent methods through the 2000s and 2010s, and since 2022 language model agents have brought general-purpose agency to software tasks. Each wave added tools that remain useful: the vocabulary of agents and environments, explicit planning, learning from reward, and coordination among many agents.
Throughout the course, each lesson pairs a concept with a short program you can run and modify. Changing the parameters, such as the number of steps, the probabilities or the costs, and predicting the result before running it is one of the best ways to build intuition for how agents behave and why they fail.
In the lessons that follow, keep the agent–environment loop in mind. Every technique, from search and planning to reinforcement learning, tool use, memory and multi-agent coordination, is a way of improving one part of that loop: what the agent perceives, how it represents the world, how it decides, or how its actions are controlled. Asking which part a technique improves is a quick way to understand what problem it solves and where its limits lie.
Common mistakes
MistakeBuilding an agent before defining success.
InsteadWrite the performance measure and PEAS first.
MistakeUsing a fully autonomous agent for a fixed process.
InsteadPrefer a simple workflow when the path is predictable.
MistakeAssuming the environment is fully observable.
InsteadDesign for partial information and uncertainty.
MistakeIgnoring internal state.
InsteadTrack progress and what remains to avoid wasted steps.
MistakeEquating rationality with success.
InsteadRational agents can fail with missing information.
Summary and key terms
- Agents perceive environments through sensors and act through actuators.
- Rational agents maximize expected performance given their percepts.
- PEAS specifies performance, environment, actuators and sensors.
- Environments vary in observability, determinism, dynamics and number of agents.
- Designs range from reflex to model-based, goal-based, utility-based and learning agents.
- Internal state makes agents far more efficient.
- Use workflows for predictable tasks and agents for open-ended ones.
- Agent
- A system that perceives and acts in an environment.
- Percept
- An agent's input at a moment.
- Actuator
- The means by which an agent acts.
- Performance measure
- Criterion for judging agent behaviour.
- Rational agent
- Agent maximizing expected performance.
- PEAS
- Performance, environment, actuators, sensors.
- Partially observable
- Environment the agent cannot fully see.
- Model-based agent
- Agent maintaining internal state about the world.
- Utility function
- Function ranking outcomes by desirability.
- Workflow
- Predefined orchestration of model calls.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Define an agent.
Show answer
Something that perceives its environment and acts on it.
Is a rational agent always successful?
Show answer
No; it maximizes expected performance given its information.
What does PEAS stand for?
Show answer
Performance, environment, actuators, sensors.
Is poker fully observable?
Show answer
No; opponents' cards are hidden.
Give an episodic task.
Show answer
Classifying individual images.
What does a model-based agent add to a reflex agent?
Show answer
Internal state about unseen parts of the world.
In C1, how many moves did the model-based agent use?
Show answer
9.
Why did the reflex agent miss dirt?
Show answer
It wandered randomly without memory.
Distinguish workflows and agents.
Show answer
Workflows follow predefined paths; agents direct their own process.
Name two agent benchmarks.
Show answer
SWE-bench, WebArena, OSWorld, GAIA.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.