Inferensys

Glossary

Conditional Task

A conditional task is a planning construct in Hierarchical Task Networks (HTN) whose decomposition into subtasks or direct execution is contingent upon the runtime evaluation of specific world state conditions.
Product manager reviewing autonomous task execution dashboard on laptop, completed tasks visible, casual work session.
HIERARCHICAL TASK NETWORKS

What is a Conditional Task?

A Conditional Task is a fundamental construct in Hierarchical Task Network (HTN) planning and agentic cognitive architectures where the decomposition or execution of a task is dynamically determined by evaluating runtime conditions.

A Conditional Task is a task whose decomposition into subtasks or whose execution is contingent upon the runtime evaluation of specific preconditions against the current world state. Unlike a Primitive Task (a direct action) or a fixed Compound Task, its resolution is not predetermined; the planner or agent must evaluate logical expressions to select the appropriate method for decomposition or to decide if the task can be executed. This enables agents to build flexible, context-aware plans that adapt to dynamic environments.

In practice, conditional tasks are implemented through conditional methods or precondition checks within an HTN's domain description. For example, a high-level task NavigateTo(Destination) might decompose into DriveCar if a car is available, or Walk otherwise. This conditional branching is central to plan refinement and is a key differentiator from simpler sequential planners. It allows agentic systems to exhibit robust, goal-directed behavior by making decisions based on sensed state, closely simulating executive function in cognitive architectures.

HIERARCHICAL TASK NETWORKS

Core Characteristics of Conditional Tasks

A Conditional Task is a fundamental construct in Hierarchical Task Network (HTN) planning where the structure or execution of a task is dynamically determined by runtime conditions. These tasks enable agents to build flexible, context-aware plans.

01

Runtime State Dependence

The decomposition or execution path of a Conditional Task is not predetermined but is selected based on the evaluation of preconditions against the current world state. This is the core distinction from static task networks.

  • Example: A Navigate task may decompose into CallElevator if the agent is inside a building, or WalkToDestination if it is already outside. The planner evaluates the agent-location state variable to choose the correct method.
02

Integration with HTN Methods

Conditionality is formally implemented through HTN Methods. Each method provides one possible decomposition for a compound task, guarded by a logical precondition.

  • A task like AcquireItem(?item) could have multiple methods:
    • Method 1: Precondition ItemOnShelf(?item) → Subtasks: NavigateToShelf, PickUpItem.
    • Method 2: Precondition ItemInStorage(?item) → Subtasks: RequestFromStockroom, WaitForDelivery. The planner selects the first method whose precondition holds true.
03

Enables Contextual Plan Branching

Conditional Tasks are the primary mechanism for introducing branching logic and contingency handling into hierarchical plans. They allow a single high-level goal to be achieved via different action sequences depending on situational context.

  • This is critical for robustness in dynamic environments. For instance, an HandleServerAlert task will branch differently if the condition alert-severity == CRITICAL is true versus if it is false, leading to distinct escalation and repair procedures.
04

Foundation for Reactive Execution

While HTN planning is often considered deliberative, Conditional Tasks bridge planning with reactive execution. During plan execution, if a condition for a pending task changes, the system can trigger replanning from that task node.

  • This creates a sense of continuous, context-sensitive decision-making. An AssessRisk task that conditionally calls Evacuate or ContinueMission can be re-evaluated if new sensor data updates the world state, making the agent responsive to real-time changes.
05

Distinction from Primitive & Compound Tasks

It's essential to differentiate a Conditional Task from its sibling concepts in the HTN hierarchy:

  • Primitive Task: An executable action (e.g., TurnValve). Has no decomposition.
  • Compound Task: A high-level task (e.g., RepairPump) that must be decomposed, but may have only one static method.
  • Conditional Task: A type of Compound Task that has two or more alternative methods, where the choice is contingent on state. All conditional tasks are compound, but not all compound tasks are conditional.
06

Implementation in Planners (e.g., SHOP)

Algorithms like SHOP (Simple Hierarchical Ordered Planner) natively support Conditional Tasks. SHOP performs a forward search, interleaving task decomposition with state progression. When it encounters a compound task, it evaluates the preconditions of all its methods in the current state and non-deterministically chooses an applicable one to pursue.

  • This makes the planning process itself conditional and state-dependent. The efficiency of HTN planning comes from this directed search through the space of possible decompositions, guided by the preconditions on methods.
CONDITIONAL TASK

Frequently Asked Questions

Questions and answers about Conditional Tasks, a core concept in Hierarchical Task Network (HTN) planning that enables dynamic, context-aware behavior in autonomous agents.

A Conditional Task is a task within a Hierarchical Task Network (HTN) whose decomposition into subtasks or whose execution is contingent on the runtime evaluation of specific world state conditions. Unlike a static task, its resolution path is not predetermined but is dynamically selected based on the current state of the environment.

In practice, this is implemented by attaching preconditions to the methods that decompose a compound task. When the planner encounters a conditional task, it evaluates the preconditions of all available decomposition methods. Only methods whose conditions are satisfied in the current world state are considered valid for decomposing that task. This allows an agent to choose different action sequences based on real-time sensor data, user input, or the outcomes of previous actions, enabling flexible and robust behavior.

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.