E ExamMaster

Artificial Intelligence · AI Foundations

Agents and Environments

In AI because every system — thermostat to tool-calling model — is an agent coupled to an environment, and the coupling decides the machinery.

Every AI system, from a thermostat to a tool-calling language model, is one design pattern: an agent coupled to an environment through percepts and actions. This lesson makes the pattern precise — the boundary, the PEAS specification, the properties of environments that dictate how much machinery an agent needs, the ladder of agent architectures, and the modern tool-using loop that production systems actually run.

  • Artificial Intelligence
  • Medium level
  • 6 concepts

1Agents and environments

An agent is anything that can be viewed as perceiving its environment through sensors and acting on it through actuators. The definition is deliberately structural: a thermostat qualifies, a chess program qualifies, a person qualifies — what varies is the sophistication of the mapping from percept history to action, not the shape of the coupling.

The boundary between agent and environment is drawn by control, not by physics or by code: the agent is exactly what chooses, and the environment is everything whose response the agent does not choose. A chess program's clock is environment — the program does not decide how time passes — and so is the opponent, and so is the user.

What crosses the boundary gets precise names. A percept is what the environment presents in one instant; the percept sequence is the complete history; an action is what the agent emits; a reward, when the framing includes one, is the environment's running score. The agent function — from percept sequence to action — is the mathematical object; the agent program is its implementation on finite hardware.

Rewards are optional, which is why supervised learning fits the framing: in this course's labs the percept is a table row, the action is a predicted label, and the graded answer plays the score's role only when we choose to keep it.

Drawing the boundary is the first modelling act, and drawing it wrong is a real failure mode: put the user inside your agent and you will 'optimise' behaviour you do not control; forget that a downstream system obeys your model's outputs and you have missed an actuator — which means missing where the damage happens.

Figure. The loop runs clockwise from the agent: it chooses an action, the action changes the environment, the environment emits the next percept (and sometimes a reward), and the percept updates the agent's next decision. In these labs the percept is a table row and the action is a prediction.

Where does the boundary between agent and environment actually fall?
  1. The agent is the software and the environment is the hardware it runs on
  2. The agent is what chooses; the environment is everything whose response the agent does not choose
  3. The agent holds the features and the environment holds the labels
  4. There is no agent unless the environment returns a reward at every step

The split is about control, not about code or hardware. Rewards are optional in this framing, which is why supervised labs fit it perfectly well.

2Perceive, decide, act

The agent definition compresses into three verbs every system must implement somehow: perceive, decide, act. The triple is a checklist for reading any AI system, not an architecture — nothing says the three parts are separate modules, and in a fitted end-to-end model they are not.

A thermostat closes the loop with a sensor, a threshold comparison and a relay. A spam filter closes it with an email's text, a fitted classifier and a folder move. A self-driving stack closes it with cameras and lidar, a planner over a world model, and steering and braking commands. The same three verbs, separated by many orders of magnitude of machinery.

In this course's browser labs the loop is at its barest: the percept is one table row, the decision is the model's computation, and the action is the emitted label. Later, in the tool-using agent pattern, the identical loop runs with a language model deciding and API calls acting.

The checklist earns its keep during debugging, because failures live in different verbs and demand different fixes: a system that never receives the signal has a perception problem no amount of decision improvement will touch; a correct decision executed against a world that has since moved is an action-timing problem; and only the middle verb is ever fixed by a better model.

The picture is the Agents and environments figure read as verbs: percept arriving on the left is perceive, the agent node is decide, the action leaving on the right is act, and the environment closes the circle.

Reading a system through the loop

  1. PerceiveName what evidence actually reaches the system, at what rate and delay: a sensor reading, an email's text, one row of a table.
  2. DecideName what turns evidence into a choice: a threshold, a search, a fitted model. This is the only verb model training improves.
  3. ActName what re-enters the world and who consumes it: a folder move, a brake command, a label a downstream system trusts.
The loop in three systems
Loop verbThermostatSpam filterSelf-driving stack
PerceiveRoom temperatureMessage text and headersCameras, lidar, GPS
DecideThreshold comparisonFitted classifierPlanner over a world model
ActRelay to the furnaceMove to a folderSteer, brake, signal
In the perceive-decide-act framing, which part of the loop does a model's predicted label occupy?
  1. The perceive step, because a label is a piece of data like any other
  2. The environment, because the label decides which row arrives next
  3. The act step, because the prediction is what the system puts back into the world
  4. None of them, because a prediction sits outside the loop entirely

Observation comes in, a decision is made, and the label is what goes out. In a tabular lab the row is the observation and the prediction is the action.

3PEAS: specifying the task environment

Before building an agent you specify its task environment, and the standard checklist is PEAS: Performance measure, Environment, Actuators, Sensors. The acronym is mundane; the discipline is not — most disagreements about whether a system 'works' turn out to be two people holding different unwritten PEAS specifications.

The performance measure comes first deliberately: it is the success criterion stated as a condition on the world — passengers delivered safely and legally, fraud losses plus review costs minimised — and every downstream choice is judged against it. A measure written about the agent's outputs instead of the world's state re-creates the specification failures of the rationality lesson.

Environment is the space the agent operates in, including everything it cannot control: roads, weather and other drivers; a mail stream that includes adversaries writing new spam against the filter. Actuators are everything the agent can move — and in software, an emitted label that a downstream system obeys is an actuator with real force, whether or not anyone listed it. Sensors bound what the agent can ever know: a limitation here is permanent, because no decision layer recovers information the percepts never carried.

Writing the four slots down before coding exposes the classic mismatches while they are still cheap: a measure that scores beliefs instead of outcomes, an actuator with side effects nobody listed, a sensor gap the model is silently expected to guess across.

There is no picture to draw: PEAS is four labelled slots, and the table beside this concept is the figure — two systems specified side by side, slot by slot.

Two worked PEAS specifications
SlotAutomated taxiSpam filter
PerformanceSafe, legal, comfortable trips; time and fuelSpam caught with legitimate mail untouched, the second weighted heavier
EnvironmentRoads, traffic, pedestrians, weatherA mail stream, including adversaries adapting to the filter
ActuatorsSteering, throttle, brake, signals, displayFolder move, quarantine, user-facing flag
SensorsCameras, lidar, GPS, speedometerMessage text, headers, sender history
What do the letters in the PEAS environment specification stand for?
  1. Percepts, Entities, Actions, States
  2. Performance criterion, Environment space, Actuation mechanisms, and Sensory inputs
  3. Planning, Execution, Adaptation, Search
  4. Probability, Expectation, Accuracy, Sensitivity

PEAS stands for Performance measure, Environment, Actuators, and Sensors, used to specify agent problem settings.

4Six axes of an environment

Environments differ along a small set of axes, and each axis answers one engineering question: how much machinery does the agent need? The six classical dimensions are fully versus partially observable, deterministic versus stochastic, episodic versus sequential, static versus dynamic, discrete versus continuous, and single- versus multi-agent.

Partial observability forces memory. If the current percept does not reveal the state — poker, driving in fog — the agent must maintain an internal estimate of what it cannot see, and everything downstream consumes that estimate, errors included. Full observability, as in chess with the whole board visible, is precisely what lets an agent stay memoryless.

Stochasticity forces expectation: when the same action from the same state can land differently, plans become gambles and rationality means maximising expected outcome rather than guaranteed outcome. Sequentiality forces lookahead: when today's action changes tomorrow's choices, greedy decisions compound error, and this is the pressure that makes search and planning necessary.

Dynamic environments punish slow deciders — the world moves while you deliberate, so thinking time is itself a cost. Continuous state spaces break table-based methods outright and force function approximation. Other agents make the environment adversarial or cooperative: the spam writer adapts to the filter, which is why spam filtering never stays solved.

The axes locate every lesson ahead of you: the search lessons assume observable, deterministic, static worlds — the easiest cell — and each relaxation of those assumptions is what the later machinery, probability and learning included, exists to pay for.

Imagine each axis as a slider with an easy end and a hard end. Every real task sets six sliders, and the machinery an agent needs is roughly how far right they sit — chess sets nearly all of them easy, driving sets nearly all of them hard.

Six axes, and what the hard side costs
AxisEasy sideHard sideThe hard side demands
ObservabilityChess: the board is visiblePoker, fogState estimation, memory
DeterminismPuzzle movesTraffic, diceExpected-value reasoning
Episodic?One email at a timeDrivingLookahead, planning
Static?CrosswordRoads, marketsDeciding under time pressure
Discrete?Board squaresSteering anglesFunction approximation
Single-agent?SolitaireSpam vs spammersAdversarial reasoning
An environment where the agent sensors give access to the complete state of the world at each point in time is termed:
  1. Partially observable
  2. Fully observable
  3. Non-deterministic
  4. Continuous

In a fully observable environment, the agent sensors detect all aspects relevant to choice of action at any moment.

5The ladder of agent architectures

Agent programs form a ladder, each rung adding one capability the previous rung lacked — and the right rung is the cheapest one your environment's axes permit, not the highest one you can build.

A simple reflex agent maps the current percept straight to an action: if temperature is below the set-point, heat. It is correct exactly when the current percept contains everything that matters — full observability — and it thrashes or loops when it does not, because it cannot remember what it can no longer see.

A model-based reflex agent adds internal state: a running estimate of the unobserved parts of the world, updated from the percept stream using a model of how the world evolves. This is the minimum machinery partial observability permits, and the estimate's errors become everyone else's inputs.

A goal-based agent adds explicit goals and chooses actions by asking what leads to them — this is where search and planning enter the story. A utility-based agent refines goals into a utility function, so it can trade off conflicting objectives and act under uncertainty by maximising expected utility: a goal only says win; a utility says how much each outcome is worth.

A learning agent adds a critic and an improvement loop, so performance rises with experience. Any of the previous rungs can be wrapped this way — which is exactly the relationship between classical AI and machine learning, drawn as an architecture rather than argued as a slogan.

Figure. Each rung exists because an environment axis forced it: hidden state forces a world model, consequential futures force goals, conflicting objectives force utility, and a drifting world forces learning. Choose the cheapest rung your environment permits — machinery above what the axes demand is surface area for bugs.

The rungs
RungAddsFails when
Simple reflexPercept-to-action rulesThe percept does not reveal the state
Model-basedInternal state, world modelThe future depends on choices, not just state
Goal-basedGoals; search and planningObjectives conflict or outcomes are uncertain
Utility-basedPreferences over outcomesThe world drifts and the design goes stale
LearningA critic and an improvement loopThe measure it improves against is mis-specified

6Tool-using agents: the production loop

The production agent pattern of the current era wraps a language model in the perceive-decide-act loop: the model receives a goal and a transcript as its percepts, decides between answering and calling a tool — a search query, a code runner, a database read — and each tool's result re-enters the transcript as the next percept. The loop runs until a stop condition, and the transcript is the agent's working state.

Nothing in the framing is new. This is a model-based agent whose internal state is a text buffer and whose actuators are APIs — and that is precisely why the classical vocabulary earns its keep here: every question you can ask of a thermostat has a sharper, higher-stakes version for this loop.

The engineering risks are loop-shaped, not model-shaped. An agent with no stop condition burns budget circling; one whose tool results are fed back unvalidated will act on a tool's error as if it were ground truth; one whose actuators have irreversible side effects — sending, deleting, paying — needs deterministic guardrails between decision and execution, which is the next lesson's subject.

Capability of the wrapped model and reliability of the loop are separate properties, and they are measured separately: the same model inside a better harness — tighter tool contracts, validated observations, explicit stop conditions — is a different and usually better agent. Agent evaluation is therefore end-to-end: task completion, cost and incident rate, not the model's benchmark scores.

When you meet an agent framework, reduce it to this diagram: what are the percepts, which decisions belong to the model and which to the harness code around it, what can each tool actually do, and what stops the loop. Frameworks differ mostly in how honestly they answer.

Figure. The tool loop is the agent loop with a text buffer for state: the model reads the transcript and either answers (stop condition met) or emits a tool call; an external system executes it; the result returns as an observation appended to the transcript, which the model reads again. Guardrails belong on the tool-call edge — the one with side effects.

Auditing an agent loop

  1. PerceptsWhat enters the transcript — and is any of it unvalidated tool output being treated as ground truth?
  2. DecisionsWhich choices belong to the model, and which to the harness code around it? The split is the design.
  3. ActuatorsWhich tool calls have side effects, and what sits between the model's decision and their execution?
  4. StopWhat ends the loop — and what bounds cost and damage if nothing does?

Notes

  • The agent is exactly what chooses; the environment is everything whose response it does not choose.
  • PEAS — performance measure, environment, actuators, sensors — is the specification every agent needs before code.
  • Environment axes (observable, deterministic, episodic, static, discrete, single-agent) decide how much machinery an agent needs.

Exam traps & shortcuts

  • Draw the agent-environment boundary by control, not by code: if the agent does not choose it, it is environment — including the clock and the user.
  • A sensor gap is permanent: no decision layer, however well trained, recovers information the percepts never carried.
  • For tool-using agents, audit the harness before the model: stop conditions, validated observations and guarded side-effect calls change behaviour more than a model swap.

Recap

This lesson in brief:

The boundary
The agent is exactly what chooses; the environment is everything whose response it does not choose — control draws the line, not code.
PEAS
Performance measure, environment, actuators, sensors — written down before code, with the measure stated as a condition on the world.
Six axes
Observability, determinism, episodicity, dynamics, continuity, other agents: each hard side forces specific machinery, and the axes together choose the architecture rung.
The ladder
Reflex, model-based, goal-based, utility-based, learning — take the cheapest rung the environment permits.
Tool loops
A tool-using agent is a model-based agent with a transcript for state and APIs for actuators; its reliability lives in the harness — stop conditions, validated observations, guarded side effects.

Practise Agents and Environments

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • 4 quick checks with worked explanations
  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.