lesson depth
Mastery
not started · 0%

Classical Planning, PDDL, and Hierarchical Task Networks

State representations, STRIPS action schemas (preconditions, effects), PDDL domains, forward/backward search, HTNs, and neuro-symbolic planners resolving LLM ReAct loops.

Freshness: current•16 min read•Computer Science and Programming

Key Learning Outcomes

  • ✓Author formal PDDL domain and problem specifications with typed objects, predicates, and parameterized action schemas.
  • ✓Differentiate state progression search from goal regression and relaxed planning graph heuristics.
  • ✓Diagnose why pure LLM ReAct loops suffer from plan drift and design neuro-symbolic architectures with deterministic PDDL validators.

Mental model

In general state-space search, transition functions are opaque: given a state and an action, the environment returns a successor state without revealing why the transition occurred or which state variables changed. Classical planning opens this black box by representing states as sets of logical predicates and actions as explicit causal operators with preconditions (what must be true to execute) and effects (what changes in the world).

Instead of guessing actions blind, a planning agent reasons causally about dependencies: an action cannot be scheduled until its preconditions are established by previous actions or initial facts.

In contemporary agentic systems, classical planning addresses the fatal flaws of pure LLM ReAct (Reason + Act) loops. Unconstrained LLM agents frequently hallucinate world state, cycle endlessly between tools, or execute destructive actions out of order. By integrating formal PDDL (Planning Domain Definition Language) and Hierarchical Task Networks (HTN) into a hybrid neuro-symbolic loop, engineers combine LLM common-sense reasoning with mathematically verified causal execution guarantees.

PDDL Domain Predicates & Action Schemas
Initial State & Goal Specification
Heuristic Planning Graph Progression
Causal Precondition & Effect Verification
Executable Deterministic Plan Sequence
Conceptual teaching model synthesized from:aima-search-planning,fikes-nilsson-strips-1971

Learning outcomes

  • Author formal PDDL domain and problem specifications with typed objects, relational predicates, and parameterized action schemas.
  • Implement STRIPS action execution mechanics utilizing explicit Precondition, Add, and Delete lists.
  • Differentiate forward state progression search from backward goal regression and relaxed planning graph heuristics.
  • Deconstruct complex workflows into Hierarchical Task Networks (HTN) with compound tasks and decomposition methods.
  • Diagnose failure modes in autonomous LLM ReAct loops (plan drift, tool thrashing) and design neuro-symbolic architectures with deterministic PDDL validators.

Theory

The STRIPS Formalism

Formulated by Fikes and Nilsson (1971) for the Shakey robot, STRIPS (Stanford Research Institute Problem Solver) represents states as conjunctions of positive function-free literals. An action schema $a$ consists of three components:

  1. $\text{Pre}(a)$: Conjunction of literals that must hold in state $S$ for $a$ to be applicable.
  2. $\text{Add}(a)$: Literals made true by executing $a$.
  3. $\text{Del}(a)$: Literals made false by executing $a$.

When action $a$ is applied to state $S$, the successor state $S'$ is computed by the transition equation:

text(2 lines)
1S' = (S \ Del(a)) U Add(a)
python(42 lines)
1from dataclasses import dataclass
2from typing import FrozenSet, List, Optional, Set
3
4@dataclass(frozen=True)
5class Action:
6 name: str
7 preconditions: FrozenSet[str]
8 add_list: FrozenSet[str]
9 del_list: FrozenSet[str]
10
11 def is_applicable(self, state: FrozenSet[str]) -> bool:
12 return self.preconditions.issubset(state)
13
14 def apply(self, state: FrozenSet[str]) -> FrozenSet[str]:
15 if not self.is_applicable(state):
16 raise ValueError(f"Action {self.name} is not applicable in current state.")
17 return (state - self.del_list) | self.add_list
18
19def forward_plan_search(
20 initial_state: FrozenSet[str],
21 goal_conditions: FrozenSet[str],
22 actions: List[Action]
23) -> Optional[List[str]]:
24 frontier = [(initial_state, [])]
25 explored = set([initial_state])
26
27 while frontier:
28 current_state, plan = frontier.pop(0)
29
30 # Check if all goal conditions are satisfied
31 if goal_conditions.issubset(current_state):
32 return plan
33
34 for action in actions:
35 if action.is_applicable(current_state):
36 next_state = action.apply(current_state)
37 if next_state not in explored:
38 explored.add(next_state)
39 frontier.append((next_state, plan + [action.name]))
40
41 return None
22 lines hidden

The Planning Domain Definition Language (PDDL)

PDDL standardizes planning into two files:

  1. Domain File: Defines object types, state predicates, and parameterized actions.
  2. Problem File: Declares specific objects, the initial state, and the goal state.
lisp(26 lines)
1;; Example: PDDL Cloud Server Provisioning Domain
2(define (domain cloud-infra)
3 (:requirements :strips :typing)
4 (:types server subnet vpc)
5 (:predicates
6 (in-vpc ?s - subnet ?v - vpc)
7 (server-created ?srv - server)
8 (subnet-allocated ?s - subnet)
9 (server-running ?srv - server)
10 (ssh-accessible ?srv - server))
11
12 (:action allocate-subnet
13 :parameters (?s - subnet ?v - vpc)
14 :precondition (in-vpc ?s ?v)
15 :effect (subnet-allocated ?s))
16
17 (:action provision-server
18 :parameters (?srv - server ?s - subnet)
19 :precondition (subnet-allocated ?s)
20 :effect (and (server-created ?srv) (server-running ?srv)))
21
22 (:action configure-security-group
23 :parameters (?srv - server)
24 :precondition (server-running ?srv)
25 :effect (ssh-accessible ?srv)))
6 lines hidden

Search Directions: Progression vs. Regression

  • Forward State Progression: Begins at initial state $S_0$ and applies applicable actions forward toward the goal. Advantage: ground states are always concrete. Disadvantage: high branching factor when irrelevant actions exist.
  • Backward Goal Regression: Starts at goal state $G$ and searches backward for actions whose effects satisfy goal sub-literals, updating subgoals to include the action's preconditions. Advantage: focuses strictly on relevant actions.
  • Relaxed Planning Graph Heuristics (FF Planner): Computes heuristic distance by ignoring all Delete lists ($\text{Del}(a) = \emptyset$), transforming the exponential search into polynomial time reachability analysis.

Hierarchical Task Networks (HTN)

Unlike flat STRIPS planners that search solely through atomic primitive steps, HTN planners decompose high-level compound tasks into smaller subtasks using pre-engineered domain methods. An HTN planner asks: "How do I accomplish task $T$?" rather than "What sequence of primitive operators reaches goal $G$?"

Neuro-Symbolic Agent Architecture

In modern autonomous systems, combining LLMs with classical planners eliminates key agent failure modes:

  1. LLM as Intent Parser & Heuristic Generator: The LLM translates user natural-language commands into PDDL goals or selects high-level HTN methods.
  2. Deterministic Planner as Formal Validator: A classical PDDL planner (e.g., Fast Downward, ENHSP) generates the plan and proves all causal preconditions hold before any external API is invoked.
  3. Execution Guardrail: If an external API call fails at runtime, the state discrepancy is reflected back into the PDDL state for re-planning, avoiding infinite ReAct loops.

Trade-offs

| Planning Paradigm | Planning Speed | Expressiveness | Scalability | Verification & Safety | |---|---|---|---|---| | Forward STRIPS Search | Slow (combinatorial state explosion) | Flat propositional predicates | Small problems ($< 20$ actions) | 100% mathematically proven | | Heuristic Graphplan / Fast-Forward | Fast (polynomial relaxation) | Propositional + numeric fluents | Moderate ($< 1000$ actions) | 100% mathematically proven | | Hierarchical Task Networks (HTN) | Very fast (guided by methods) | Hierarchical compound procedures | Large enterprise workflows | 100% mathematically proven | | Pure LLM ReAct Loop | Moderate (network latency per step) | Unrestricted natural language | Brittle beyond 5-8 steps | Zero formal guarantees (prone to hallucination) | | Neuro-Symbolic (LLM + PDDL/HTN) | Fast (LLM guides method selection) | Natural language + formal predicates | High enterprise scale | 100% formal precondition verification |

Failure modes and misconceptions

  1. The Sussman Anomaly: Demonstrates that non-interleaved sub-goal solving is incomplete. In the classic Blocks World, achieving Goal A (Block A on Block B) followed by Goal B (Block B on Block C) requires undoing Goal A to place Block B on Block C first. Planners must interleave action plans across multiple sub-goals.
  2. Infinite ReAct Loops: Pure LLM agents without causal precondition models frequently get trapped calling the same failing tool repeatedly because the model's autoregressive context reinforces the previous choice.
  3. Plan Drift: In multi-step agent execution, an LLM generating step 12 has often drifted from the core invariant established in step 1, violating implicit system safety constraints.
  4. Static World Assumption: Classical STRIPS assumes the world changes only when the planner acts (closed-world assumption). In distributed systems with external network changes, plans must incorporate sensory preconditions and dynamic re-planning.
Reflect before revealing the guide

Decision scenario

You are architecting an autonomous enterprise migration agent tasked with upgrading a distributed Apache Kafka cluster across three AWS regions without dropping incoming message streams or violating partition replication minimums.

  • Option A: Build an open-ended LangChain ReAct agent equipped with AWS CLI and Kafka AdminClient bash tools.
  • Option B: Author a static 400-line Python deployment script with sequential hardcoded API calls and zero branching logic.
  • Option C: Implement a neuro-symbolic HTN planning pipeline: high-level methods decompose regional rolling upgrades into discrete PDDL actions (drain-broker, reassign-partitions, verify-insync-replicas, restart-node). A deterministic engine validates that (min-isr-satisfied ?partition) holds before allowing any broker termination tool call.

Recommendation: Choose Option C. Option A will inevitably trigger partition under-replication or brain-split when the LLM hallucinates broker states. Option B crashes ungracefully when transient cloud network timeouts occur. Option C guarantees strict causal safety invariants while allowing dynamic re-planning when individual node operations encounter retries.

Prerequisites & Related Concepts (2)

Private notes

0 words
Next