Skip to content
BIASED

What an agent is

The percept–action loop, agent function versus program, rationality, environment properties and kinds of agent program.

From NLP to agents

The NLP course ended with a loop around a language model: emit a tool call, run it, put the result back in context, decide again. That loop is one instance of a much older idea. An agent perceives an environment and acts on it, over and over, so that the environment ends up in states someone wants.

A classifier or a one-shot chat answer is a function: one input, one output, done. Quality can be judged on that output alone. As soon as the system acts, the output changes the world and the next input depends on it. Moving away from a dirty square can be a mistake or a good idea depending on the rest of the room. This course builds agents from classical search through reinforcement learning to language-model agents that write code and operate computers.

The agent–environment loop

An agent perceives through sensors and acts through actuators. At step tt the environment is in state sts_t; the agent receives a percept oto_t (often only part of sts_t) and emits an action ata_t. The environment then moves, possibly at random: st+1∼P(⋅∣st,at)s_{t+1} \sim P(\cdot \mid s_t, a_t).

Two objects describe behaviour. The agent function f:O∗→Af: \mathcal O^{*} \to \mathcal A maps every percept sequence to an action. The agent program is the code that implements ff with limited memory and time. A lookup table over sequences is hopeless: with ∣O∣=4|\mathcal O|=4 and lifetime T=10T=10 it needs ∑t=1104t=1,398,100\sum_{t=1}^{10} 4^t = 1{,}398{,}100 rows. The design problem of the course is to find small programs that produce good agent functions.

Performance and rationality

A performance measure U(s0,…,sT)U(s_0,\dots,s_T) scores the sequence of environment states, not the agent’s opinion of itself. An agent is rational if for every percept sequence it chooses the action that maximizes E[U]\mathbb E[U] given those percepts and its prior knowledge. Rational is not omniscient; rationality is relative to the measure; and a rational agent gathers information when looking is cheaper than acting blindly.

In the two-square vacuum world, a reflex “if dirty suck, else move” is nearly best when moves are free, but with move cost 0.50.5 a waiting agent that checks the other square every KK steps does better (about 1.761.76 vs 1.491.49 points per step at dirt probability p=0.05p=0.05). The counter carries information: after kk steps the unseen square is dirty with probability 1−(1−p)k+11-(1-p)^{k+1}.

Task-environment properties

Classify the task environment before choosing a design:

Axis Easy end Hard end
Observability fully partially
Uncertainty deterministic stochastic
Horizon episodic sequential
Time static dynamic
Values discrete continuous
Agents single multi-agent
Knowledge known rules unknown (must learn)

Search assumes fully observable, deterministic, known worlds; MDPs add stochastic outcomes; games add an opponent; RL removes the known model.

Five kinds of agent program

Programs grow by what they compute before acting:

  1. Simple reflex — action from the current percept alone.
  2. Model-based reflex — internal state updated with transition and sensor models.
  3. Goal-based — search for action sequences that reach desirable states.
  4. Utility-based — maximize expected utility under uncertainty.
  5. Learning — improve any of the above from experience (critic, learning element, explorer).

LM agents and the course plan

A language-model agent fits the same frame: percepts enter the context, actions are text parsed by a runtime, the model is πθ(⋅∣ct)\pi_\theta(\cdot \mid c_t), and memory is the context window plus external notes. Practitioners often contrast fixed workflows (code decides the next step) with agents (the model decides); both are agents in this course’s sense.

Next: when the world is fully observable, deterministic and known, a goal-based agent can find a sequence of actions before acting — by search.

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Full notes

Answers are saved on the server and tied to this browser until you sign in.