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 a subagent’s result.
Start with natural language
Describe what you want delegated in plain language:Bundled agents
All bundled agents use
model: "auto" with no pinned fallback chain. Pin a role persistently via subagents.agentOverrides.<name>.model in settings.json or per call with model. A concrete model runs only that model plus the agent’s own fallbackModels (see Fallback models).
Bundled skills are preloaded by role: worker loads tdd, agent-browser, agent-desktop, herdr, tmux, qlty, and no-comments; debugger loads tdd, agent-browser, agent-desktop, herdr, tmux, qlty, how, why, show-me, and no-comments; code-simplifier loads tdd, qlty, no-comments, how, and why; codebase-analyzer loads how, why, show-me, and qlty; codebase-online-researcher and codebase-research-analyzer load how, why, and show-me; and codebase-locator, codebase-pattern-finder, and codebase-research-locator load how and why. worker also enables defaultProgress: true (isolated run-scoped progress.md), inheritProjectContext: true, and inheritSkills: false.
Browse agents with /agents
Run /agents (or /agents <query>) in an interactive session to inspect active agents grouped in precedence order: Project, User, Built-in, and Package.
- Type to filter by name, description, or source. Select an agent and press
Enterto inspect its model, fallbacks, default context, tools, file path, and system prompt. - Press
Escto return to the list, then back to chat.
/agents is read-only, never launches or edits agents, and hides shadowed or disabled definitions so it matches execution precedence. Outside interactive mode, call subagent({ action: "list" }) (note that action: "list" hides overridden package agents but still lists shadowed user or built-in definitions alongside project overrides). Leaving /agents open never marks Herdr as blocked.
Review compositions
Compose specialists from distinct angles and synthesize their findings in your main session:Context and Git worktrees
Fresh vs. forked context
context: "fresh"starts an isolated child session containing only the agent’s prompt and task. Usefreshfor adversarial reviews and independent research.context: "fork"branches from your main session’s latest settled turn and fails fast if the main session cannot be forked (for example, an empty session with no settled entry before the current turn — it never downgrades silently tofresh). A forked subagent inherits the main session’s model, thinking level, active tool changes, and saved tool outputs without taking ownership of the main session’s other subagents or replaying Intercom cards.
fork when a subagent needs the main conversation’s decisions and context. A forked subagent sends the exact conversation prefix the main session last sent (system prompt, project context, skills, tools, and messages), followed by its own role, a short handoff note, and its task. When it runs on the same model and thinking level, the first request reads from the main session’s prompt cache and pays only for the new suffix. On another model or provider it does not share that cache, and on another thinking level it may share only part of it.
In a fork, inheritProjectContext and inheritSkills do not hide what the main session already sent; those flags apply to fresh subagents. The subagent’s own tool allowlist still applies: calling a tool outside its allowed list fails with an error naming the allowed tools, and child-only tools not available directly run through codemode restricted strictly to the subagent’s own tools.
Fresh subagents inherit the main session’s model registry, authentication, and workspace discovery settings. A subagent’s tool list can narrow permissions, never widen them beyond the main session.
Temporary worktrees
Passworktree: true on a parallel tasks call to isolate each subagent’s edits in its own temporary Git worktree:
worktree: true:
- Parallel mode only. Creates isolated worktrees only for parallel
tasks: [...]runs (or multiple single-agent calls emitted in one assistant message). On a standalone single-agent{ agent, task }call,worktree: truehas no effect; useworktree: { branch }for an isolated single-agent worktree. - Clean tracked working tree required. Launch fails before starting any subagent if tracked files have staged or unstaged edits (
git status --porcelain --untracked-files=no). Untracked files do not block launch. - Base branch. Temporary worktrees branch from
origin/<default-branch>(fetching if needed), falling back toHEADonly if no origin default branch exists. - Automatic post-creation setup. After creating each temporary worktree, Atomic copies
.atomic/settings.local.jsonand any untracked.atomic/settings.json, shares.huskyor.git/hooksviacore.hooksPath, symlinks (or creates a junction on Windows for)node_modules, copies gitignored files listed in.worktreeinclude, and runsworktreeSetupHookif configured in config.json. - Shared
cwd. All tasks in aworktree: truebatch must share the samecwd; differing per-taskcwdoverrides are rejected. - Patch capture and cleanup. Once 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;
resumerecreates 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 (Escstops waiting without cancelling cleanup; cleanup over 10 seconds warns and continues in the background). Never delete a worktree directory while cleanup is still finishing, a sibling holds the batch, or an orphaned Git process is still running. - Git hook integration. Git hooks can check
ATOMIC_SUBAGENT_WORKTREE_PHASE=finishingduring teardown, and extensions can subscribe tosubagent:finishing(Subagent reference).
Named worktrees
Run a single subagent or specific parallel tasks on an explicit branch and directory withworktree: { branch, base?, path? }. Named worktrees cannot be combined with worktree: true. A top-level named worktree object applies to every task in tasks that does not set its own worktree.
- No clean-tree requirement and no automatic post-setup. Named worktrees work with dirty local checkouts and do not symlink
node_modules, copy settings or.worktreeincludefiles, configurecore.hooksPath, runworktreeSetupHook, 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 removed.
- Branch and path rules.
pathdefaults to.atomic/worktrees/<branch>(/replaced with+); relative paths resolve against the caller’scwd, and an existing empty directory atpathis allowed. New branches use--no-trackand start frombase, then@{upstream}, thenHEAD. Unused existing branches check out as-is, and a branch already checked out atpathis reused. Launch fails fast if the branch is checked out elsewhere orpathholds 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, while the same branch at a different path fails after the first finishes. A checkout hook cannot synchronously create another named worktree for the same branch or path (WorktreeReentryError). Preferworktree: { ... }over runninggit worktree addalongside subagents in the same turn.
Recovering 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
Everysubagent 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 does not infer acceptance gates, so put required tests, commands, or evidence checks directly in the task prompt.
- Waiting.
subagent({ action: "wait", id: taskId, budgetMs? })observes an existing task launched by this session up tobudgetMs(default30000ms). Ending a wait on budget, pressingEsc, 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 paralleltasks, setcount(integer>= 1) on an item to repeat it N times. Expanded items count towardparallel.maxTasks. - Concurrency. Multiple single-agent launches 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 does not free a running slot. - Heartbeats. Running subagents send task heartbeats every 15 minutes by default. Override with
heartbeatMs(0disables; minimum60000ms). - Read directives (
reads).readsdoes not inline file contents; it prepends[Read from: <abs-path>, ...](resolved relative to childcwd) to the prompt so the subagent reads those files with its own tools. In single-agent mode, pass an array of paths orfalse(reads: trueis rejected, and frontmatterdefaultReadsis not applied). In paralleltasks[], omittingreadsor passingreads: trueuses the agent’sdefaultReads, andreads: falsedisables it. - Output files (
output/outputMode). Whenoutputis set, Atomic injects**Output:** Write your findings to: <path>. If the subagent creates or modifies that file, Atomic reads it back; otherwise Atomic writes the subagent’s final assistant text to that path (creating parent directories). Passoutput: trueto use the agent’s frontmatteroutputdefault, oroutput: false(or"false") to disable it.outputMode: "file-only"requires anoutputpath and returns only the saved-file reference inline on success (failed runs or save errors still return inline details). Duplicateoutputpaths in a parallel batch are rejected. - Progress tracking (
progress/includeProgress).progress: trueenables an isolated run-scopedprogress.mdunder artifact storage (never inside childcwdor the repository). When omitted, Atomic inherits the agent’sdefaultProgress, suppressing it automatically if the prompt text uses read-only phrasing (such asreview-only,no edits,do not edit, orleave files unchanged).includeProgress: trueonly adds progress telemetry on direct blocking runs without a background task host; standard background launches return at admission. - Settled output.
waitandstatusreturn up to 16 KB inline, plusFull output: <path>(Atomic keeps the 256 most recent copies in a private temp directory and cleans them on exit) andRequested output:whenoutputwas set. - Startup progress and retries. Before a subagent’s first turn,
statusreports its exact startup step (opening its session,loading its resources, waiting for a concurrent session-startup slot,creating its agent session,registering on Intercom, ordispatching its task) with elapsed time. If startup exceedssessionStartTimeoutMs(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 automatically restores them.
Task inspection
Use/tasks (or /tasks <id>) or the agent panel below the prompt (↓ on an empty prompt) to inspect 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 selectmainin the panel to return without interrupting the subagent. - Pause or stop. While viewing a working subagent, press
Esc(orCtrl+Con an empty prompt) to pause its active turn without affecting main chat. In/tasksor the agent panel, pressxtwice within 3 seconds to stop a running task resumably, orxonce to dismiss a finished row. - Subagent shells and questions. A subagent’s running shells nest beneath it in the agent panel, and a subagent’s
ask_user_questionor extension dialogs wait inside its own transcript (Needs input) without blocking the main chat. - Launch cards and history. Each subagent renders
Agent(<agent> · <short task title>)(Ctrl+Oexpands prompt, tool calls, and result). Atomic keeps live status for the 256 most recently finished runs plus all active runs; older subagents remain resumable viasubagent({ action: "resume", id }).
/tasks controls.
Run control
Control subagents withpause, quit, and resume. The id parameter accepts a child ID (<runId>:<index>), task ID, Intercom name, or single-child run ID:
pause. Stops the active turn and keeps queued steering or follow-up messages to deliver once in order beforeresume’smessage. Intercom messages to a paused subagent do not resume it; they wait without expiry and arrive afterresume’smessage.quit. Stops the subagent gracefully, including already-paused subagents, while keeping it resumable.- Awaiting resume. Completion notices report
paused · awaiting resumeorquit · awaiting resumewithStop reason: pauseorquitand the exactresumecall.subagent({ action: "status" })lists them under Awaiting resume across restarts aspaused · awaiting resumeorquit · paused · awaiting resumewithout auto-relaunching. - Queued parallel subagents. You can
pauseorquita subagent still waiting for a concurrency slot.resumestarts it with its original task, optionalmessage, 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: trueis not supported). For paused, quit, or interrupted subagents,messageruns before continuing; for completed or failed subagents,messagestarts a fresh turn. Omittingmessageprompts the subagent to continue or stop if done.- Resumable vs. 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 rejectresume(pauseorquitthem first, or message them via Intercom). Failed resumes preserveworktree: truecheckouts. - Interrupting control calls. Pressing
Escstops waiting onpause,quit, orresume(already-requested stops finish; unstarted resumes cancel cleanly). - Removed actions.
killandinterruptwere removed; calls fail and point to{ action: "quit", id }.
Ctrl+O or your own expand shortcut to see what happened, the task ID, and any message you 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-targetintercom 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 bounded to 6 resumes in 10 minutes and chain depth 4. See Messages that resume a finished subagent.
Released subagents
A background subagent that waits more than 1 minute on a long-running detachable external tool call (for example, a CI run or deployment tool marked detachable), a budgetless shellwait, 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.
- What you see. Main chat shows 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" })reportsreleased · waiting on <tool> (<call id>). - Inspecting, waking, or holding. Viewing a released subagent opens 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 Intercomsend/ask, or callingresumewakes it immediately. Pressingxtwice or callingpauseorquitstops auto-wake and holds arriving results until youresume. - 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 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.runningCapacityreleased subagents wake concurrently.
Automatic restore and session storage
If Atomic exits, crashes, or you switch sessions (/new, /resume, /fork), running subagents stay resumable and relaunch automatically when you reopen the launching session — keeping their Intercom name, group, model, thinking level, original agent definition, forked context, and unread queued messages.
Finished, paused, quit, and permanently cancelled subagents do not auto-relaunch, and session forks (/fork, --fork) never relaunch the original session’s subagents. If a subagent cannot be restored, Atomic posts one recovery notice with its IDs, worktree or branch, git inspection commands, and relaunch call, then marks it gone.
A subagent always stores its session in the launching session’s own session store (local SQLite by default, shared PostgreSQL, 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, andhistory://sessionsomit them, whilehistory://sessions/<id>reads them directly (with?project=<dir>if the subagent ran in another directory or worktree). In SQLite and PostgreSQL stores, forked subagents share their parent’s conversation history instead of copying it (Shared-history forks). - Unsaved sessions. Sessions started with
--no-sessionor in-memory storage keep subagent sessions in memory and move finished transcripts to a temp file cleaned on exit. - Worktree snapshots. In blob-capable stores, subagents record worktree snapshots of checkouts they modify so reopening restores the newest state cleanly.
Coordination and swarms
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 alone controls Intercom availability 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).
- Decision waits vs.
intercomask.contact_supervisor({ reason: "need_decision", message })andinterview_requestwait inside the requesting subagent and continue that same subagent when you answer withintercom({ action: "reply", message: "..." })(usependingandreplyTowhen multiple asks are open). Never relaunch the subagent to answer it. By contrast,intercomaskreturns at delivery and delivers late replies as messages. - Non-blocking updates.
intercomsendandcontact_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
intercomTargetor ID fromintercom list, and choosedelivery: "steer"(default),"followUp", or"interrupt". See Intercom reference. - Embedded SDK sessions without background task management. When an SDK host runs a single subagent directly without a background task host,
subagentblocks until completion and a blockingcontact_supervisorends 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 explicitgroup, discover each other with intercom({ action: "list" }) and communicate directly with send and ask instead of routing through the supervisor.
- Share findings, divide file ownership or expensive test runs, pass along reproductions, and challenge disagreements with evidence. Each subagent still returns its own complete result.
- Reserve
contact_supervisorfor supervisor decisions. Peer asks and one blocking supervisor ask can wait concurrently. See/skill:intercomfor peer patterns.
Scaling a swarm
- Parallel limits.
parallel.maxTasks,parallel.concurrency, andparallel.runningCapacityeach default to1000with no hard upper cap. Adjust all three inconfig.jsonto raise limits, or lowerparallel.concurrencyto throttle. Provider rate limits and host memory remain the practical bounds. - Teams. Intercom groups have no member cap. Give each team a named
group(orgroup: truefor a unique shared UUID group); members can still reach the supervisor viacontact_supervisor.
From codemode scripts
When bothcodemode and subagent are active, tools.subagent() launches the same background subagents and resolves at launch, 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 are not merged into one burst; pass tasks: [...] for a parallel batch.
{ action: "launch", tasks }. Each slot contains agent, state ("admitted", "queued", or "refused" with reason), taskId, childId, and intercomTarget when available. Do not retry already-started siblings if one slot is refused.
- Strict script rules. Always pass
id— passing the legacyrunIdalias is rejected in codemode ("Use id instead of runId in subagent scripts."). Inwait,budgetMstakes a finite non-negative number or a plain decimal string such as"2000"(defaults to30000ms even when a host configures unlimited foreground waits;0checks immediately). waitoutcomes. Returnsoutcome: "settled","running", or"stopped-waiting"(when the script’s signal aborts; script timeouts cancelwait, not the subagent). On settled results, bothpauseandquitstops (when not released) resolve toresult.status: "paused"(withresult.reason: "pause"or"quit"), while a released child resolves toresult.status: "cancelled".list,get,models,status, and control. Inspect agents or models, callstatusafter reopening a session to reconcilechildren, and callpause,quit, orresumewithid(orall: trueforpause/quit). Creating, updating, or deleting agent definitions requires a direct tool call.- Temporary worktrees.
statuscan showfinishingwhilewaitstill returnsrunning. CheckworktreeNoteorworktreeNotesin script results before deleting any temporary worktree directory.
Configuration and start timeouts
Configure subagent runtime defaults in~/.atomic/agent/extensions/subagent/config.json (or ~/.pi/agent/extensions/subagent/config.json when the Atomic file is absent) and inspect available scoped models with subagent({ action: "models" }). Subagents enforce your active enabledModels / --models / /scoped-models scope and skip providers without configured 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 5-minute (300000 ms) startup budget covering session open, resource load, agent session creation (including slot wait), and task dispatch. Queue wait under parallel.runningCapacity does not count. Override it in ~/.atomic/agent/extensions/subagent/config.json (1 to 2147483647 ms):
SessionStartTimeoutError (shown in status and serialized as startError for SDK callers):
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 cannot create, update, or delete agent definitions. Subagents can still run background shells (nested under the subagent 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.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.