Option-Critic Architecture
Give an agent reusable skills plus a learned sense of when to drop them, and both the skills and the quitting rules improve straight from reward, with no hand-placed subgoals.
Why Does This Exist?
Long tasks need skills, not just twitches. Nobody solves a dungeon by choosing muscle torques; they cross rooms, grab keys, open doors. The options framework wrote that idea down in 1999: an option has an initiation set, an internal policy for acting while it runs, and a termination chance for handing control back.
The framework left one question bleeding: where do options come from? For years the answer was a human. People hand-placed bottleneck states, drew initiation sets around doorways, and tuned termination by feel. Two-phase pipelines clustered state graphs offline and froze the skills before learning began. Nothing adapted when the world changed, and no gradient connected final reward back to the quitting decisions.
Option-Critic closed the loop in 2017. Bacon, Harb, and Precup derived gradients for both the internal policies and the termination functions, so skills and quitting rules learn end to end from reward. For the framework it builds on, see options framework. For the broader family, see hierarchical RL. For the value-decomposition sibling, see MAXQ.
The one idea you need first
An option's value is the expected return of starting option in state . The state's hierarchical value is the best the agent can do from by picking options well. Their gap, the advantage , says whether staying in the current option beats quitting. Negative means quit, positive means persist. Everything below is gradient ascent listening to that gap.
Think of It Like This
A fighter with combos and a quitting instinct
A martial artist under pressure does not deliberate each inch of footwork. She fires a combo, say a side-step pivot, and the body runs the drilled sequence while her attention watches for the moment to abort. The combo is the intra-option policy: automatic while active. The quitting instinct is the termination function: it fires when continuing looks worse than switching.
Early in training her instincts are garbage and she spins through full combos into punches. Over bouts, two things sharpen together. The combos get tighter, and the abort sense gets better calibrated: she learns to bail the instant the opponent overcommits and a strike pays more than another pivot. Nobody handed her a combo list or a quitting manual. Sparring scores trained both.
Where it stops: fighters copy coaches and drill forms on purpose. Option-Critic has no coach, no demonstrations, and no notion of what a skill should look like. Skills and stopping points both emerge from scalar reward, which is slower and stranger than coaching.
How It Actually Works
One shared trunk reads the state; three heads decide. The intra-option head picks primitive actions while option runs. The termination head outputs a quit chance, usually a sigmoid over a logit. The critic head scores options.
Arriving in under option , the continuation value blends staying and quitting:
The intra-option policy climbs the gradient of , favoring actions that lead somewhere the current option stays valuable. The termination parameters climb a different gradient, the termination gradient theorem:
Read the sign: a negative advantage (current option losing) flips the minus and pushes up, so the option quits. A positive advantage pushes down, so the skill persists. Raw switching is free in this math, so unregularized agents quit everywhere and skills collapse to single steps. A deliberation cost added to the advantage demands the gain beat a switching fee before quitting pays.
Worked example
State with active option , rival , deliberation cost , step size :
- Option values: , , so .
- Raw advantage: . Regularized: . Staying loses even after the fee.
- Termination logit , so with slope .
- Ascent direction: . Update: , so .
- New quit chance: , up from 0.50.
The losing option now quits more often, exactly as the advantage ordered.
Code
This replay runs the worked numbers above:
import math
def sigmoid(z: float) -> float: """Logistic squashing from logit to probability.""" return 1.0 / (1.0 + math.exp(-z))
def termination_update(q_current: float, q_best: float, eta: float, z: float, alpha: float) -> tuple[float, float, float]: """Advantage, gradient step, and new termination probability.""" advantage = (q_current - q_best) + eta beta = sigmoid(z) grad = beta * (1.0 - beta) * advantage z_new = z - alpha * grad return round(advantage, 2), round(z_new, 4), round(sigmoid(z_new), 4)
print(termination_update(4.0, 6.0, 0.5, 0.0, 0.5)) # -> (-1.5, 0.1875, 0.5467)The output matches the hand walk: advantage , logit , quit chance .
Watch Out For
Unregularized options collapse to single steps
Quitting every step is never worse than committing, by the math: it buys a fresh greedy choice each time. So without intervention the termination gradient drives toward 1.0 everywhere, average option length falls to 1, and the hierarchy silently becomes flat one-step RL wearing a costume.
Watch mean option duration during training. If it dives toward 1, add a deliberation cost, initialize termination logits negative so options start long, and penalize saturation. Check duration before celebrating returns.
Bootstrapping options like atomic actions biases the policy gradient
The intra-option update must bootstrap through the continuation value , which mixes staying and quitting. A common bug treats the option as one long action and bootstraps with plain , ignoring that termination hands control to a different option with a different value. The gradient then credits actions for value they never produce.
Always route the bootstrap through with the current inside it. If intra-option policies improve while termination sits frozen and nothing converges, the bootstrap is the first place to look.
The Quick Version
- Option-Critic learns intra-option policies, termination chances, and option values together from reward gradients, with no hand-built subgoals.
- The intra-option policy climbs built on the continuation value , which blends staying with quitting through .
- The termination gradient pushes up when the advantage is negative and down when it is positive; here moves 0.50 to 0.5467.
- Free switching collapses options to single steps, so a deliberation cost charges a fee for quitting.
- Bootstrap intra-option updates through , never through plain action values, or the gradient credits phantom value.