An iterative task is a type of compound task within a Hierarchical Task Network (HTN) that involves repeating a subtask or a network of subtasks until a specified termination condition is satisfied. Unlike a simple sequence, it introduces a looping construct into the planning process, allowing an autonomous agent to model repetitive operations like "monitor until stable" or "retry until successful." The termination condition is a logical precondition evaluated against the dynamic world state.
Glossary
Iterative Task

What is an Iterative Task?
A core concept in automated planning and agentic systems, an iterative task defines a repetitive control structure within a hierarchical task network.
In execution, an iterative task is decomposed by a method that inserts its subtask network into the plan, followed by a recursive link back to the iterative task itself, creating a loop. This continues until the condition is met, at which point the planner exits the loop. This construct is fundamental for building robust, long-horizon agents that can handle replanning and persistent goal pursuit without manual intervention, directly supporting executive function simulation in cognitive architectures.
Core Characteristics of Iterative Tasks
An iterative task is a fundamental construct in hierarchical planning where a subtask or network of subtasks is repeated until a termination condition is satisfied. This page details its defining features and role in autonomous systems.
Definition and Formal Structure
An iterative task is a specialized compound task defined by a loop body (a subtask or task network) and a termination condition. The planner repeatedly decomposes and executes the loop body, evaluating the condition after each iteration. It is formally represented in the domain description alongside other tasks and methods. This structure is essential for modeling repetitive processes like data validation or search until a goal is met.
Termination Conditions
The loop's halt is governed by a logical termination condition, which is evaluated against the dynamic world state. Common conditions include:
- State-Based: A specific fact becomes true (e.g.,
inventory_count == 0). - Resource-Based: A consumable resource is exhausted (e.g.,
budget < cost). - Iteration Limit: A maximum count is reached (e.g.,
attempts >= 10). - Goal Achievement: The desired high-level goal is satisfied. The condition must be carefully designed to prevent infinite loops.
Integration with HTN Planning
Within Hierarchical Task Network (HTN) planning, an iterative task is a compound task requiring a dedicated decomposition method. This method specifies how to unroll a single iteration, generating the loop body's subtasks. Planners like SHOP interleave this decomposition with state progression, allowing the termination condition to be re-evaluated with updated world facts after each iteration's effects are applied, enabling dynamic loop control.
Contrast with Primitive Loops
Unlike a loop written in imperative code (e.g., a while loop), an HTN iterative task is declarative and plan-time. The planner reasons about the iteration, not just executing it. This allows for:
- Optimization: The planner may reorder or interleave loop iterations with other tasks if constraints allow.
- Verification: The plan can be verified for correctness (e.g., guaranteed termination) before execution.
- Explanation: The decomposition tree provides a transparent audit trail of the iterative process.
Common Use Cases and Examples
Iterative tasks model real-world processes requiring repetition until a criterion is met.
- Data Processing: "Clean records until no invalid entries remain."
- Search & Optimization: "Refine solution parameters until error < 0.01%."
- Diagnostic Systems: "Run test A, if inconclusive, run test B, repeat until fault identified."
- Resource Gathering: "Collect units until the required quantity is met." These are foundational for building robust autonomous agents that handle open-ended problems.
Relation to Conditional and Parallel Tasks
Iterative tasks often interact with other HTN control structures.
- Conditional Tasks: The loop body may contain conditional tasks that branch execution based on state, making each iteration adaptable.
- Parallel Tasks: Subtasks within the loop body may be designated for parallel execution, subject to resource constraints, to improve efficiency.
- Recursive Decomposition: An iterative task's loop body can itself contain another iterative task, enabling nested loops for complex multi-phase processes.
Frequently Asked Questions
Common questions about iterative tasks, a core concept in Hierarchical Task Network (HTN) planning for autonomous agents. This concept is fundamental for engineers building agents that must repeat actions until a goal is satisfied.
An iterative task is a compound task within a Hierarchical Task Network (HTN) that is defined to repeat a specific subtask or an entire network of subtasks until a defined termination condition is satisfied. It is a control structure that enables the representation of loops within a hierarchical plan, allowing an agent to perform actions like 'monitor until stable' or 'search until found'.
In formal terms, an iterative task is decomposed by a method that contains a looping construct. This method specifies the subtask to be repeated and the precondition that, when it becomes false, signals the loop to terminate. The iterative task itself is not a primitive action but a high-level directive that the planner must expand into a sequence of repeated primitive actions during the task decomposition process.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Iterative tasks are a core construct within Hierarchical Task Networks (HTNs). The following terms define the planning and execution concepts that enable and constrain this form of controlled repetition.
Conditional Task
A task whose decomposition or execution is contingent on the runtime evaluation of specific world state conditions. This is a fundamental mechanism for implementing the termination logic of an iterative task.
- Key Role: Enables branching logic within a plan. The planner or executor checks a condition to decide which method to apply or whether to continue a loop.
- Example: A
Navigatetask may decompose intoDriveif the destination is far, orWalkif it is near. An iterativePolishSurfacetask continues its subtask only while theSurfaceRoughnessmetric is above a threshold.
Precondition
A logical condition that must be true in the current world state for a planning operator or HTN method to be applicable. For iterative tasks, preconditions often encode the termination condition.
- Mechanism: A method that decomposes an iterative task will have a precondition that, when evaluated as false, prevents its application, thereby ending the iteration.
- Contrast with Effects: While effects change the state, preconditions are checked before an action or decomposition to ensure validity. A loop continues only while the precondition for its continuation method holds.
Plan Refinement
The iterative process in HTN planning of replacing abstract tasks in a skeletal plan with more concrete subtasks or primitive actions. Executing an iterative task is a form of runtime plan refinement.
- Process: The planner or executive agent begins with a high-level iterative task. Through refinement, it repeatedly applies decomposition methods, generating concrete subtask instances until the termination condition is met.
- Link to Execution: In online planning or interleaved planning and execution, refinement happens in real-time. The agent refines the iterative loop, executes a subtask, evaluates the state, and decides whether to refine another iteration.
Replanning
The process of generating a new plan when the execution of the current plan fails or the world state changes unexpectedly. Iterative tasks must be robust to replanning if an iteration fails.
- Failure Context: If an iteration's subtask fails (e.g., a
GraspObjectaction drops the item), the system may need to replan. This could involve retrying the same iterative task with modified parameters or choosing a different decomposition method altogether. - System Resilience: A well-designed iterative task within an HTN provides clear replanning hooks. The system can backtrack to the level of the iterative task and attempt a different strategy for the remaining iterations.
SHOP (Simple Hierarchical Ordered Planner)
A seminal HTN planning algorithm that performs task decomposition in a forward, depth-first manner, interleaving planning with state progression. SHOP naturally handles iterative tasks through recursive method application.
- Algorithm Behavior: SHOP starts with a task list, picks the first task, and finds an applicable method or operator. It then recursively decomposes compound tasks. For an iterative task, this means the planner will repeatedly apply the same decomposition method, progressing the simulated world state each time, until the method's preconditions are no longer met.
- Practical Impact: SHOP's approach demonstrates how iterative logic is embedded in the domain description (via methods with state-dependent preconditions) rather than as a separate control construct in the planning algorithm itself.
Decomposition Tree
A tree structure that visually represents the hierarchical breakdown of a high-level task into its constituent subtasks during HTN planning. An iterative task creates a repeating pattern within this tree.
- Visualizing Iteration: In the tree, a node for an iterative task will have multiple, structurally similar subtrees as children, each representing one cycle of the loop. The tree expands horizontally at that level with each iteration.
- Debugging Aid: The decomposition tree is a crucial tool for plan verification and debugging. It allows engineers to see how many times an iterative task was decomposed and inspect the state conditions that led to each decomposition step.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us