The Options Framework
The Options Framework extends reinforcement learning beyond single-step primitive actions by formalizing temporally extended subroutines with initiation sets, internal policies, and termination conditions.
Why Does This Exist?
In standard reinforcement learning, the agent operates in lockstep with a discrete clock: at every single timestep , the agent receives state , selects a single primitive action , receives reward , and transitions to . For complex, long-horizon tasks—such as an autonomous robot navigating across an entire office building or solving an intricate manipulation puzzle—this flat, step-by-step representation introduces severe bottlenecks:
- Exponential Exploration Complexity: If an agent must take 10,000 primitive joint motor commands to reach a distant room, undirected random exploration (like -greedy) requires exponential time to stumble upon the goal. The probability of randomly generating a coherent sequence of thousands of low-level motor torques is virtually zero.
- Diluted Credit Assignment: When a delayed reward is finally discovered after thousands of steps, Temporal Difference Learning must backpropagate that reward signal backwards across thousands of individual transitions, requiring millions of training iterations for values to propagate to initial states.
- Inability to Reuse Behavioral Modules: Biological intelligence does not plan at the millisecond motor-twitch level. When deciding to grab a cup of coffee, humans invoke macro-behaviors: "stand up", "walk down the hall", "open door", and "grasp cup". Flat RL forces the agent to relearn basic locomotion primitives from scratch for every new task.
The Options Framework, formalized in the seminal work of Richard Sutton, Doina Precup, and Satinder Singh (1999), resolves this by bringing temporal abstraction to reinforcement learning. Instead of restricting actions to single-step primitives, the framework formalizes macro-actions—termed options—that execute over variable temporal durations. By embedding options into the mathematics of Semi-Markov Decision Processes (SMDPs), the framework allows agents to plan, learn, and act seamlessly across multiple time scales without abandoning the rigorous convergence guarantees of dynamic programming.
Think of It Like This
Reusable Subroutines in Software Engineering
Imagine writing a complex software application in raw x86 assembly language where your only available operations are single-clock-cycle CPU instructions: bit-shifts, register increments, and jumps.
If you had to write every sorting algorithm, network socket connection, and file reading loop by copy-pasting hundreds of lines of assembly instructions directly into your main() loop, programming would be impossible. Finding bugs would be agonizing, and optimizing high-level business logic would get lost in the weeds of register allocation.
Instead, computer science relies on functions and subroutines:
- A function like
quicksort(array)has a clear entry prerequisite: the input must be an array of comparable items (the Initiation Set). - Once invoked, the function executes a specialized sequence of loops and swaps across hundreds or thousands of CPU cycles (the Internal Policy).
- When the array is fully partitioned and sorted, the function reaches a
returnstatement and exits (the Termination Condition).
At the high-level application level, your program simply calls quicksort(). The CPU still executes primitive assembly instructions underneath, but your planning logic operates across macro-level units of work.
The Options Framework does the exact same thing for reinforcement learning agents. An option is a callable behavioral subroutine: the agent invokes a high-level option like navigate_to_doorway(), the option runs its internal policy for environment ticks, and returns control to the high-level policy when the doorway is reached.
Where the analogy stops: Software subroutines are typically deterministic and write to clean memory addresses. In RL, options operate in stochastic, partially observable physical environments, where transitions are probabilistic and termination conditions are stochastic functions evaluated at every state.
How It Actually Works
Formal 3-Tuple Definition of an Option
In the Options Framework, an option is formally defined as a 3-tuple:
where:
- Initiation Set : The subset of states in which the option can be initiated. An option is available to be selected at state if and only if . The set of available options at state is denoted .
- Internal Policy : The policy governing the agent while option is executing. When in state under active option , the agent selects primitive action with probability .
- Termination Condition : A function giving the probability that the option terminates upon arriving in state . If the agent enters state , option terminates with probability , relinquishing control back to the high-level policy. With probability , the option continues executing .
Primitive Actions as Degenerate Options:
Every standard primitive action can be expressed as a 1-step option:
Because primitive actions are valid options of duration , an agent utilizing the options framework retains the full expressive capacity of the original MDP.
Semi-Markov Decision Processes (SMDPs) and Intra-Option Learning
When an agent selects among options that execute over variable temporal durations , the underlying discrete-time Markov Decision Process transitions to a Semi-Markov Decision Process (SMDP) at the macro level.
Primitive MDP (k = 1):s_0 ──[a_0, r_1]──► s_1 ──[a_1, r_2]──► s_2 ──[a_2, r_3]──► s_3 (Discount: gamma)
Macro SMDP (k = 3 steps):s_0 ═══════════════[ Option omega, R(s_0, omega) ]══════════════► s_3 (Discount: gamma^3) (Executes internal policy pi_omega until beta_omega(s_3) = 1)1. SMDP Reward and Transition Models
Let denote the event that option is initiated at state at time , terminating at time in state .
The expected multi-step discounted reward of option is:
The discounted transition probability to arrive at terminal state under option across all possible durations is:
where is the joint probability that option terminates in state after exactly steps.
2. Macro-Level Bellman Equations over Options
Let denote the high-level policy over options, which selects which option to execute upon option termination. The action-value of executing option in state satisfies the Bellman Equation:
The optimal state value across all available options is:
3. Intra-Option Learning
Standard SMDP Q-learning waits until an option fully terminates after steps before performing a single value update. If an option executes for 50 steps, nothing is learned until step 50.
Intra-Option Learning overcomes this latency by updating option values on every single primitive transition :
where represents the expected value of arriving in state :
If the option continues (), the bootstrap target is . If the option terminates (), the target switches to the optimal next option value . Crucially, intra-option learning enables off-option learning: an experience tuple generated by one option can simultaneously update all other options whose internal policy is consistent with action .
Worked numerical example
Let us trace a concrete option execution in the classic 4-room gridworld door navigation problem:
- Environment Setup:
- State : Interior room position (non-terminal). Current option estimate: .
- State : Intermediate hallway position.
- State : Goal doorway connecting Room 1 to Room 2.
- Option Specification:
- Initiation set: .
- Termination condition:
- (continue).
- (terminate at doorway).
- Discount factor: .
- Option Trajectory Rollout ( primitive steps):
- Step 1: Takes primitive action , receives reward , reaches . Termination check: .
- Step 2: Takes primitive action , receives reward , reaches doorway . Termination check: Option terminates!
- Next-State Value:
- At doorway , the agent can invoke options to enter Room 2. Suppose maximum next option value is:
Step 1: Compute the Multi-Step Discounted Reward
The accumulated discounted reward over the duration is:
Step 2: Compute the Effective Temporal Discount Factor
Because the option executed for primitive timesteps, the future value at termination is discounted by :
Step 3: Compute the SMDP Bellman Target
The SMDP Bellman target for option value is:
Step 4: Evaluate Temporal Difference (TD) Error and Loss
Compared against the prior estimate :
The squared Bellman error loss is:
Step 5: Contrast with Intra-Option Evaluation at Step 2
Under intra-option learning at step 2 (transition from with and ):
Intra-option learning updates the value of reaching the doorway immediately on step 2 without waiting for retrospective SMDP trajectory stitching.
Code
import numpy as np
class OptionsFrameworkEvaluator: """Evaluates multi-step temporal abstraction under the Options Framework:
Option 3-tuple <I, pi, beta>, SMDP discounted return integration, macro-Bellman target computation, and intra-option TD updates. """
def __init__(self, gamma: float = 0.90) -> None: self.gamma = gamma
def compute_smdp_return( self, step_rewards: list[float] ) -> tuple[float, float, int]: """Computes multi-step discounted SMDP reward R(s, omega) and effective discount gamma^k:
R(s, omega) = sum_{t=0}^{k-1} gamma^t * r_{t+1} """ k = len(step_rewards) discounted_r = 0.0 for t, r in enumerate(step_rewards): discounted_r += (self.gamma**t) * r effective_gamma = self.gamma**k return float(discounted_r), float(effective_gamma), k
def compute_smdp_target( self, smdp_return: float, effective_gamma: float, next_state_max_q: float, ) -> float: """Computes SMDP Bellman target: y = R(s, omega) + gamma^k * max_{omega'} Q(s', omega').""" return float(smdp_return + effective_gamma * next_state_max_q)
def compute_intra_option_target( self, reward: float, beta_next: float, q_same_option: float, next_max_q: float, ) -> float: """Computes single-step intra-option target:
y_intra = r + gamma * [ (1 - beta(s')) * Q(s', omega) + beta(s') * max_{omega'} Q(s', omega') ] """ expected_continuation = ( 1.0 - beta_next ) * q_same_option + beta_next * next_max_q return float(reward + self.gamma * expected_continuation)
if __name__ == "__main__": np.set_printoptions(precision=4, suppress=True)
evaluator = OptionsFrameworkEvaluator(gamma=0.90)
# 4-room gridworld door navigation worked example # Step 1: r=0.0, s1, beta(s1)=0.0 # Step 2: r=1.0, s2=s_door, beta(s2)=1.0 step_rewards = [0.0, 1.0] next_max_q = 6.00 current_q_s0 = 5.00
# 1. SMDP multi-step return and effective discount r_smdp, eff_gamma, duration = evaluator.compute_smdp_return(step_rewards)
# 2. SMDP Bellman target and temporal difference error target_smdp = evaluator.compute_smdp_target(r_smdp, eff_gamma, next_max_q) td_error_smdp = target_smdp - current_q_s0 loss_smdp = 0.5 * (td_error_smdp**2)
# 3. Step-by-step intra-option targets # Step 1: r=0.0, arrives at s1 where beta=0.0, suppose Q(s1, omega)=5.50 y_intra_step1 = evaluator.compute_intra_option_target( reward=0.0, beta_next=0.0, q_same_option=5.50, next_max_q=5.50 ) # Step 2: r=1.0, arrives at s2 where beta=1.0, next_max_q=6.00 y_intra_step2 = evaluator.compute_intra_option_target( reward=1.0, beta_next=1.0, q_same_option=4.00, next_max_q=6.00 )
print(f"Option Duration k: {duration} steps") # -> Option Duration k: 2 steps
print(f"SMDP Multi-Step Reward R(s_0, omega): {r_smdp:.2f}") # -> SMDP Multi-Step Reward R(s_0, omega): 0.90
print(f"Effective Discount gamma^k: {eff_gamma:.4f}") # -> Effective Discount gamma^k: 0.8100
print(f"SMDP Bellman Target y: {target_smdp:.2f}") # -> SMDP Bellman Target y: 5.76
print(f"SMDP TD Error delta: +{td_error_smdp:.2f}") # -> SMDP TD Error delta: +0.76
print(f"Squared Bellman Loss: {loss_smdp:.4f}") # -> Squared Bellman Loss: 0.2888
print(f"Intra-Option Step 1 Target: {y_intra_step1:.2f}") # -> Intra-Option Step 1 Target: 4.95
print(f"Intra-Option Step 2 Target: {y_intra_step2:.2f}") # -> Intra-Option Step 2 Target: 6.40
# Assert correctness against worked example values assert duration == 2 assert np.isclose(r_smdp, 0.90, atol=1e-2) assert np.isclose(eff_gamma, 0.81, atol=1e-2) assert np.isclose(target_smdp, 5.76, atol=1e-2) assert np.isclose(td_error_smdp, 0.76, atol=1e-2) assert np.isclose(loss_smdp, 0.2888, atol=1e-3) assert np.isclose(y_intra_step1, 4.95, atol=1e-2) assert np.isclose(y_intra_step2, 6.40, atol=1e-2)Watch Out For
Option Degeneration, Chattering, and the Curse of Handcrafted Abstractions
When implementing hierarchical systems using the Options Framework, practitioners frequently encounter two catastrophic failure modes related to the termination condition :
- Option Chattering (Premature Termination): If termination functions are set too liberally (e.g., terminating whenever minor noise occurs), the high-level policy switches options at almost every timestep (). This destroys the entire benefit of temporal abstraction, reverting the SMDP back into a flat, high-variance MDP while adding the computational overhead of hierarchical evaluation.
- Option Degeneration (Zombie Options): Conversely, if termination conditions are too strict or internal policies get stuck in loops, an option may never terminate (). The high-level policy is locked out of control, unable to adapt if environmental conditions shift.
- The Sub-Optimality Gap: Manually handcrafting options (e.g., hardcoding doorway waypoints) biases the agent's state-visitation trajectory. If the handcrafted subroutines fail to capture the true optimal path, the hierarchically optimal policy will strictly underperform a flat, unconstrained policy.
The Fix: Modern hierarchical RL moves away from static, hand-designed options and uses end-to-end option discovery:
- Adopt the Option-Critic Architecture, which parameterizes the termination function as a differentiable neural network trained directly via policy gradients to terminate only when the option's continuation value falls below the value of switching options.
- Incorporate a deliberation cost (or switching penalty) into the termination gradient: penalize frequent option switching to naturally encourage longer, temporally meaningful options without manual tuning.
The Quick Version
- Temporal Abstraction 3-Tuple: An option formalizes macro-behaviors through an initiation set , an internal primitive policy , and a termination condition .
- Semi-Markov Decision Process (SMDP): When options execute over variable durations , the macro-level transition dynamics form an SMDP where rewards accumulate as and future values discount by .
- Intra-Option Efficiency: Intra-option learning avoids waiting for an option to terminate after steps by updating option action-values on every primitive transition, enabling simultaneous off-option updates.
- Overcoming Flat RL Limits: Options dramatically accelerate exploration and credit assignment in long-horizon sparse-reward environments, serving as the foundational building block for modern hierarchical RL architectures like Option-Critic and Feudal Networks.