Skip to content
learn
  1. Learn
  2. Artificial Intelligence
  3. Intelligent Agents and Problem Solving by Search

AI AI-01.01

Agents and environments

Agents that perceive and act, PEAS descriptions, the properties that make environments easy or hard, and reflex, goal-based and utility-based agents.

Beginner 10 min Last reviewed

The big idea

A robot vacuum, a chess program, a self-driving car and an AI assistant that books flights look nothing alike, but they share one shape. Each one takes in information about its world, decides, and does something that changes the world. That shape is called an agentAnything that perceives its environment through sensors and acts on it through actuators, choosing actions to achieve its goals., and it is the most useful single idea in AI, because it turns "make it intelligent" into a concrete question: given what it has perceived so far, which action should it take next?

Describing any AI system as an agent forces you to say what it can sense, what it can do, what world it lives in and how success is measured. Those four answers usually tell you which techniques will work, before you write a line of code.

Picture a thermostat, then a person running a household budget. Both perceive (temperature; bills) and act (heat on; spend or save). The difference is in how they choose, and that difference is what this lesson classifies.

How it works

Step 1: The agent loop

The agent loop: percepts in, actions out An environment on the right sends percepts through sensors into the agent program on the left, which chooses an action and sends it through actuators back to the environment. The loop repeats continuously. Agent percepts actions Sensors camera, text, API data Agent program decides the action Actuators wheels, messages, tool calls Environment the world it acts in Figure 1. The agent loop. Sensors turn the world into percepts, the agent program picks an action, actuators carry it out, and the changed world produces new percepts.
  • A perceptWhat an agent senses at one moment, such as a camera frame, a reading or a message. is what the agent senses at one instant; the percept sequence is everything it has sensed so far.
  • An action is something the agent can do that affects the environment.
  • The agent program maps percepts to actions. Designing it is the job of AI.

Step 2: Describe the task with PEAS

Before choosing an algorithm, write a PEASPerformance measure, Environment, Actuators, Sensors: a four-part description of an agent's task. description:

Robot vacuumAutomated taxiFlight booking assistant
Performancefloor cleaned, battery used, nothing brokensafe, legal, fast, comfortable, profitableright flight, low price, few user turns
Environmentrooms, furniture, petsroads, traffic, pedestrians, weatherairline APIs, user, calendar
Actuatorswheels, brushes, suctionsteering, throttle, brakes, signalssearch and booking calls, messages
Sensorsbump sensors, dirt sensor, lidarcameras, radar, GPS, speedometerAPI responses, user messages

The performance measure matters most. It defines what "good behavior" means, and a badly chosen measure produces an agent that games it: a vacuum rewarded for "dirt collected" might learn to dump dirt and collect it again.

Step 3: What makes an environment hard

Environments differ along a few dimensions, and each one changes what kind of agent you need:

  • Fully or partially observable: can the agent see everything relevant? Chess is fully observable; poker and driving are not.
  • Deterministic or stochastic: does an action always have the same result? A puzzle move does; a dice roll or a skid does not.
  • Episodic or sequential: is each decision independent (classifying one photo) or does it affect the future (every chess move)?
  • Static or dynamic: does the world change while the agent thinks? A crossword waits; traffic does not.
  • Discrete or continuous: a fixed set of states and moves (a board game) versus smooth quantities (steering angle, speed).
  • Single or multi-agent: are there other agents, cooperating or competing?

The hardest real environments, such as driving, are partially observable, stochastic, sequential, dynamic, continuous and multi-agent all at once.

Step 4: Four kinds of agent program

From simplest to most capable:

  1. Simple reflex agents act on the current percept with if-then rules: "if dirty, suck". Fast and simple, but helpless when the right action depends on what it cannot currently see.
  2. Model-based reflex agents keep an internal state, a model of the parts of the world they cannot see right now, such as "I already cleaned the kitchen".
  3. Goal-based agents consider what their actions will lead to and choose ones that reach a goal, which requires search and planning. Most of this module is about how they search.
  4. Utility-based agents go further: when several outcomes reach the goal, or goals conflict, they choose the action with the highest expected utilityA number scoring how desirable an outcome is, letting an agent trade off goals such as speed against safety., trading off speed, cost, safety and risk.

Any of these can also be a learning agent that improves its program from experience. And an LLM agent that calls tools in a loop is the same structure: messages and tool results are percepts, tool calls are actions. See Function calling and tool use .

Try it

Which kind of agent program is each system closest to?

Show answers
  • An automatic door that opens when its sensor detects motion: Simple reflex. One rule on the current percept, no memory or planning.
  • A route planner that finds any path from A to B: Goal-based. It searches for action sequences that reach the goal.
  • A navigation app choosing the route that balances time, tolls and fuel: Utility-based. Many routes reach the goal; it scores them and picks the best trade-off.
  • A spam filter that blocks emails containing certain words: Simple reflex. It reacts to the current email with fixed rules.
  • A puzzle solver finding a sequence of moves to the solved state: Goal-based. It plans a path through states to a goal test.
  • A self-driving car deciding how hard to brake given risk and comfort: Utility-based. It weighs safety, comfort and progress under uncertainty.

Going deeper

Rationality is not omniscience

A rational agentAn agent that chooses the action expected to maximize its performance measure, given what it has perceived and knows. picks the action that maximizes its expected performance given what it knows. It can still have a bad outcome: a driver who checks both ways and is hit by a car that ran a red light acted rationally. Judging agents by expected performance rather than outcomes is what makes reasoning under uncertainty, covered in Probability for AI (recap) , possible.

Specify the objective carefully

Because agents optimize what you measure, a sloppy performance measure is dangerous. A recommendation system optimizing watch time may promote outrage; a game agent may find a scoring bug instead of winning. This problem of specifying what we really want returns, at much larger scale, in Alignment and interpretability, the big picture .

Trade-offs

OptionWins whenLoses when
Simple reflex agent Fully observable, fast-reacting tasks with clear rules: thermostats, simple filters Anything needing memory, planning or trade-offs
Goal-based agent Problems with a clear goal and known actions: routing, puzzles, scheduling Situations where many outcomes satisfy the goal and some are much better
Utility-based agent Trade-offs and uncertainty: driving, trading, recommendations Cases where a good utility function is hard to write or to compute

Common mistakes

  • Starting with the algorithm before writing a PEAS description. The environment's properties decide which algorithm can work.
  • Writing a performance measure that can be gamed. The agent will find the loophole.
  • Assuming the environment is fully observable when it is not. A reflex agent that cannot see the whole situation makes confident, wrong moves.
  • Forgetting other agents. Traffic, markets and games change because others react to you.

Check yourself

  1. In the agent loop, what does an actuator do?

    Show answer

    B. Carries out the chosen action in the environment Sensors bring percepts in; actuators carry actions out.

  2. Which environment is partially observable?

    Show answer

    C. Poker In poker you cannot see the other players' cards.

  3. A navigation app picks between three routes that all arrive, weighing time, tolls and fuel. What kind of agent is this?

    Show answer

    D. Utility-based Several outcomes reach the goal; scoring their desirability is what a utility-based agent does.

  4. Why does the performance measure matter so much?

    Show answer

    B. Agents optimize what is measured, so a flawed measure leads to unwanted behavior An agent will maximize exactly what you measure, loopholes included.

Recap

  • An agent perceives through sensors and acts through actuators, in a loop.
  • PEAS (performance, environment, actuators, sensors) describes any agent's task.
  • Environments vary: observable or not, deterministic or not, episodic or sequential, static or dynamic, discrete or continuous, single or multi-agent.
  • Agent programs range from simple reflex to model-based, goal-based and utility-based.
  • Agents optimize their performance measure, so define it carefully.

Get new lessons by email

Get new posts on backend and AI internals. No spam, unsubscribe anytime.

Your email is only used to send new posts. Privacy