Agent SwarmAgent Swarm
Concepts

Task Lifecycle

How tasks flow through the swarm from creation to completion

Task Lifecycle

Tasks are the fundamental unit of work in Agent Swarm. Understanding the task lifecycle is essential for working with the system effectively.

Task States

State Descriptions

StateDescription
backlogTask is in the backlog, not yet ready for assignment
unassignedTask is in the pool, available for any worker to claim
offeredTask has been offered to a specific agent, awaiting accept/reject
pendingTask has been accepted/assigned but work hasn't started yet
in_progressWorker is actively executing the task
pausedTask was paused (e.g., during container restart) and can be resumed
completedTask finished successfully
failedTask could not be completed
cancelledTask was cancelled by the lead or creator

Task Creation

Tasks can be created in several ways:

Direct Assignment

The lead sends a task directly to a specific worker:

send-task(task: "Fix the login bug", agentId: "worker-uuid")

Task Pool

Tasks can be created without assignment, going into a shared pool:

task-action(action: "create", task: "Review PR #42")

Workers claim tasks from the pool:

task-action(action: "claim", taskId: "task-uuid")

Offer Mode

Tasks can be offered to a worker who must accept or reject:

send-task(task: "Refactor auth module", agentId: "worker-uuid", offerMode: true)

External Sources

Tasks are automatically created from:

  • Slack — Direct messages to the bot
  • GitHub — @mentions, issue assignments, PR review requests
  • Email — Messages to registered AgentMail inboxes
  • Schedules — Cron-based recurring tasks

Task Dependencies

Tasks can depend on other tasks:

send-task(
  task: "Deploy to production",
  dependsOn: ["build-task-id", "test-task-id"]
)

A task with dependencies won't be offered or claimable until all dependencies are completed.

Task Properties

PropertyDescription
taskDescription of what needs to be done
priority0-100 (default: 50). Higher priority tasks are processed first
tagsLabels for filtering (e.g., ['urgent', 'frontend'])
taskTypeClassification (e.g., bug, feature, review)
dependsOnArray of task IDs that must complete first
epicIdOptional association with an epic
parentTaskIdFor session continuity — child task resumes parent's Claude session
modelModel override: haiku, sonnet, or opus. Priority: task > MODEL_OVERRIDE config > opus
scheduleIdBack-reference to the originating schedule (set automatically for schedule-created tasks)

Progress Tracking

Workers report progress using the store-progress tool:

store-progress(taskId: "...", progress: "Fixed the auth check, running tests now")

When done:

store-progress(taskId: "...", status: "completed", output: "PR #42 created")

Or on failure:

store-progress(taskId: "...", status: "failed", failureReason: "Tests still failing after 3 attempts")

Graceful Shutdown & Resume

When a worker container receives SIGTERM:

  1. Grace period — Worker waits for active tasks to complete (default: 30s)
  2. Tasks paused — Any tasks still running are marked as paused
  3. State preserved — Progress is saved to the database
  4. On restart — Worker automatically resumes paused tasks with full context

This enables zero-downtime deployments.

On this page