@bastani/atomic SDK error classes for background tasks. For everyday interactive usage, see Manage background tasks.
Observation and wait matrix
Tool calls choose foreground-first or immediate background observation throughwait and action: "wait". Observation budgets control only when a tool call returns; they never kill a running command or subagent.
Key behavioral rules:
- Cancelling a launch vs. cancelling
action: "wait". PressingEsc(or aborting the call’sAbortSignal) during the initial foreground wait ofbash,powershell, orhistory://read/searchcancels the underlying command or history scan. By contrast, cancelling{ action: "wait", id }on an already-running task only ends the wait and leaves the task running with its original deadline. - Incremental output paging on running shells. Calling
bashorpowershellwith{ action: "wait", id }on a running shell returns at most 8 KiB of newly produced output per call (trimmed to a complete UTF-8 character boundary and advancing the wait offset). When more output is buffered, Atomic appends[Additional output not shown; wait again to retrieve retained output.]. Waiting on a settled shell returns all retained output (subject to standard truncation with a full-output file path). - Timed-out shell waits. Waiting on a shell stopped by its
timeoutreturnsisError: trueand reportsTask <id> was cancelled (timed out after <N> seconds).. - Unknown and evicted IDs. Waiting on an unknown shell ID fails with
No background task "<id>" in this session. Waiting on an evicted shell ID fails withTaskEvicted: Task "<id>" finished and is no longer kept in this session. Waiting on an unknown or expired history task fails withUnknown history task <id>: it was never started here, or it ended long ago. - SDK host default wait policy. Custom SDK hosts can override automatic wait budgets or set
tasks.wait.kind: "until-settled"so omitted foreground budgets wait until completion, while explicit per-callbudgetMsvalues still take precedence. See Supervised command SDK.
Stopping tasks and CancelReceipt
kill tool contract
kill({ id }) stops a background shell (bash or powershell) or a background history:// scan started by the current session:
- Shell tasks. Returns a summary line (
◼ stopping · cancellation requested,◯ cancelled, or● already completed · exit 0) and a structuredCancelReceiptindetails:taskId: the task identifier.decision:"already-settled" | "already-finishing" | "cancellation-requested".execution:{ kind: "queued" | "running" | "cancelling" | "settled", ... }.cleanup:{ kind: "active" | "draining" | "reaped" | "quarantined" | "failed", ... }. Whencleanup.kind === "failed", the tool result setsisError: true.- If a command finished before
killran, its original outcome is preserved. Stopping a task never erases its output or completion notice.
- History tasks (
history-N). Stops the scan, sends no completion notice, and returns plain text withdetails: undefined(noCancelReceipt). - Subagent tasks. Calling
killwith a subagent task ID is rejected withkill only supports shell tasks. Usesubagent({ action: "quit", id })orsubagent({ action: "pause", id })instead. - Interactive stop-all (
Ctrl+X Ctrl+K). Stops every running or queued background subagent and shell owned by the session (including shells started by subagents). It does not stop backgroundhistory://tasks. - Windows supervision. Native Windows refuses background shell launches it cannot supervise, and legacy Windows WSL
bash.exestdin transport is unsupported (run Atomic inside WSL for POSIX Bash).
Commands while viewing a subagent
Slash commands behave differently depending on whether you are viewing a subagent on the main chat screen (selected from the agent panel or/tasks) or inside a subagent’s own chat surface inside /tasks.
Main-screen subagent view
Bare-only vs. argument-taking built-in commands
- Take arguments (intercepted with or without arguments):
/tasks,/model,/thinking,/export,/import,/name,/login,/logout,/compact,/resume, plus/session snapshot. - Bare-only (intercepted only with no trailing text):
/settings,/scoped-models,/share,/trust,/reload,/quit,/exit,/tools,/changelog,/hotkeys,/tree,/fork,/clone,/new,/copy,/debug, and/session(other than/session snapshot). Appending extra text (such as/copy thator/new idea) sends the line to the subagent as normal text.
Subagent chat inside /tasks
Inside a subagent’s own chat surface in /tasks, only /tasks (listing that subagent’s own tasks), /copy, and /hotkeys run locally. Every other built-in slash command is refused with /<name> is not available in a subagent chat and never sent as text. Skills, prompt templates, and user or project extension commands still run in the subagent’s session.
See Slash commands for the full command catalog.
Agent panel and /tasks UI reference
Responsive columns, row limits, and timers
- Model column. Displays
provider/model-idand reasoning level, capped at 40 columns (truncating the model ID while keeping the reasoning level). Updates on model fallback, resume, or effort change; blank when unknown. - Responsive breakpoints. Task titles shorten first. Below 100 columns (or when a row lacks space for task and elapsed time), the model column hides. Below 70 columns, token counts hide. If fewer than 8 columns remain for the task title, the title hides.
- Row caps. Up to 4 rows appear while the prompt has focus (
+N morecounts omitted rows, including nested shells, while keeping the viewed subagent and its running shells visible). Focusing the panel displays up to 8 rows at a time. Themainrow never counts toward either cap. - Stopped-row dimming. Finished subagents leave the panel immediately unless currently viewed (a viewed finished row stays until you switch away or dismiss it with
x). Stopped, paused, or interrupted subagents stay while other work runs, dim after 30 seconds, and leave once nothing else is running. - Selection memory. The panel remembers your last selected row (
main, subagent, or a subagent opened from/tasksviaEnteror click) and scroll position across visits. Leaving/taskswithEscdoes not change the remembered row. - Shell output previews and large saved entries.
/tasksshell output pages display the last 8 KiB of retained output starting on a valid UTF-8 character boundary (trailing blank lines trimmed; unframed below 24 columns). Shell detail pages display up to 10 wrapped lines from that 8 KiB tail. Database-backed subagent transcripts page on scroll; any single saved entry exceeding 1 MiB shows its position and byte count so you can read it viahistory://or export. - Keybinding IDs. Customize task shortcuts in
keybindings.json(Keybindings), includingapp.list.stop(x),app.tasks.openWaited(Alt+W),app.session.resume, andapp.session.new/tree/fork.
Extension panel sources
Extensions can contribute custom rows to the agent panel and/tasks via atomic.registerAgentPanelSource(). If an extension source throws or returns invalid rows, Atomic hides that source’s invalid rows and logs a warning once per source while keeping other rows and chat usable; fix the extension and run /reload to re-register.
Heartbeat sampling and batching
- Eligible states. Only running shells and subagents emit heartbeats. Queued, stopping, completed, failed, killed, paused, quit, and
history://tasks never emit heartbeats. - Cadence rules. The interval (
heartbeatMs, defaulttasks.heartbeatMs=900000ms / 15 minutes;0disables; minimum60000ms) counts from when the task started running. In parallelsubagentcalls, a per-taskheartbeatMsoverrides the top-level value. Resumed subagents keep their original launch’sheartbeatMs(falling back to the chat default only if omitted originally). - Shell sampling. Shell output is sampled every 30 seconds from the trailing 2 KiB of output, reporting total output size, time since last output, and up to 6 non-empty trailing lines (each capped at 160 characters).
- Subagent fields. Subagent heartbeats report agent name, elapsed time, time since last activity, current or last tool call, turn count, tool-call count, token count, active model (and fallback mismatch
model <ran>, not the requested <requested>when fallback occurred), and attention states (input-neededorno recent activity). - Batching and caps. Tasks coming due within
min(1 minute, cadence / 4)share one heartbeat (for example, 15 seconds on a 1-minute cadence). One heartbeat describes up to 8 tasks in full, lists up to 20 more by name, and summarizes any beyond 28 as; and N more. In chat, a collapsed heartbeat card lists up to 5 tasks and counts the rest. - Backpressure and idle wake. Each chat holds at most 1 unread heartbeat. While an unread heartbeat waits, due tasks recheck every 30 seconds; missed intervals never stack or replay. Heartbeats queue without interrupting streaming text and wake an idle chat (including after an
Escinterrupt) unlesstasks.heartbeatWakesIdleSessionisfalseor you queued a draft and interrupted withCtrl+C. Heartbeats also yield an activeaction: "wait"call while the task continues. - Routing. Subagent-launched shells are managed by the launching main session, so their heartbeats go to the main session.
Lifetime, retention, and process cleanup
Output and retention limits
Process-tree containment and cleanup
- Linux and macOS. Each shell command runs in its own session so teardown stops child processes across process groups while leaving intentionally detached processes (such as
setsiddaemons) alone once they close stdout/stderr. On Linux with a user-owned cgroup v2 hierarchy, Atomic additionally places background shells in cgroups for tighter process-tree containment. SetATOMIC_TASK_CGROUP=0to disable cgroup v2 containment (for example in containers with restrictive cgroup policies). - Windows. Atomic uses Windows Job objects to terminate process trees cleanly. On native Windows, Suspend opens a PowerShell subshell while background tasks keep running until you exit back to Atomic.
- Unconfirmed teardown and admission waits. If a shell exits while a descendant keeps stdout/stderr open, Atomic preserves the shell’s exit code and output (discarding later writes) and waits up to 15 seconds in the background — and up to 15 seconds more on session close — to confirm process-tree teardown (
cleanup.kind: "quarantined"). While waiting for confirmation, that shell holds its concurrency permit. New shell launches blocked only by pending-cleanup permits wait up to 5 seconds before failing withTaskCleanupAdmissionTimeoutError. - Temporary worktrees on close. Closing or switching sessions waits for subagent execution, output, and recovery notices while remaining batch Git worktree cleanup continues in the background. See Temporary worktrees.
Task SDK errors
All four task error families below are exported from@bastani/atomic. Branch on the class, guard, or code, not the message text.
TaskEvictedError
Thrown (or wrapped as cause on TaskToolError with code: "TaskEvicted") when a task finished and was evicted past the 256-task retention window (FINISHED_TASK_RETENTION).
code:"task_evicted"retryable:false- Fields:
taskId,retainedFinishedTasks,hint - Helpers:
isTaskEvictedError(error),findTaskEvictedError(error),rehydrateTaskEvictedError(serialized)
TaskCleanupError and TaskCleanupAdmissionTimeoutError
Thrown when shell process-tree teardown cannot be confirmed within the confirmation window, or when a new command waits 5 seconds behind unconfirmed-cleanup permits.
code:"task_cleanup_unconfirmed"(both classes)retryable:true(isRetryableTaskError(error)returnstrue)TaskCleanupErrorfields:phase("session-close" | "app-shutdown" | "stage-pause" | "command-admission"),failures(readonly TaskCleanupFailure[]),hintTaskCleanupAdmissionTimeoutErrorextendsTaskCleanupErrorwithphase: "command-admission",timeoutMs, andelapsedMs- Helpers:
isTaskCleanupError(error),isTaskCleanupAdmissionTimeoutError(error),isRetryableTaskError(error),rehydrateTaskCleanupError(serialized)
TaskToolError
Thrown on shell wait and kill failures. Only StaleGeneration is retryable: true. On TaskEvicted, error.cause is a TaskEvictedError.
Helpers:
isTaskToolError(error), rehydrateTaskToolError(serialized).
TaskMessageError and TaskMessageTimeoutError
Thrown when sending a typed message into a task transcript fails.
Helpers:
isTaskMessageError(error), isTaskMessageTimeoutError(error), isRetryableTaskMessageError(error), findTaskMessageError(error), rehydrateTaskMessageError(serialized).