Tasks

This page defines the current contract for managed task execution: lifecycle, terminal re-entry, and supervision surfaces.

Last verified: 2026-05-25 against src/types.rs TaskRecord, TaskStatus, TaskKind, TaskHandle, TaskWaitPolicy, and the tool implementations in src/tool/tools/{exec_command,task_list,task_status, task_output,task_input,task_stop,spawn_agent}.rs.

Source RFCs

Task kinds

TaskKindDescription
CommandTaskShell command execution via ExecCommand
ChildAgentTaskParent-supervised delegated child agent via SpawnAgent
SleepJobInternal sleep timer (not model-visible)
SubagentTaskLegacy child agent kind (migrating to ChildAgentTask)
WorktreeSubagentTaskLegacy worktree-isolated child agent (migrating)

Task lifecycle

              ExecCommand / SpawnAgent
                       │
                       ▼
                 ┌──────────┐
                 │  Queued  │
                 └────┬─────┘
                      │
                      ▼
                 ┌──────────┐     TaskStop
                 │ Running  │──────────────┐
                 └────┬─────┘              │
                      │                    ▼
          ┌───────────┼───────────┐  ┌────────────┐
          ▼           ▼           ▼  │ Cancelling │
    ┌──────────┐ ┌──────────┐ ┌────┴─┴─────┐      │
    │Completed │ │  Failed  │ │Interrupted│      ▼
    └──────────┘ └──────────┘ └───────────┘┌──────────┐
                                           │Cancelled │
                                           └──────────┘

Terminal states: Completed, Failed, Cancelled, Interrupted. Non-terminal states: Queued, Running, Cancelling.

Wait policy

Each task carries a wait policy for task-list and task-status compatibility:

TaskWaitPolicyBehavior
BackgroundTask runs independently; agent can continue turns while task is active

All current task kinds report Background. Historical task detail payloads may still contain wait_policy: "blocking", but the runtime ignores that value for scheduler blocking decisions.

Key contract:

Supervision tools

ToolPurpose
TaskListCompact active-task digest (non-terminal tasks only)
TaskStatusSingle-task lifecycle snapshot with metadata
TaskOutputBounded output preview with optional block=true
TaskInputSend stdin/follow-up input to an interactive task
TaskStopStop a running task (may transition through Cancelling)

Key contract:

Distinction from WorkItems and waiting

Tasks are execution handles, not planning objects:

Tasks often serve WorkItem objectives (running commands, delegating to child agents), but task lifecycle is independent of WorkItem lifecycle.

Resolved gaps