Agent with subagents
Example OrchaJS parent agent that delegates work to private subagents.
01import { orcha } from "orchajs";02 03orcha.init({04 providers: {05 anthropic: process.env.ANTHROPIC_API_KEY ?? "",06 },07 agents: {08 coordinator: {09 path: "./coordinator",10 subagents: {11 researcher: "./researcher",12 },13 },14 },15});Delegate focused reasoning
This example is a complete research coordinator with one private subagent. The coordinator decides what to delegate, the researcher handles one focused question, and the coordinator remains responsible for the final response.
A subagent is an ordinary agent folder with its own model configuration,
instructions, context, and durable session. Registering it inside
coordinator.subagents gives the parent internal tools to run, resume, and
inspect that child without exposing the child as a top-level application API.
The parent waits while the child runs, receives the child response as a tool result, and continues automatically. Parent and child histories remain separate and linked for inspection.
Select any file in the editor to inspect the complete standalone project.
Understand each file
orcha/coordinator/index.json
Configures the parent agent and optionally limits new child sessions per run.
orcha/coordinator/instructions.md
Explains what to delegate and keeps final synthesis with the parent.
orcha/researcher/index.json
Configures the specialist as an ordinary agent with its own model and session.
orcha/researcher/instructions.md
Gives the child a narrow role and a clear response contract.
orcha/index.ts
Registers researcher inside coordinator.subagents, making it private to the parent.
- Private subagents do not become top-level orcha properties.
- Parent and child keep separate, linked durable sessions.
app.ts
Runs only the coordinator. Delegation is handled inside the execution.
Next: test an agent.