Inferensys

Glossary

Iterative Task

An iterative task is a structured task in AI planning that involves repeating a subtask or a network of subtasks until a defined termination condition is satisfied.
Product manager reviewing autonomous task execution dashboard on laptop, completed tasks visible, casual work session.
HIERARCHICAL TASK NETWORKS

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.

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.

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.

HIERARCHICAL TASK NETWORKS

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.

01

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.

02

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.
03

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.

04

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.
05

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.
06

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.
HIERARCHICAL TASK NETWORKS

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.

Prasad Kumkar

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.