Subagents & Task Delegation
Purpose
Delegate work to specialized child agents so the main agent can parallelize independent subtasks instead of doing everything in one context.
How it works
- The
tasktool (src/task/index.ts) spawns subagents. It discovers agent definitions from three places:- bundled agents shipped with the coding agent,
~/.omp/agent/agents/*.md(user-level),.omp/agents/*.md(project-level).
- Each spawn gets a subagent prompt (
src/prompts/system/subagent-user-prompt.md) with a fresh context; results come back as structured JSON events or session artifacts. - Supports: single spawn (parallelism = multiple
taskcalls), batch spawning with shared context whentask.batchis enabled, background execution throughAsyncJobManagerwhenasync.enabledis enabled, and progress events. - The
/taskslash command manages the async background side (/task run <description>,/task list,/task status <id>). src/task/parallel.tsprovides the parallel-fan-out helper used by multi-agent features;src/agents/adds consensus/critic/best-of-N patterns.
Configuration
task:
batch: false # allow batch spawn + shared context per call
async:
enabled: true # background execution through AsyncJobManager
Real example
> run three file-hunting jobs in parallel - one per directory
> (agent issues 3 task tool calls; each subagent returns its match list)
> /task run "port the parser to TypeScript" # fire-and-forget background
> /task list
> /task status <id>
Screenshot

/task command surface in the TUI (usage + async job list).
Expected behavior
- Subagent results are delivered per-item; the caller sees usage + progress.
- Depth is bounded:
canSpawnAtDepthprevents unbounded recursive spawning. - With async enabled,
/taskshows live background jobs and their status.
Failure behavior
- A killed parent process loses in-memory background task state unless the task runner persisted it (a
persisted-revive.tsmodule exists for revival). - Spawn limits (
canSpawnAtDepth) reject deeper nesting with an error.
Limitations
- Subagent isolation is logical (fresh context), not OS-level unless the PAL isolation backend is configured (
subagent.isolation: auto→ CoW/overlayfs).