← Documentation indexdocs/tasks-and-automation.md

Durable tasks and scheduled work

This guide describes resumable work recorded by the local runtime. A normal chat turn and a durable task have different lifecycle rules: accepting a plan or requesting queued work creates a task with explicit progress and evidence rather than treating an unfinished reply as success.

Task lifecycle

  1. Prepare: Ask/Plan gathers context and proposes a bounded task. The user accepts the plan or explicitly requests Agent work.
  2. Run: The task manager claims work under its scope, records tool calls and other evidence, and returns control between actions for approvals and cancellation.
  3. Verify: A task is complete only when its completion contract has observable evidence. Coding work needs an acceptance command or test result; research needs its requested sources and output. A tool call that returns successfully is not by itself proof that the goal succeeded.
  4. Recover: Pending tasks can be resumed after restart. Interrupted sub-agent assignments are reported and mutations are not replayed automatically. Reconcile current files and receipts before retrying any interrupted side effect.

Task IDs and records are actor/workspace/session scoped. The web task API exposes list/create/resume operations; the runtime inventory gives exact routes. In the TUI use /tasks to inspect progress and /agents for delegated jobs. Cancellation stops subsequent sub-agent tools between tool calls; it cannot undo an external effect that already occurred.

Simple work does not require a plan, and a plan is optional for medium work. Complex direct work uses a durable Working Plan with runtime-owned stable IDs and explicit acceptance criteria. The typed update_plan boundary applies revision-checked batches of add, update, cancel, reorder, dependency, split, merge, replace, block, and unblock operations; legacy complexity/tasks input is adapted through the same validation path. Splitting, merging, or replacing retains superseded tasks as cancelled history and records both directions of the relationship. Blocking requires a reason and prevents scheduling until explicitly unblocked with a reason. Each structural revision and its optional rationale are written atomically with a complete plan/task snapshot in the event history. A changed task must still be pending and unexecuted; executed task records and evidence are preserved. Scheduling follows plan order and waits for every dependency to succeed. A plan completes only when every task succeeds with acceptance evidence; recovery also reconciles a crash between the final task write and the plan status write. Clearing an active plan cancels its unfinished steps. The foreground scheduler runs consecutive calls concurrently only when every call is catalog-marked safe and read-only; all other calls preserve response order, and task receipts are reconciled in that order. Assistant answers remain available when a complex turn ends with unfinished work; its runtime outcome is reported separately as completed, incomplete, blocked, or cancelled. This outcome uses only that turn's Working Plan, so an unrelated task ledger cannot make a simple answer appear unfinished. The native foreground loop uses typed provider calls; the legacy text protocol remains available through its compatibility adapter.

In native Agent mode, the model can call the structured update_plan tool when its effective capabilities include write. Ask and Plan modes never receive that schema. Tool authorization still intersects the active capability token, and an accepted Strategic Plan remains bound to its objective, revision, paths, effects, and approval state; plan editing does not grant permission to perform the revised tasks.

Every native request includes a current tool list derived from the actual filtered schemas. It supersedes earlier request lists and separates current tools from declarations retained only to correlate historical replies. Required-plan exposure is temporary: creating and starting a Working Plan can expand the next request's tools; a completed plan leaves only confirmation exposure for that turn. Schemas define argument contracts, and neither current nor historical list membership bypasses workspace, capability, approval, or plan checks.

Native builtin discover_tools calls retain their global receipts but do not establish a task execution contract or supply task completion evidence.

Create, start, and verify a Working Plan

For Git history, start an inspection task and use discover_tools if Git tools are absent from the current list. Once git_log identifies the commit, an ordinary verification task can use git_show with that commit hash in its typed acceptance. The selected task completes when the exact read succeeds.

New tasks omit id; the runtime allocates their durable IDs. In the compatibility complexity/tasks form, a supplied task.id must already belong to the active plan. Do not mix that form with operations, plan_id, expected_revision, or reason. To create a canonical plan, omit plan_id and set expected_revision to zero. Later edits use the latest returned plan_id, revision, and task IDs. An add.ref is only a local reference for later operations in the same batch.

For example, these update_plan arguments create and explicitly start a read task:

{
  "complexity": "simple",
  "expected_revision": 0,
  "operations": [
    {
      "op": "add",
      "ref": "inspect",
      "task": {
        "description": "Inspect notes.txt for the requested ready marker",
        "acceptance": [
          {
            "criterion": "notes.txt contains the requested marker",
            "verification": {
              "action": "read_file",
              "arguments": {"path": "notes.txt"},
              "expect": {"contains": "ready"}
            }
          }
        ]
      }
    },
    {"op": "start", "task": "inspect"}
  ]
}

Send the plan edit in its own response. Then call read_file separately with {"path":"notes.txt"}. start selects the runtime task before the read. An ordinary path-only criterion also accepts an authorized read with explicit limits when the returned content covers the whole file. Criteria that declare limits require those exact arguments. contains is a nonempty, case-sensitive substring predicate. Use "expect":{"equals":"ready\n"} when the returned content must equal that string, including whitespace. Every declared criterion needs matching evidence.

Read verification uses the successful typed result's complete data.content, with truncated exactly false. Display previews, metadata, truncated or malformed results, and prose-only acceptance do not certify the read. suggest_complete checks evidence already recorded; it never creates evidence or makes an unverified task succeed. Matching receipts can complete the plan automatically. A later batch containing only suggest_complete can then confirm its verified succeeded tasks without changing the plan, tasks, or revision. Send only the three top-level keys plan_id, expected_revision, and operations for this completed-plan confirmation. Omit reason, complexity, tasks, and all other metadata; a snapshot's reason describes the saved plan revision and is not a confirmation argument. The bounded pinned context keeps the current scoped completed plan's IDs, revision, and task statuses visible after earlier tool replies are archived; it does not replay every old result. Use those current runtime-returned IDs and revision; stale, historical, cancelled, or unverified targets are rejected, as are batches requesting other edits. This read-only confirmation is distinct from a new plan commit and cannot erase a failed transaction or complete unrelated work in a later turn. An executed task with the wrong action/argument contract must be cancelled and replaced rather than rewritten to fit later receipts.

An ordinary Working Plan task can declare a command check with a criterion and a verification object whose action is run_cmd and whose arguments match the planned command exactly. Start the task before running the check. The runtime requires a successful receipt with a verified zero exit status. A reproduction that exits nonzero remains evidence of the bug and requires a separate successful check to verify the fix.

A builtin input error rejected before any plan transaction may be corrected by a later successful plan edit in the same turn. It stops blocking turn completion only after the same scoped, nonempty Working Plan completes with verified task evidence; the failed receipt remains in history. A transaction attempt, including a rollback or unknown/post-commit outcome, is never treated as this no-effect input correction. Denials and failed reads or effects retain their failure evidence.

The TUI and Web chat show the current Working Plan revision, its user-facing revision reason, and tasks in scheduler order. Progress is updated from typed task events; successful tasks are shown as verified, and cancelled replacements remain marked as superseded. The Web view restores the active plan snapshot when a saved session is reopened. These observer projections contain task descriptions, statuses, supersession links, and rationale only; execution evidence and tool arguments remain private.

The tool executor makes at most one automatic retry, and only when a typed error marks a normal-risk read or an allowlisted built-in network lookup as retriable. It rechecks task binding and child cancellation before dispatching the retry. Filesystem, process, Git, stateful, custom network, and other mutation-capable calls are never automatically retried. After interruption or restart, unfinished side effects remain uncertain; inspect the current workspace and recorded receipts before requesting the mutation again.

Plan Mode can produce a versioned Strategic Plan before execution. Acceptance records the exact objectives, acceptance criteria, workspace paths, capabilities, effect categories, and risk ceiling alongside its linked Working Plan. A step may also carry a visible, fingerprinted execution contract for one exact write_file, edit_file, or apply_patch call; delegated file mutations require this explicit contract and still pass assigned-file, workspace-bound, and tool-approval checks. apply_patch requires the hash from a structured read and ordered {old_text, new_text} hunks, each matching exactly once without overlap. Each criterion should include a verification action and exact object arguments. A read_file verifier must also include one case-sensitive expect predicate (equals or nonempty contains); the returned text must satisfy it before the criterion is recorded. Plain-text criteria remain readable for legacy proposals but cannot satisfy the per-criterion completion gate without a verifier. Runtime tool dispatch checks each tool's catalog policy and supplied paths against those accepted bounds; shell processes are denied because this runtime cannot confine arbitrary commands to those paths. An unbounded legacy proposal receives read-only defaults. Strategic acceptance does not grant capabilities, bypass tool approvals, or establish completion evidence.

For a typed plan step, include an optional execution object with the canonical tool action and object arguments. Native tool calls associate with a task only when the runtime receives that task's explicit ID; matching action and arguments alone never select a task. A successful associated receipt may add execution evidence, but it cannot satisfy acceptance criteria by itself. A delegated assignment may carry that explicit Working Plan task ID; the parent records task evidence only after the independent review succeeds. The legacy text adapter retains its bounded matching behavior for compatibility. Plan IDs and task IDs are returned as structured result data so later updates can retain runtime-owned task identities.

Sub-agents

For a suitable multi-part request, the coordinator can assign independent work to specialist sessions, preserve parent scope, collect structured results, and conduct a read-only peer review. Concurrency is a number of parallel execution slots: the default is four; additional assignments queue. Per-role provider and model overrides do not inherit the main provider's generic key. Provider setup, authorization and failure handling are described in sub-agents.

Sub-agents share the parent's intended work context only through the declared assignment and permitted workspace. Their conclusions are evidence to evaluate, not an approval or permission token. Check /agents or the run detail route to distinguish complete, failed, cancelled and still-running assignments.

Scheduled jobs

The web runtime owns a scheduler for the supported named jobs, including learning cycles, chat jobs, and task-worker processing. Schedule metadata is stored locally and scoped to actor/workspace. Use /api/v2/schedules to inspect and create schedules; the matching disable route disables an existing schedule. The route list is generated in tool-inventory.md.

Scheduling needs the web process to be running. A durable schedule record does not mean the host is a guaranteed background service, and a stopped machine cannot run a job at its scheduled time. Check job state and application logs after a restart before interpreting a delayed run as a successful execution. Avoid creating duplicate external jobs when a prior run's outcome is uncertain.

Webhooks

The webhook routes let an authenticated server operator register a public HTTP(S) destination for allowed events. The current implementation allows chat.completed and test, caps registrations at 32, rejects URL credentials and obvious local/private IP or host names, and sets a five-second request timeout. A successful chat is not made to fail just because webhook delivery failed; failures are audited locally. The chat.completed body contains a bounded redacted reply summary, reply length, actor, session ID, profile, and streaming flag.

IP hostname checks cannot fully prevent DNS rebinding. Run with outbound firewall controls or an egress proxy when an attacker can control webhook registrations. Keep endpoints public and intentionally operated; do not register internal administration URLs. The registration API currently keeps its webhook list in the web service process, so treat registrations as process-local runtime state and re-check them after restart.

Inspect and recover

Use the web UI's task and agent panels, /api/v2/tasks, /api/v2/agents/runs, and /api/v2/agents/runs/{run_id} to inspect status. Correct an incomplete goal or replay a failed request only after reading tool receipts and checking whether its earlier actions took effect. See history and rollback for conversation restore and memory and storage for durable state.