Skip to content

Multi-Agent

OpenMotoko supports spawning sub-agents for parallel task execution. The primary agent can delegate work to specialized sub-agents, each with their own context and budget.

The AgentManager controls the lifecycle of all agents:

  • Maximum 4 concurrent sub-agents
  • Each agent is persisted to the agents database table
  • Supports waiting for one agent or all agents to complete
  • Agents have configurable timeouts
RoleDescription
primaryThe main agent handling user conversations
subA spawned agent executing a delegated task
StatusDescription
idleCreated but not yet running
runningActively processing
waitingBlocked on sub-agent results
completedFinished successfully
failedTerminated with an error

The LLM can use two tools to work with sub-agents:

Spawns a new sub-agent with a specific task.

{
"task": "Research the latest Node.js 24 features and summarize them",
"name": "node-researcher",
"model": "fast",
"budget": 0.50
}
ParameterTypeDefaultDescription
taskstring(required)Task description for the sub-agent
namestring(auto)Human-readable name
modelstring(parent model)Model alias to use
budgetnumber1.00Max cost in USD

Waits for one or more sub-agents to complete.

{
"agentIds": ["agent_abc123", "agent_def456"]
}

The primary agent blocks until all specified agents finish, then receives their outputs.

  • Each sub-agent runs for a maximum of 10 turns
  • Sub-agents have their own system prompt tailored to their task
  • Sub-agents inherit the parent’s skill access
  • Budget is enforced per-agent; exceeding it terminates the agent
EventFieldsDescription
agent:spawnedagentId, parentId, name, modelSub-agent created
agent:completedagentId, parentId, name, output, durationMsSub-agent finished
agent:failedagentId, parentId, name, output, durationMsSub-agent errored
MethodPathDescription
GET/api/agentsList all agents
GET/api/agents/:idGet agent details
DELETE/api/agents/:idKill a running agent

Parallel research: spawn multiple agents to research different topics simultaneously, then synthesize their findings.

Code review: one agent analyzes code quality while another checks for security issues.

Data processing: split a large dataset across agents for parallel analysis.

Multi-step workflows: chain agents where each handles one stage of a pipeline.