Launch now, use the result later
When your main session coordinates subagents through codemode (confirm bothcodemode and subagent are enabled with /tools), tools.subagent() launches background subagents and returns immediately:
launch.tasks output:
- Launch, not completion.
awaitresolves as soon as subagents start ("admitted"), queue ("queued"), or fail validation ("refused"withreason). Your main session can keep working or end its turn while completion notices deliver results automatically. Inspect live progress anytime in/tasksor the agent panel (Manage background tasks). - Explicit parallel batches. Separate
tools.subagent()calls inside one script are not merged automatically; passtasks: [...]to launch a parallel batch. - Explicit wait. When a later step depends on a result immediately, wait on the existing task ID instead of launching a duplicate. The
// @optionscomment sets per-script codemode options such astimeout_ms:
id (passing runId is rejected), pass a non-negative integer for budgetMs (defaults to 30000 ms even when a host configures unlimited foreground waits), and note that pause and quit stops both report result.status: "paused".
- Cancellation and evidence. Hitting
budgetMs, returning early, or timing out the script never stops already-launched subagents; calltools.subagent({ action: "quit", id: childId })to stop one. Treat settled results and real verification output — never launch receipts — as evidence. - One-level delegation. Only the main session launches subagents. If a subagent discovers follow-up work, it reports back so the main session can launch the next batch.
- Peer messaging. Pass
group: trueto create a unique shared Intercom group for a batch, or pass a shared namedgroup. Address subagents using their exactintercomTarget(Intercom from codemode);contact_supervisorstill reaches the main session across groups.
What survives interruption
Subagents are persisted sessions; codemode scripts are not checkpointed programs.- Reopening a session. Running subagents relaunch automatically when you reopen the original main session. Paused and quit subagents stay awaiting manual resume in
/tasksor viatools.subagent({ action: "resume", id: childId })(unless configured otherwise via run control settings). - Forks and unsaved sessions. Forking a session (
/forkor--fork) never restores the original session’s subagents, and sessions started with--no-sessionare not saved so their subagents cannot be restored after Atomic closes. - Branch-scoped handoff state. Save small handoff state — task IDs, round counts, and next checks — with the codemode store.
store()writes persist per branch only when the script succeeds; if a script throws or times out, itsstore()writes are discarded even though launched subagents keep running. - Reconciling after a restart. Call
await tools.subagent({ action: "status" })and reconcilechildrenagainst storedchildIdvalues before launching new subagents. Collect finished results, resume paused work that is still needed, and inspect/tasks, chat, and modified files before retrying.
Choose a pattern
Classify-and-act
Triage input with a read-only subagent, validate the label, then dispatch the matching specialist.
Fan-out-and-synthesize
Split a broad review or investigation across parallel subagents and reconcile their evidence.
Adversarial verification
Ask a fresh read-only subagent to find a concrete failing input against a candidate fix.
Generate-and-filter
Gather candidate inputs or cases from fresh subagents and filter them with a deterministic check.
Tournament
Compare competing implementations in isolated named worktrees against shared fixtures.
Loop-until-done
Run verification checks in the main session between bounded repair rounds.
Stacked slices
Branch each dependent slice from the verified commit of the previous slice.
Skills as workflows
Save repeatable multi-step instructions as a skill, or migrate legacy workflow files.
.atomic/workflows/*.ts file or removed built-in workflow name? Follow Migrate an earlier workflow to a skill.