Skip to main content
Use subagents to delegate focused research, code reviews, debugging, or parallel edits to separate background sessions without crowding your main conversation. No extra package installation is needed. For writing custom agent definitions, see Create custom subagents. For exact discovery rules, model fallbacks, and config.json keys, see Subagent reference. The following table helps you choose between working in main chat and delegating to a subagent: Every subagent runs in the background. Let completion notices report back instead of polling, and call subagent({ action: "wait", id }) only when your next step depends on the result.

Start with plain language

To delegate work in chat, describe the goal, boundaries, and verification check in plain language. Atomic picks the specialist and execution shape (single subagent, parallel batch, or forked context) for you. For example, ask Atomic to map a subsystem before editing:
To run several independent review passes in parallel:
To check external library behavior against local code:

Bundled agents

Atomic ships nine bundled specialists. All of them use model: "auto" with no pinned fallback chain. You can pin a role persistently in settings.json under subagents.agentOverrides.<name>.model or per call with model. A concrete model runs only that model and the agent’s own fallbackModels (see Fallback models). The following table lists each bundled agent, its default context, whether it edits files, and its preloaded skills: worker also enables defaultProgress: true (isolated run-scoped progress.md), inheritProjectContext: true, and inheritSkills: false.

Browse agents with /agents

To inspect active agents in an interactive session, run /agents (or /agents <filter>). Atomic groups definitions in precedence order: Project, User, Built-in, and Package. Use these keys in the browser:
  • Type to filter by name, description, or source.
  • Select an agent and press Enter to inspect its model, fallbacks, default context, tools, file path, and system prompt.
  • Press Esc to return to the list, then again to return to chat.
/agents is read-only: it never launches or edits agents, and it hides shadowed or disabled definitions so the view matches runtime precedence. Leaving /agents open never marks Herdr as blocked. Outside interactive mode, run subagent({ action: "list" }). Unlike /agents, action: "list" hides overridden package agents while still showing shadowed user or built-in definitions alongside project overrides.

Compose review panels

You can combine specialists from distinct angles and synthesize their findings in your main session. The following table maps common review angles to bundled specialists: For example, ask Atomic to run a three-angle diff review:

Context and Git worktrees

Choose the right context mode and Git worktree isolation before launching writers or independent reviewers.

Fresh versus forked context

  • context: "fresh" starts an isolated child session with only the agent’s prompt and task. Use fresh for independent research and adversarial reviews.
  • context: "fork" branches from your main session’s latest settled turn. It fails fast if the main session can’t be forked (for example, an empty session with no settled turn) instead of downgrading silently to fresh. A forked subagent inherits the main session’s model, thinking level, active tool changes, and saved tool outputs without taking over other subagents or replaying Intercom cards.
If you omit context on a parallel tasks batch and any agent declares defaultContext: fork (such as worker), the entire batch runs in forked context. Pass context: "fresh" explicitly when you want fresh-context siblings alongside worker, or launch worker in a separate call.
Use fork when a subagent needs decisions already made in your main chat. A forked subagent sends the exact prefix the main session last sent (system prompt, project context, skills, tools, and messages), followed by its own role, a brief handoff note, and its task. On the same model and thinking level, its first request reuses the main session’s prompt cache and pays only for the new suffix. On another model or provider, it doesn’t share that cache; on another thinking level, it might share only part of it. In a fork, inheritProjectContext and inheritSkills don’t hide what the main session already sent; those flags apply only to fresh subagents. A subagent’s own tool allowlist still applies: calling a disallowed tool returns an error naming the allowed tools, and child-only tools not exposed directly run through codemode restricted to the subagent’s allowed tools. Fresh subagents inherit the main session’s model registry, authentication, and workspace discovery settings. A subagent’s tool list can only narrow permissions, never widen them beyond the main session.

Temporary worktrees

To isolate each parallel writer in a disposable Git worktree, pass worktree: true on a parallel tasks call:
Temporary worktrees follow these rules:
  • Parallel mode only. Atomic creates temporary worktrees only for parallel tasks: [...] batches (or multiple single-agent calls emitted in one assistant message). On a standalone { agent, task } call, worktree: true has no effect; use worktree: { branch } instead.
  • Clean tracked tree required. Launch fails before starting any subagent if tracked files have staged or unstaged edits (git status --porcelain --untracked-files=no). Untracked files don’t block launch.
  • Base branch. Temporary worktrees branch from origin/<default-branch> (fetching if needed), falling back to HEAD when no origin default branch exists.
  • Automatic post-creation setup. After creating each worktree, Atomic copies .atomic/settings.local.json and any untracked .atomic/settings.json, shares .husky or .git/hooks through core.hooksPath, symlinks (or creates a Windows junction for) node_modules, copies gitignored files listed in .worktreeinclude, and runs worktreeSetupHook if configured in subagent config.json.
  • Shared cwd. Every task in a worktree: true batch must share the same cwd; per-task cwd overrides that differ are rejected.
  • Patch capture and cleanup. After every subagent in the batch finishes, Atomic saves each subagent’s changes as a patch under worktree-diffs/<run-id> and removes the temporary worktrees and branches. If patch capture fails for a worktree, Atomic keeps that worktree on disk and reports it in the diff summary.
  • Paused, quit, and cancelled subagents. Paused, quit, or session-closed subagents keep their temporary worktree only if it has uncommitted changes, untracked files, or new commits. Clean worktrees are removed; resume recreates them from base plus the saved patch (task-<n>-<agent>.<execution>.patch). Permanently cancelled subagents release their worktrees, while unresumed stopped worktrees with changes remain under .atomic/worktrees/.
  • Waiting on cleanup. pause, quit, completion, and failed resume wait for Git cleanup. Pressing Esc stops waiting without cancelling cleanup; cleanup lasting over 10 seconds warns and continues in the background. Don’t delete a worktree directory while cleanup is finishing, a sibling holds the batch, or a Git process is still running.
  • Git hook integration. Git hooks can check ATOMIC_SUBAGENT_WORKTREE_PHASE=finishing during teardown, and extensions can subscribe to subagent:finishing (see SDK integration and errors).

Named worktrees

To run a single subagent or specific parallel tasks on a permanent branch and directory, pass worktree: { branch, base?, path? }. You can’t combine named worktrees with worktree: true. A top-level named worktree object applies to every task in tasks that doesn’t set its own worktree. The following calls create named worktrees for single and parallel runs:
Named worktrees differ from temporary worktrees in five ways:
  • No clean-tree requirement or automatic setup. Named worktrees work with dirty local checkouts. They don’t symlink node_modules, copy settings or .worktreeinclude files, set core.hooksPath, run worktreeSetupHook, or save diff patches.
  • Permanent ownership. Atomic never deletes a named worktree or its branch. Resuming reuses the worktree, or checks the branch back out there if it was removed.
  • Branch and path rules. path defaults to .atomic/worktrees/<branch> (/ replaced with +). Relative paths resolve against the caller’s cwd, and an existing empty directory at path is allowed. New branches use --no-track and start from base, then @{upstream}, then HEAD. Atomic uses unused existing branches as-is and reuses a branch already checked out at path. Launch fails fast if the branch is checked out elsewhere or path contains something else.
  • Subdirectory cwd. If your session runs inside a repository subdirectory, the subagent starts in that same subdirectory inside the worktree (falling back to the worktree root if absent on the branch).
  • Concurrency and hooks. Different branches and paths run concurrently. Duplicate (branch, path) launches wait and reuse; the same branch at a different path fails after the first finishes. A checkout hook can’t synchronously create another named worktree for the same branch or path (WorktreeReentryError). Prefer worktree: { ... } over running git worktree add alongside subagents in the same turn.
Recover an interrupted named-worktree checkout. External Git locks time out after 30 seconds (another git process seems to be running at <path>), and an interrupted prior checkout fails immediately (an interrupted named-worktree checkout left an incomplete worktree at <path>). To recover, confirm no Git process is running, back up any needed files, run git worktree unlock PATH, remove the directory, run git worktree prune, and clear stale HEAD.lock or branch .lock files (or run git worktree remove --force --force PATH). Never fix a partial checkout by deleting only index.lock.

Background launches and waiting

Every subagent launch runs in the background and returns immediately with each subagent’s taskId and intercomTarget (for example subagent-worker-1a2b3c4d-1). Use intercomTarget verbatim when messaging a subagent. Subagents return their results directly. Atomic doesn’t infer acceptance gates, so put required tests, commands, or evidence checks directly in the task prompt. The following examples launch a subagent, wait up to two minutes for its result, and check its status:
Replace the following:
  • TASK_ID: The taskId returned by the launch (for example task-1-0-2).
Keep these launch and wait behaviors in mind:
  • Waiting. subagent({ action: "wait", id: "<taskId>", budgetMs? }) observes an existing task launched by this session for up to budgetMs milliseconds (default 30000 ms). Ending a wait on budget, pressing Esc, user steering (input-needed), or an inbound Intercom message (intercom-coordination) leaves the subagent running. Wait again when you need its result (see Observation and wait matrix).
  • Repeating tasks (count). In parallel tasks, set count (integer >= 1) on an item to repeat it N times. Expanded items count toward parallel.maxTasks.
  • Concurrency. Multiple single-agent calls emitted in one assistant message combine into one parallel run sharing concurrency (shared options must match across those calls; prefer one explicit { tasks: [...] } call). Returning from launch or ending a wait doesn’t free a running slot.
  • Heartbeats. Running subagents send task heartbeats every 15 minutes by default. Override with heartbeatMs (0 disables; minimum 60000 ms).
  • Read directives (reads). reads doesn’t inline file contents. Instead, it prepends [Read from: <abs-path>, ...] (resolved relative to the child’s cwd) to the prompt so the subagent reads those files with its own tools. Single-agent mode accepts an array of paths or false (reads: true is rejected and frontmatter defaultReads isn’t applied). Parallel tasks[] uses defaultReads when reads is omitted or true, and disables it on reads: false.
  • Output files (output and outputMode). When output is set, Atomic injects **Output:** Write your findings to: <path>. If the subagent writes or updates that file, Atomic reads it back; otherwise Atomic writes the subagent’s final text there (creating parent directories). Pass output: true to use frontmatter output, or output: false (or "false") to disable it. outputMode: "file-only" requires an output path and returns only the saved-file reference inline on success (failures still return inline details). Duplicate output paths in one parallel batch are rejected.
  • Progress files (progress and includeProgress). progress: true creates an isolated run-scoped progress.md in an artifacts directory outside your repository and child cwd. Omitting progress inherits defaultProgress, suppressed automatically when the prompt uses read-only phrasing (review-only, no edits, do not edit, or leave files unchanged). includeProgress: true adds progress telemetry only on direct blocking SDK runs without a background task host.
  • Settled output. wait and status return up to 16 KB inline, plus Full output: <path> (Atomic keeps the 256 most recent copies in a private temporary directory cleaned on exit) and Requested output: when output was set.
  • Startup progress and retries. Before a subagent’s first turn, status reports its exact startup step (opening its session, loading its resources, waiting for a session-startup slot, creating its agent session, registering on Intercom, or dispatching its task) with elapsed time. If startup exceeds sessionStartTimeoutMs (default 5 minutes), Atomic marks the attempt stalled and retries once after releasing its session (failing without retry if the stalled attempt still holds its session after half the budget, capped at 30 seconds).
  • Session close and reopen. Closing a session stops running subagents; reopening the same session restores them automatically.

Inspect and switch to tasks

Run /tasks (or /tasks <taskId>) or press ↓ on an empty prompt to focus the agent panel under the prompt. From either view you can monitor running, waiting, and finished subagents and their nested shells:
  • Switch to a subagent. Select a subagent row and press Enter (or click it) to view its live transcript and message it on the shared chat screen. Press ← on an empty prompt or select main in the panel to return without interrupting the subagent.
  • Pause or stop. While viewing a working subagent, press Esc (or Ctrl+C on an empty prompt) to pause its active turn without affecting main chat. In /tasks or the agent panel, press x twice within three seconds to stop a running task resumably, or x once to dismiss a finished row.
  • Subagent shells and questions. Running subagent shells nest beneath their subagent in the agent panel. A subagent’s ask_user_question or approval dialogs wait inside its own transcript (Needs input) without blocking main chat.
  • Launch cards and history. Each subagent renders Agent(<agent> · <short task title>) (Ctrl+O expands prompt, tool calls, and result). Atomic keeps live status for the 256 most recently finished runs plus all active runs; older subagents stay resumable with subagent({ action: "resume", id }).
For the full panel layout, keybindings, and slash-command routing, see Manage background tasks and Background tasks reference.

Run control

Use pause, quit, and resume to control subagent runs. The id parameter accepts a child ID (<runId>:<index>), task ID, Intercom name, or single-child run ID. The following examples show common run-control calls:
Replace the following:
  • CHILD_ID: The subagent’s child ID, task ID, or Intercom name.
Run control follows these rules:
  • pause. Stops the active turn and keeps queued steering or follow-up messages to deliver once in order before resume’s message. Intercom messages to a paused subagent don’t resume it; they wait without expiry and arrive after resume’s message.
  • quit. Stops the subagent gracefully, including already-paused subagents, while keeping it resumable.
  • Awaiting resume. Completion notices show paused · awaiting resume or quit · awaiting resume with Stop reason: pause or quit and the exact resume call. subagent({ action: "status" }) lists them under Awaiting resume across restarts without auto-relaunching.
  • Queued parallel subagents. You can pause or quit a subagent still waiting for a concurrency slot. Calling resume starts it with its original task, optional message, model, thinking level, worktree, and fork copy, re-entering the concurrency queue (or reporting it gone if its model or fork copy no longer exists).
  • resume. Continues the subagent’s saved session under the same child ID, Intercom name, and group (all: true isn’t supported). For paused, quit, or interrupted subagents, message runs before continuing; for completed or failed subagents, message starts a fresh turn. Omitting message prompts the subagent to continue or stop if done.
  • Resumable versus terminal. Paused, quit, interrupted, completed, failed, and session-closed subagents are resumable. Killed (explicit cancellation) and Gone (unrestorable after restart) subagents are terminal and reject resume. Running subagents reject resume—pause or quit them first, or message them through Intercom. Failed resumes keep worktree: true checkouts intact.
  • Interrupting control calls. Pressing Esc stops waiting on pause, quit, or resume. Already-requested stops finish, and unstarted resumes cancel cleanly.
  • Removed actions. kill and interrupt were removed; calls fail and point to { action: "quit", id }.
When an expand hint appears after resuming a subagent, press Ctrl+O (or your custom expand binding) to inspect what happened, the task ID, and any message sent.

Messages that resume a finished subagent

Any session allowed to message a subagent under Intercom group and reach rules can wake it. A single-target intercom send or ask to a completed or failed subagent returns immediately with queued: true, and the launching session resumes the subagent to handle the message. Calling subagent({ action: "resume", id: "<intercom-name>", message }) for a subagent launched by another session sends message through that same wake queue. Messages to a paused or quit subagent wait in a durable queue without resuming it until the launching session continues it. Message-triggered resumes are capped at six resumes in 10 minutes and chain depth 4 (see Messages that resume a finished subagent).

Released subagents

A background subagent that waits more than one minute on a long-running detachable external tool call (such as a continuous integration (CI) run or deploy tool marked detachable), a budgetless shell wait, an intercom ask, or a blocking contact_supervisor (need_decision or interview_request) is released. The waited operation keeps running while the subagent frees its session resources and wakes automatically when the result arrives. Released subagents behave as follows:
  • What you see. Main chat displays a dim notice (◌ <name> is waiting on <tool> (<call id>)) without starting a model turn. /tasks, the agent panel, and the launch card list it under Waiting with ◌. subagent({ action: "status" }) reports released · waiting on <tool> (<call id>).
  • Inspecting, waking, or holding. Opening a released subagent shows its saved transcript without waking it. Press Alt+W (or click · alt+w opens it) to inspect its newest waited shell in /tasks. Sending a message in its view, sending an Intercom send or ask, or calling resume wakes it immediately. Pressing x twice or calling pause or quit disables auto-wake and holds arriving results until you resume.
  • Late results and crash recovery. If something else wakes the subagent first, the waited call returns as still running and its late result arrives later as a notice card inside the subagent’s chat. Queued messages persist before wake so nothing is lost on crash. On reopen after a restart, detachable external calls re-run with the same call IDs and arguments; local Intercom asks time out while multi-node database asks stay open. At most parallel.runningCapacity released subagents wake concurrently.
For error codes reported when tracking or waking a released subagent fails, see Released subagent error codes.

Automatic restore and session storage

If Atomic exits, crashes, or switches sessions (/new, /resume, /fork), running subagents stay resumable and relaunch automatically when you reopen the launching session. They keep their Intercom name, group, model, thinking level, original agent definition, forked context, and unread queued messages. Finished, paused, quit, and permanently cancelled subagents don’t auto-relaunch, and session forks (/fork, --fork) never relaunch the original session’s subagents. If a subagent can’t be restored, Atomic posts one recovery notice with its IDs, worktree or branch, git inspection commands, and relaunch call, then marks it gone. Every subagent stores its session in the launching session’s own session storage (local SQLite by default, shared PostgreSQL, JSON Lines (JSONL) directory, or in-memory), regardless of cwd, worktrees, forks, or codemode launches. Subagents resume, wake, and export wherever the launching session opens, including another machine sharing the same database:
  • Visibility and history://. Subagent sessions are marked internal, so /resume, atomic -r, -c, and history://sessions omit them. You can still read a subagent session directly with history://sessions/<sessionId> (add ?project=<dir> if it ran in another directory or worktree). In SQLite and PostgreSQL session storage, forked subagents share their parent’s conversation history instead of copying it (see Shared-history forks).
  • Unsaved sessions. Sessions started with --no-session or in-memory session storage keep subagent sessions in memory and move finished transcripts to a temporary file cleaned on exit.
  • Worktree snapshots. When worktree snapshots are enabled, subagents record snapshots of checkouts they modify so reopening restores the newest state cleanly.

Coordination and swarms

Subagents coordinate directly with each other over Intercom and escalate scope decisions to the launching supervisor.

Supervisor coordination

By default (intercomBridge.mode: "always" in config.json), Atomic injects both intercom and contact_supervisor into every subagent whose launching session has Intercom active. Tool frontmatter controls Intercom availability alone only when intercomBridge.mode is "off" (or "fork-only" for fresh subagents). A subagent without read or search also receives a read-only session_history tool after compaction to recover its own history (see Agents without read or search). Supervisor coordination follows these rules:
  • Decision waits versus intercom ask. contact_supervisor({ reason: "need_decision", message }) and interview_request wait inside the requesting subagent and continue that same subagent when you answer with intercom({ action: "reply", message: "..." }) (use pending and replyTo when multiple asks are open). Never relaunch a subagent just to answer it. By contrast, intercom ask returns at delivery and delivers late replies as messages.
  • Non-blocking updates. intercom send and contact_supervisor({ reason: "progress_update", message }) return immediately without interrupting siblings or worktrees.
  • Messaging a running subagent. Subagents register on Intercom before their first turn. Address a subagent by its intercomTarget or ID from intercom list, and set delivery to "steer" (default), "followUp", or "interrupt" (see The intercom tool).
  • Embedded SDK sessions without background task management. When an SDK host runs a single subagent directly without a background task host, subagent blocks until completion and a blocking contact_supervisor ends the subagent with [TASK_CONTEXT] so the caller can launch a fresh subagent with the supervisor’s answer.

Peer coordination

Peer-to-peer coordination is the default. Siblings in a parallel batch—or sharing an explicit group—discover each other with intercom({ action: "list" }) and communicate directly with send and ask instead of routing peer updates through the supervisor. Use peer coordination to share findings, divide file ownership or slow test runs, pass reproductions, and challenge disagreements with evidence. Each subagent still returns its own complete result. Reserve contact_supervisor for supervisor decisions. Peer asks and one blocking supervisor ask can wait concurrently. Run /skill:intercom for peer patterns. The following parallel launch instructs three reviewers to coordinate findings directly over Intercom:

Scale a swarm

Tune parallel limits and group boundaries when running large subagent batches:
  • Parallel limits. parallel.maxTasks, parallel.concurrency, and parallel.runningCapacity each default to 1000 with no hard upper cap. Adjust all three in config.json to raise limits, or lower parallel.concurrency to throttle. Provider rate limits and host memory are the practical bounds.
  • Teams. Intercom groups have no member cap. Give each team a named group (or group: true for a unique shared universally unique identifier (UUID) group); members can still reach the supervisor through contact_supervisor.

Launch subagents from codemode scripts

When both codemode and subagent are active, tools.subagent() launches the same background subagents and resolves at admission, not completion. Admitted subagents belong to the main session and keep running even if the script returns, throws, or times out. Separate tools.subagent() calls aren’t merged automatically; pass tasks: [...] for a parallel batch. The following script launches two workers in a shared Intercom group and saves their launch receipts:
Single and parallel launches both return { action: "launch", tasks }. Each slot contains agent, state ("admitted", "queued", or "refused" with reason), taskId, childId, and intercomTarget when available. Don’t retry already-started siblings if one slot is refused. Keep these script-mode rules in mind:
  • Use id, not runId. Passing the legacy runId alias fails in codemode ("Use id instead of runId in subagent scripts."). In wait, budgetMs takes a finite non-negative number or plain decimal string such as "2000" (defaults to 30000 ms even when a host configures unlimited foreground waits; 0 checks immediately).
  • wait outcomes. wait returns outcome: "settled", "running", or "stopped-waiting" (when the script’s signal aborts; script timeouts cancel wait, not the subagent). On settled results, non-released pause and quit stops resolve to result.status: "paused" (with result.reason: "pause" or "quit"), while a released child resolves to result.status: "cancelled".
  • Inspect and control. Call list, get, models, status (reconcile children after reopening a session), and pause, quit, or resume with id (or all: true for pause and quit). Creating, updating, or deleting agent definitions requires a direct tool call.
  • Temporary worktrees. status can report finishing while wait still returns running. Check worktreeNote or worktreeNotes in script results before deleting any temporary worktree directory.

Configure defaults and start timeouts

Configure subagent runtime defaults in ~/.atomic/agent/extensions/subagent/config.json (falling back to ~/.pi/agent/extensions/subagent/config.json when the Atomic file is absent) and inspect scoped models with subagent({ action: "models" }). Subagents enforce your active enabledModels / --models / /scoped-models scope and skip providers without credentials before launch. For every config.json key, model resolution rule, fallback chain, and tool parameter, see Subagent reference.

Subagent start timeouts

Subagents have a five-minute (300000 ms) startup budget covering session open, resource load, agent session creation (including slot wait), and task dispatch. Queue wait under parallel.runningCapacity doesn’t count. To raise the startup budget, set sessionStartTimeoutMs (1 to 2147483647 ms) in ~/.atomic/agent/extensions/subagent/config.json:
Exceeding the budget fails with SessionStartTimeoutError (shown in status and serialized as startError for SDK callers). The following table lists each failure phase and recovery action: For SDK configuration (createAgentSession, builtins: { subagents: false }, excludedTools: ["subagent"], humanInput) and error rehydration, see Subagent children in the SDK and Session start errors.

Delegation boundaries

Delegation is fixed at one level: only the main session can launch, pause, resume, or quit subagents, and restricted subagents can’t create, update, or delete agent definitions. Subagents can still run background shells (nested beneath them in the agent panel) and inspect status with list, get, status, and wait. Subagent prompts omit parent orchestration artifacts and prior control traffic.
Removed acceptance-gate fields. Older calls or agent files that passed acceptance or completionGuard: false should remove them (tool-based updates strip completionGuard automatically) and put required tests, commands, or evidence checks directly in the task prompt.

Troubleshoot subagents

The following table lists common subagent launch and control issues and how to fix them:

Next steps

Create custom subagents

Define custom Markdown agents, YAML frontmatter fields, and built-in overrides.

Subagent reference

Discovery precedence, automatic model selection, fallback models, config.json, and tool parameters.

Manage background tasks

Agent panel, /tasks, steering, stopping work, and task heartbeats.

Orchestrate multi-step work

Coordinate parallel subagents from codemode and recover cleanly after interruptions.