Hierarchical Task Networks — the planner family behind game AI and space-shuttle scheduling — decompose abstract tasks into primitive actions via reusable "methods." Paired with an LLM, they give agentic planning a spine that pure prompting lacks.
An HTN planner works backward from a task: is there a method for this task in the current state? If yes, decompose it into subtasks and recurse; if it is already primitive, schedule it; if no method applies, the plan fails — loudly and early. Unlike classical state-space planners that search over world states, HTNs search over decompositions, which is why they scale to plans with thousands of steps and why game studios have shipped them for decades.
LLMs are superb at the part HTNs are weak at — writing the methods. A model given a domain description can propose "to deploy-a-service: build, run-tests, push-image, update-manifest, verify-health" with preconditions each step asserts. The classical engine then executes and validates those decompositions deterministically. The LLM contributes world knowledge and flexible generalization; the HTN contributes soundness, termination guarantees, and an explanation of exactly which decomposition failed.
The Division of Labor
- LLM proposes: task decompositions, method preconditions, recovery strategies for failed branches — the creative combinatorics.
- HTN disposes: validity checking against world state, ordering, resource constraints, and provable plan failure instead of silent flailing.
- Agent loop bridges: at execution time, primitive actions become tool calls whose observations update the world state the planner reasons over.
The pattern's discipline is its gift: when everything is a decomposition of a known task vocabulary, an agent can no longer invent an unbounded plan mid-run — it can only instantiate branches the system has already blessed. For high-stakes domains (infrastructure, medical, finance), that constraint is not a limitation. It is the product.