A hierarchical task network (HTN) is an automated planning formalism in which a planner achieves goals by recursively decomposing high-level tasks into smaller subtasks according to domain-specific methods, until only directly executable actions remain. In Symbolic AI & reasoning, HTN planning is one of the most widely deployed planning paradigms, because it lets domain experts encode procedural knowledge about how things are done rather than only describing what the goal state should be.
Where classical planning searches for any sequence of actions that reaches a goal, HTN planning searches only among decompositions that the domain author considers sensible. This restriction makes it faster and more predictable in practice, and it explains the popularity of HTN planning in games, robotics, logistics and process automation.
How HTN planning decomposes tasks
An HTN planner starts from an initial task network, which is a set of tasks with ordering constraints, and a description of the current world state. It repeatedly selects a non-primitive task and replaces it with the subtasks of an applicable method, checking preconditions against the state.
The process ends when the network contains only primitive tasks, also called operators or actions, whose preconditions and effects resemble STRIPS actions. The resulting sequence is the plan. If no method applies at some point, the planner backtracks and tries an alternative decomposition.
| Element | Role | Example in a delivery domain |
|---|---|---|
| Compound task | Abstract activity that must be decomposed | Deliver package to customer |
| Method | One recipe for decomposing a compound task | Deliver by truck when within city limits |
| Method precondition | Condition under which a method applies | Truck is available and road is open |
| Primitive task | Directly executable action with effects | Load package, drive, unload package |
| Ordering constraint | Required sequence among subtasks | Load before drive, drive before unload |
Because several methods can exist for the same compound task, the domain encodes alternative strategies. The planner chooses among them by search, which combines expert guidance with the flexibility of automated reasoning.
Variants and formal properties
HTN planning appears in several variants that differ in how subtasks are ordered and how decomposition is searched. The distinction affects both expressiveness and computational cost.
| Variant | Ordering of subtasks | Typical planner style | Trade-off |
|---|---|---|---|
| Total-order HTN | Fixed linear sequence | Forward decomposition, as in SHOP | Fast and simple, less flexible |
| Partially ordered HTN | Only required orderings specified | Interleaving of subtasks, as in SHOP2 | More expressive, larger search space |
| HTN with task insertion | Planner may add actions outside methods | Hybrid of HTN and classical planning | Robust to incomplete methods |
| Hybrid or plan-space HTN | Causal links and decomposition together | Partial-order planning with hierarchy | Expressive but complex to implement |
Formally, HTN planning is strictly more expressive than classical planning. General HTN plan existence is undecidable, while total-order and certain restricted forms are decidable. This theoretical power is the reason careful method design matters: unrestricted recursion can describe problems no planner can solve in general.
For standardized description, the HDDL language extends PDDL with tasks and methods and is used in the hierarchical track of the International Planning Competition.
HTN compared with classical planning
The key difference is the source of search guidance. Classical planners derive guidance automatically from heuristics over goals, whereas HTN planners rely on human-authored methods that prune the space before search begins.
| Aspect | Classical planning | HTN planning |
|---|---|---|
| Problem input | Initial state and goal condition | Initial state and tasks to accomplish |
| Domain knowledge | Actions with preconditions and effects | Actions plus decomposition methods |
| Search space | All action sequences | Only sanctioned decompositions |
| Plan quality control | Optimality via cost metrics | Encoded in method design |
| Authoring effort | Lower | Higher, requires expert knowledge |
| Typical languages | STRIPS, PDDL | SHOP domain syntax, HDDL |
HTN planners often solve large real-world problems orders of magnitude faster than domain-independent planners, but only when methods are well written. Poor methods cause missed solutions, because the planner never considers plans outside the hierarchy.
Where HTN planning is applied
HTN planning is used wherever repeatable expert procedures must be combined flexibly at runtime. Its plans are also easy to explain, because each action can be traced back to the high-level task it serves.
- Video game AI: non-player characters choose behaviors through HTN planners that react to the game state.
- Robotics: mission planning decomposes goals such as inspect area into navigation and sensing actions.
- Logistics and manufacturing: process plans assemble operations into feasible production sequences.
- Military and emergency operations: course-of-action planning follows doctrine encoded as methods.
- Cloud and business automation: workflows are composed from service-level tasks.
- LLM agents: hierarchical decomposition structures tool calls and verifies subgoals.
Recent neuro-symbolic work combines learned models with HTN structure, for example by learning methods from demonstrations or by letting a language model propose decompositions that a symbolic planner then validates.
Limitations and common pitfalls
The main limitation of HTN planning is the knowledge engineering burden. Writing complete and correct methods requires deep domain expertise, which echoes the knowledge acquisition bottleneck known from expert systems.
| Problem | Symptom | Mitigation |
|---|---|---|
| Missing method | Planner reports no plan for solvable tasks | Add alternatives or allow task insertion |
| Left recursion | Planner loops without progress | Reorder subtasks or add guards |
| Overly strict preconditions | Valid strategies never applied | Test methods on varied states |
| Brittle world model | Plans fail during execution | Add monitoring and replanning |
HTN plans are only as good as the hierarchy, so systematic testing of domains and execution monitoring with replanning on failure are essential in deployed systems.
In everyday language
Think about planning a dinner party. You do not start by listing every hand movement. You start with big tasks: plan the menu, buy food, cook, set the table.
Each big task breaks into smaller ones. Buying food becomes making a list, driving to the store and paying. A hierarchical task network plans the same way. It splits big jobs into smaller steps until each step is simple enough to do. Experts write the recipes for splitting tasks, so the computer follows proven ways of working.
Seen in the real world
A studio developing a tactical action game needs enemy squads that behave believably and adaptively. Scripted state machines had become difficult to maintain, with hundreds of transitions between behaviors that designers struggled to debug.
The team adopts an HTN planner for squad behavior. The top-level task, defend position, decomposes into methods such as hold cover, flank the player or retreat to a fallback point, each with preconditions on ammunition, health and line of sight. Primitive tasks include move, take cover, reload and fire. The planner replans within milliseconds when the world state changes.
Designers now adjust behavior by editing individual methods instead of rewiring a state machine. Playtesters report that enemies feel more coordinated, and debugging is easier because each action shows which high-level task it serves.