Skip to main content

Module task

Module task 

Source
Expand description

AI Task Definition

A Task is a unit of work to be performed by an AI agent. It is step ④ in the end-to-end flow described in mod.rs — the stable identity for a piece of work, independent of how many times it is attempted (Runs) or how the strategy evolves (Plan revisions).

§Position in Lifecycle

 ③  Plan ──steps──▶ [PlanStep₀, PlanStep₁, ...]
                         │
                         ├─ inline (no task)
                         └─ task ──▶ ④ Task
                                       │
                                       ├──▶ Run₀ ──plan──▶ Plan_v1
                                       ├──▶ Run₁ ──plan──▶ Plan_v2
                                       │
                                       ▼
                                   ⑤  Run (execution)

§Status Transitions

Draft ──▶ Running ──▶ Done
  │          │
  ├──────────┴──▶ Failed
  └──────────────▶ Cancelled

§Relationships

FieldTargetCardinalityNotes
parentTask0..1Back-reference to parent Task for sub-Tasks
intentIntent0..1Originating user request
runsRun0..NChronological execution history
dependenciesTask0..NMust complete before this Task starts

Reverse references:

  • PlanStep.task → this Task (forward link from Plan)
  • Run.task → this Task (each Run knows its owner)

§Replanning

When a Run fails or the agent determines the plan needs revision, a new Plan revision is created. The Task stays the same — it is the stable identity for the work. Only the strategy (Plan) evolves:

Task (constant)                Intent (constant, plan updated)
  │                              └─ plan ──▶ Plan_v2 (latest)
  └─ runs:
       Run₀ ──plan──▶ Plan_v1   (snapshot: original plan)
       Run₁ ──plan──▶ Plan_v2   (snapshot: revised plan)

§Purpose

  • Stable Identity: The Task persists across retries and replanning. All Runs, regardless of which Plan version they executed, belong to the same Task.
  • Scope Definition: constraints and acceptance_criteria define what the agent must and must not do, and how success is measured.
  • Hierarchy: parent enables recursive decomposition — a PlanStep can spawn a sub-Task, which in turn has its own Plan and Runs.
  • Dependency Management: dependencies enables ordering between sibling Tasks (e.g. “implement API before writing tests”).

Structs§

Task
A unit of work with constraints and success criteria.

Enums§

GoalType
Classification of the work a Task aims to accomplish.
TaskStatus
Lifecycle status of a Task.