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.rsTaskRecord,TaskStatus,TaskKind,TaskHandle,TaskWaitPolicy, and the tool implementations insrc/tool/tools/{exec_command,task_list,task_status, task_output,task_input,task_stop,spawn_agent}.rs.
Source RFCs
- Command Tool Family
- Task Surface Narrowing
- Interactive Command Continuation
- Agent Delegation Tool Plane
- Agent Control Plane Model
- Runtime Scheduler Contract
Task kinds
TaskKind | Description |
|---|---|
CommandTask | Shell command execution via ExecCommand |
ChildAgentTask | Parent-supervised delegated child agent via SpawnAgent |
SleepJob | Internal sleep timer (not model-visible) |
SubagentTask | Legacy child agent kind (migrating to ChildAgentTask) |
WorktreeSubagentTask | Legacy 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:
TaskWaitPolicy | Behavior |
|---|---|
Background | Task 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:
- For background tasks, use
WaitFor(wake=task_result, resource=<task_id>)to wait for the terminalTaskResultinstead of pollingTaskOutput. - The terminal
TaskResultevent re-enters the agent as continuation context; the runtime wakes the agent automatically. TaskOutput(block=true)is for explicit current-turn synchronous waiting, not the default waiting strategy.
Supervision tools
| Tool | Purpose |
|---|---|
TaskList | Compact active-task digest (non-terminal tasks only) |
TaskStatus | Single-task lifecycle snapshot with metadata |
TaskOutput | Bounded output preview with optional block=true |
TaskInput | Send stdin/follow-up input to an interactive task |
TaskStop | Stop a running task (may transition through Cancelling) |
Key contract:
TaskListexcludes terminal tasks; useTaskStatusfor historical detail.TaskOutputreturns a boundedoutput_previewplus artifact refs for full output; it is for inspection, not polling.TaskInputaccepts input only for tasks created with interactive continuation enabled (accepts_input=true).TaskStopsends a stop request; the task may first enterCancellingbefore reachingCancelled.
Distinction from WorkItems and waiting
Tasks are execution handles, not planning objects:
- A
Taskrepresents a running or queued execution unit. - A
WorkItemrepresents a durable objective the agent is working toward. Waitingrepresents why a WorkItem or agent cannot proceed.
Tasks often serve WorkItem objectives (running commands, delegating to child agents), but task lifecycle is independent of WorkItem lifecycle.
Resolved gaps
- Issue #1382 removed the
unused
Blockingtask wait policy from the public/runtime contract. Waiting is expressed withWaitFor(wake=task_result)plus terminal task re-entry, or with a boundedTaskOutput(block=true)call inside the current turn.
