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
| Type | Label | Description | Tools | Max Turns |
|---|---|---|---|---|
explore | Explorer | Fast codebase search, structural questions. Read-only. | file_read, file_search, file_list, file_tree, file_info | 6 |
general | Generalist | Full tool access for complex multi-step tasks. | All available | 12 |
plan | Planner | Creates detailed execution plans with step IDs. Read-only. | Read-only file tools | 8 |
code | Coder | Writes and edits code. Runs tests — verification is mandatory. | Full file system + shell + code_exec | 10 |
research | Researcher | Web research and information synthesis. | web_search + read-only file tools | 8 |
Domain Specialists
| Type | Label | Description | Tools | Max Turns |
|---|---|---|---|---|
security | Security Auditor | OWASP Top 10, secrets, CVEs. Read-only. | file_read, file_search, file_list, file_tree, file_info, web_search | 10 |
debug | Debugger | History → Reproduce → Isolate → Fix → Verify → Regression test. | Full file system + shell + code_exec | 12 |
architect | Architect | System design with quantified trade-offs, ADR format. Read-only. | Read-only file tools | 10 |
devops | DevOps Engineer | Docker, Kubernetes, Terraform, CI/CD, shell automation. | Full file system + shell + web_search | 12 |
data | Data Analyst | Data queries, analysis, insights. | shell + code_exec + db_query + web_search | 12 |
ui | UI/UX Designer | Accessible interface design. WCAG 2.1 AA minimum. | Full file system + shell + browser + web_search + code_exec | 12 |
Quality & Documentation
| Type | Label | Description | Tools | Max Turns |
|---|---|---|---|---|
reviewer | Code Reviewer | Structured PR review: BLOCKER / SUGGESTION / NITPICK / QUESTION. Read-only. | file_read, file_search, file_list, file_tree, file_info, web_search | 10 |
writer | Technical Writer | Writes/edits docs, changelogs, READMEs, API references. | file_read, file_write, file_edit, file_search, file_list, file_tree, shell, web_search | 10 |
Spawning Flow
Parent Agent → tools/builtin/sub_agent.ts → agent/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
- Built-in Agents — Pre-configured agent profiles
- Agent Loop — How agents process turns
- Multi-Agent Orchestration — 6 coordination strategies