Agentic AI · L-MDP
A formal lens on agent decision-making: states, actions, observations and rewards — the language in which agent benchmarks, evaluations and safety arguments are written.
This is the MDP framing for agents — the vocabulary, not the solution methods. Solving an MDP (returns and discounting, the Bellman equations, optimal policies, exploration–exploitation, options) belongs to a reinforcement-learning course and is out-of-scope.
DECOMPOSE, RANK, SUMMARIZE.A Markov decision process (MDP) is a formal model of sequential decision-making: an agent selects actions, and an environment answers each action with a next state and a reward. Part I defines the model, Part II maps an LLM agent onto it, and Part III treats a reward that does not express the intended objective:
| Part | The question it answers | Sections |
|---|---|---|
| I · Markov Decision Processes | Which components define an MDP, and what are a policy and the value of a state? | The Agent–Environment Interface · Decision Theory: The Single-Decision Foundation · The MDP Formalism · Reward · Policy & Value |
| II · LLM Agents as MDPs | Which parts of an LLM agent are the state, the action, the policy and the environment? | An LLM Agent as an MDP · The POMDP a Benchmark Actually Uses · Three MDPs, Differing in Who Is the Environment · Deliberation Strategies as Formulations of Policy $\pi$ · Post-Training RL as Internalized Deliberation |
| III · Objective Specification | What does a capable agent do when its reward does not express the intended objective, and how can an agent act under uncertainty about that objective? | Responsible AI — Reward Mis-Specification · Goal Misgeneralization: Competently Pursuing the Wrong Objective · Uncertainty about the Objective: Assistance Games |
A Markov decision process (MDP) describes sequential decision-making by a state space, an action space, a dynamics function and a discount factor: a policy selects an action in each state, and the value of a state is the expected discounted reward that follows that state.
At each discrete time step $t=0,1,2,\dots$ the agent observes a state $S_t$ from the state space $\mathcal S$, takes an action $A_t$ from the action space $\mathcal A$, and the environment answers with a scalar reward $R_{t+1}\in\mathbb R$ and a next state $S_{t+1}$:
This produces a trajectory $S_0, A_0, R_1, S_1, A_1, R_2, \dots$ — the run of the agent, written out. Its behaviour is a policy $\pi(a\mid s)$: the probability of choosing action $a$ when the state is $s$. The goal is to maximise long-run reward, not the immediate one (Sutton & Barto, 2018).
(Three alphabets, three roles — the course convention: calligraphic $\mathcal S,\mathcal A$ are the sets (state and action space), capitals $S_t, A_t, R_t$ are the random variables — which state, action and reward actually occurred at $t$ — and lowercase $s,a,r$ are the values they take, the ones we write inside a formula.)
Under uncertainty, a rational agent takes the action with the best expected outcome (→ L-Intro). The formal machinery for that is decision theory = probability theory + utility theory (Russell & Norvig, 2021, §1.1): let $\omega\in\Omega$ be an outcome the action may lead to, $P(\omega\mid a)$ the probability of that outcome given action $a$, and the utility $U(\omega)\in\mathbb R$ how much the agent values it. A decision-theoretic agent then takes the action $a^{*}$ of maximum expected utility (MEU): $$ a^{*}=\arg\max_{a}\;\mathbb E[\,U\mid a\,]=\arg\max_{a}\sum_{\omega\in\Omega}P(\omega\mid a)\,U(\omega). $$
An MDP is decision theory made sequential: instead of one action's expected utility, we maximise the expected return $G_t$ (the reward still to come after step $t$, defined below) over a whole trajectory — utility becomes reward-to-go.
A finite Markov Decision Process is $(\mathcal S, \mathcal A, p, \gamma)$:
Markov property: the future depends only on the current $(s,a)$, not the full history — it is the Markov chain of the training ladder, now with actions.
Reward hypothesis (Sutton & Barto): goals can be framed as maximising expected cumulative reward. The reward $R_{t+1} \in \mathbb{R}$ is a scalar feedback signal emitted by the environment at time $t+1$ that evaluates the quality of taking action $a_t$ in state $s_t$. The underlying reward function $r: \mathcal{S} \times \mathcal{A} \to \mathbb{R}$ deterministically or stochastically maps state-action pairs to this scalar value: $R_{t+1} = r(s_t, a_t)$.
The reward function is not a mere detail of the model—it is the formal specification of the task, and everything the agent does follows from it.
Macro vs. Micro Actions
In LLM literature, you will see two levels of abstraction for "actions":
Viewing token generation as a sequence of decisions—each with an expected outcome value $v_\pi$—helps identify which tokens truly matter. A step where different token choices cause a large swing in expected value is a choice point, where the model's decision significantly alters the final output quality.
An LLM agent is a partially observable MDP (POMDP), an MDP in which the agent receives an observation instead of the state: the policy is the language model together with its prompt, tools and loop, and the choice of the environment — the human, the external world or the language model — fixes the meaning of every symbol.
Just-in-time planning = choosing the next action from the current state — acting in the MDP without a stored plan. The weights never change: the policy is the model plus the prompt, the tools and the loop around it, so the harness computes $\pi$ at inference time — which is why changing the system-prompt or the runtime changes the policy.
Reinforcement learning is the contrasting case: it tunes the policy by changing the model against the reward — training, before deployment, and out of scope here (see the excursion).
The mapping on the previous slide is not only a teaching device — it is how agent benchmarks define their tasks. AgentBoard (Ma et al., 2024) relies on the Partially Observable Markov Decision Processes (POMDPs) fomalism. Nine text environments are specified as the tuple
$$\mathcal{M} = \langle g,\; \mathcal S,\; \mathcal A,\; \mathcal O,\; \mathcal T \rangle$$
— with goal $g$, state space $\mathcal S$, action space $\mathcal A$, observation spaces $\mathcal O$ (including environment feedback), and transition function $\mathcal T: \mathcal S \times \mathcal A \rightarrow \mathcal S$.
Here we have a deterministic $\mathcal{T}$: Given a specific current state $s_t$ and action $a_t$, the environment produces one specific next state $s_{t+1} = \mathcal{T}(s_t, a_t)$ with $100\%$ certainty.
Why the Distinction Matters for LLM Agents
In a Fully Observable MDP, the agent directly sees the true state ($o_t = s_t$). However, an LLM agent operates in a POMDP (Partially Observable MDP):
The agents predictions at step $t$ are based on the goal and the memory $m_t$. The memory is written explicitly as the interleaved history sequence of actions and observations:
$$m_t = \{o_j, a_j, o_{j+1}, a_{j+1}, \dots, o_t\},\qquad 0 \le j < t.$$
A trajectory $\tau = [s_0, a_0, s_1, a_1, \dots, s_n]$ of $n$ steps — one concrete run, hence lowercase — then has probability, with $p(s_0)$ the distribution the environment starts from,
$$p_\pi(\tau) \;=\; p(s_0)\prod_{t=0}^{n-1} \pi(a_t \mid g,\, s_t,\, m_t)\; T(s_{t+1}\mid s_t, a_t).$$
By writing $\pi(a_t \mid g, s_t, m_t)$, the authors took a standard mathematical shortcut called collapsing the observation step.
The Fully Rigorous POMDP FactorizationIn a true POMDP, the complete joint distribution over states, observations, and actions expands to (noting that in Transformer-based agents, memory $m_t$ acts as an implicit, uncompressed belief state):
$$p_\pi(\tau) = p(s_0) \prod_{t=0}^{n-1} \underbrace{p(o_t \mid s_t)}_{\text{Observation Step}} \cdot \underbrace{\pi(a_t \mid g, m_t)}_{\text{Agent Policy}} \cdot \underbrace{T(s_{t+1} \mid s_t, a_t)}_{\text{State Transition}}$$
Three things are worth reading off that product.
The mapping above places the human and the physical world on the environment side. This is a choice of agent-environment boundary, not an inherent property of the LLM. Following the conceptual framework in Yang et al. (2023), we can construct three distinct MDP factorizations for the same underlying system by shifting where the boundary is drawn:
| Mode | Environment ($\mathcal{T}$) | Policy ($\pi$) | Single Step Dynamics |
|---|---|---|---|
| Dialogue | The Human | Model + Scaffold | Agent emits utterance; Human updates mental state and replies |
| Tool Use | The External World (APIs / Web / Terminal) | Model + Scaffold | Agent executes tool call; Environment updates state and returns output |
| Iterative Prompting | The Language Model Itself | The Scaffold (Harness) Alone | Harness structures/chooses the prompt; LM updates internal context and generates text |
In the Dialogue MDP, the human interlocutor serves as the environment $\mathcal{T}$, while the combination of the language model and its scaffold acts as the agent policy $\pi$.
The Dialogue framework is defined by the tuple $\mathcal{M}_{\text{dialogue}} = \langle g, \mathcal{S}, \mathcal{A}, \mathcal{O}, \mathcal{T} \rangle$:
Crucial Insight: The Markov property is bought, not assumed. It holds for the agent's internal history representation $m_t$ because $m_t$ is defined as the complete sequence of past turns up to time $t$, serving as an uncompressed belief state proxy. This forces $m_t$ to grow monotonically, directly causing the context-window limits that dynamic memory architectures must manage.
Tools use extends the same history-concatenation mechanics to a hybrid action space (see L-ReAct):
$$ \hat{\mathcal{A}} \;=\; \mathcal{A} \cup \mathcal{L}, $$ (where $\mathcal{A}$ is the external action space (tool calls) and $\mathcal{L}$ the language space (free-form text)).
This hybrid action space introduces three fundamental decision sub-problems unique to tool environments:
Iterative prompting is a control framework that inverts the standard LLM agent boundary, modeling the interaction as a Markov Decision Process (MDP) where a program execution wrapper (the harness/scaffold) serves as the acting policy $\pi$, and the parametric Language Model (LLM) acts as the state-transition environment $\mathcal{T}$. In hybrid implementations, the policy boundary may expand beyond pure code to include auxiliary models (e.g., LLM_plan or LLM_judge) or human-in-the-loop interventions to execute specific operators.
A prompting scheme becomes a policy over high-level structural actions that map string states to string outputs:
| High-level action | Implementation Spectrum (Pure Scaffold vs. Hybrid Policy) |
|---|---|
DECOMPOSE |
Pure: Programmatic string/AST splitting. Hybrid: Auxiliary LLM_plan decomposes tasks into recursive sub-goals. |
RANK |
Pure: Algorithmic voting, exact match, or perplexity heuristics. Hybrid: Auxiliary LLM_judge or reward model evaluates/scores candidate states. |
SUMMARIZE, PRUNE |
Pure: Non-parametric FIFO context truncation or line pruning. Hybrid: Auxiliary LLM_summarizer compresses context into dense semantic summaries. |
SEARCH |
Pure: Direct API/Vector DB execution. Hybrid: Auxiliary LLM_query_rewriter optimizes queries prior to API execution. |
Two fundamental properties follow from this formulation:
SUMMARIZE/PRUNE or divide tasks via DECOMPOSE is an active control optimization performed by the policy, rather than an external exception-handling routine.Crucial Conceptual Boundary: Which structural reading you adopt dictates the precise physical meaning of every variable:
- Dialogue: Environment = Human Interlocutor; Policy = Model + Scaffold
- Tool Use: Environment = External World/APIs; Policy = Model + Scaffold
- Prompting: Environment = Language Model Itself; Policy = Scaffold (or Scaffold + Auxiliary Models)
Conflating these boundaries within a single analysis is the primary source of formal confusion in LLM literature. The Prompting MDP does not deny that an LLM generates text; rather, it asserts that when the primary object of system design is the prompting scheme, the model functions formally as the state-transition dynamics $\mathcal{T}$ being acted upon.
The entire landscape of planning and reasoning methods simplifies down to a single question: How does the policy $\pi$ select an action $a$?
In this unified view, ReAct, explicit planning, and Tree-of-Thoughts are not different agent architectures—they are three different search strategies used by the policy $\pi$ to choose an action, differing only in how much compute the harness spends before committing to $a_t$.
| Strategy | Search Space | Compute Spent per Action Step |
|---|---|---|
| ReAct | Single path | $1$ model call (greedy or nucleus sampling) |
| Explicit Plan | Directed Acyclic Graph (DAG) | $1$ planning call + $1$ execution call per step |
| Tree Search (ToT) | Branching tree | $O(b \cdot d)$ model calls (BFS/DFS over candidate states) |
The Core Agent Loop Is Invariant. All three planning approaches run inside the exact same control loop: the policy requests actions, and the harness control plane executes them against the environment. Deliberation simply shifts locations across the stack:
ReAct is not the agent loop. ReAct is simply the cheapest, single-sample policy that runs inside it.
Inference-Time Search Trades Compute for Accuracy. Expanding a search tree (ToT) buys what additional compute always buys in an MDP: a mathematically superior estimate of $Q^*(s_t, a_t)$—the action that maximizes expected cumulative return. However, inference-time search can only optimize action selection over the given reward function; it cannot fix a fundamentally mis-specified reward $\mathcal{R}$.
The same MDP formalism used to build agent harnesses also explains how reasoning models (e.g., DeepSeek-R1, OpenAI o1) are trained.
By treating each generated token or thought as an action $x_t$, the state as the preceding prompt and text history $x_{1:t-1}$, and applying standard policy gradient updates:
$$\nabla_\theta J(\pi_\theta) \;=\; \mathbb{E}_\tau\!\left[\sum_{t=1}^{T} \nabla_\theta \log \pi_\theta(x_t \mid x_{1:t-1})\; A(s_t, a_t)\right]$$
(where $A(s_t, a_t)$ is the advantage—a scalar weighting that reinforces token sequences leading to higher-than-average final rewards).
This optimization yields two critical insights for agent engineering:
The reward function is the formal specification of the task: an agent that maximises a reward which does not express the intended objective optimises the wrong objective, and an assistance game models an agent that is uncertain about the objective and infers it from the behaviour of the human.
If the reward is wrong, a capable agent will optimise the wrong thing (reward hacking / Goodhart's law). Sparse, gameable, or proxy rewards are dangerous — a core AI-safety concern, and the reason the specification of the reward matters as much as the optimisation of it.
Specify goals well — SMART. A good objective is Specific, Measurable, Achievable, Relevant, Time-bound; a vague or gameable one is a mis-specified reward (monitored in → L-Eval).
Reward mis-specification is only one of two major goal-alignment failure modes. Goal misgeneralization occurs when the task specification $r(s,a)$ is completely correct, yet the system competently pursues a proxy goal at runtime (Shah et al., 2022).
| Failure Mode | Reward Function $r(s,a)$ | Agent Capability | What Goes Wrong |
|---|---|---|---|
| Specification Gaming | Flawed / Gameable | Capable | The agent exploits a broken reward function or shortcut. |
| Capability Failure | Correct | Lacking | The agent fails simply because it lacks the skill or intelligence. |
| Goal Misgeneralization | Correct | Capable | The agent could do the right thing, but competently pursues a proxy goal instead. |
Goal misgeneralization happens because training or test environments are underdetermined: multiple distinct goals yield identical, successful behavior under normal conditions.
Even without updating model parameters $\theta$, prompt instructions, few-shot examples, and unit tests serve as the agent's "training situations."
If your prompt examples or test suites fail to decouple proxy behaviors from your true intent, the agent will pass every benchmark test during development, only to execute something confidently wrong on its first novel deployment case.
Scaffolding Rule: Build evaluation sets specifically designed to separate proxy shortcuts from true goals, rather than just testing happy paths.
Reward mis-specification assumes the agent has a fixed reward function $r$ — just the wrong one. A deeper response is to let the agent stay uncertain about the true objective and treat the human's reward as something to be inferred, not assumed.
Formally this is an assistance game (Russell & Norvig, 2021, §17.2.5): a two-player game between a human and a robot in which both maximise the human's payoff parameter $\theta$, but only the human observes $\theta$; the robot holds a prior $P(\theta)$ and updates it from what the human does. Solving it reduces to a POMDP whose hidden state includes the preference parameters $\theta$ — i.e. objective uncertainty is just more partial observability, on top of the POMDP view of an LLM agent above.
Two consequences matter for safe agents:
The standard-model limit. This is the flip side of the rational agent whose objective we supply: when the objective is hard to specify completely — the norm for real tasks — the safer design is an agent uncertain about the reward, not one confidently maximising a proxy. The human oversight enforced at the gateway (→ L-Gateway) is the operational face of this same idea.
excursions/solving-mdps/.DECOMPOSE / SUMMARIZE as its actions. In
dialogue the state is the whole history, so the Markov property is bought by definition — and
so is the unbounded growth memory management has to absorb.Peer-reviewed papers
Preprints & other non-peer-reviewed papers
DECOMPOSE / RANK / SUMMARIZE / PRUNE as high-level actions; §4.2 why a task specified in language beats a scalar reward.Textbooks & monographs
excursions/solving-mdps/.