Sub-Agents

CortexPrism agents can spawn sub-agents — child Deno processes that run independently with their own model, tools, and system prompt. Sub-agents are used for parallel work, specialized tasks, and scope isolation.

Sub-Agent Types

Defined in src/agent/sub-agent-types.ts (13 types total):

Core Types

TypeLabelDescriptionToolsMax Turns
exploreExplorerFast codebase search, structural questions. Read-only.file_read, file_search, file_list, file_tree, file_info6
generalGeneralistFull tool access for complex multi-step tasks.All available12
planPlannerCreates detailed execution plans with step IDs. Read-only.Read-only file tools8
codeCoderWrites and edits code. Runs tests — verification is mandatory.Full file system + shell + code_exec10
researchResearcherWeb research and information synthesis.web_search + read-only file tools8

Domain Specialists

TypeLabelDescriptionToolsMax Turns
securitySecurity AuditorOWASP Top 10, secrets, CVEs. Read-only.file_read, file_search, file_list, file_tree, file_info, web_search10
debugDebuggerHistory → Reproduce → Isolate → Fix → Verify → Regression test.Full file system + shell + code_exec12
architectArchitectSystem design with quantified trade-offs, ADR format. Read-only.Read-only file tools10
devopsDevOps EngineerDocker, Kubernetes, Terraform, CI/CD, shell automation.Full file system + shell + web_search12
dataData AnalystData queries, analysis, insights.shell + code_exec + db_query + web_search12
uiUI/UX DesignerAccessible interface design. WCAG 2.1 AA minimum.Full file system + shell + browser + web_search + code_exec12

Quality & Documentation

TypeLabelDescriptionToolsMax Turns
reviewerCode ReviewerStructured PR review: BLOCKER / SUGGESTION / NITPICK / QUESTION. Read-only.file_read, file_search, file_list, file_tree, file_info, web_search10
writerTechnical WriterWrites/edits docs, changelogs, READMEs, API references.file_read, file_write, file_edit, file_search, file_list, file_tree, shell, web_search10

Spawning Flow

Parent Agent → tools/builtin/sub_agent.tsagent/sub-agent.ts → spawns deno run packages/infra/src/processes/sub-agent-entry.ts. Communication via stdin/stdout JSON-line protocol.

Child sends { type:"ready" } and { type:"done", result:{ ... } }.

Protocol

Parent ↔ Child communication uses stdin/stdout JSON-line protocol:

  • Parent → Child: { "type": "init", "config": {...}, "agentConfig": {...} }
  • Child → Parent: { "type": "ready" }, { "type": "chunk", "delta": "..." }, { "type": "done", "result": {...} }, { "type": "error", "error": "..." }

Session Tracking

Every sub-agent session records its parent via parent_session_id. API: GET /api/sessions/:id/children, getChildSessions(parentId), getParentSession(childId), countChildSessions(parentId). Web UI shows channel type badges and ⤷ child indicators.

Parallel Sub-Agent Dispatcher

Task board tracks all active/completed sub-agent tasks with pulsing green indicators, status badges, and 3-second auto-refresh.

See Also