Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Subagent

The subagent plugin provides a tool that spawns independent child agents. Other agents (or the orchestrator) can invoke it to delegate subtasks. Each instance can be configured with its own system prompt, tool name, and model role.

Details

IDnexus.agent.subagent
Dependenciesnexus.agent.react
Multi-instanceYes — supports instance suffixes (e.g., nexus.agent.subagent/researcher)

Configuration

KeyTypeDefaultDescription
max_iterationsint10Max iterations for spawned agents
model_rolestring(default)Default model role for spawned agents
system_promptstring(none)Default system prompt for spawned agents
system_prompt_filestring(none)Path to default system prompt file
tool_namestringspawn_subagentName of the tool exposed to the parent agent
tool_descriptionstring(auto)Description of the tool

Tool Definition

The subagent registers a tool (default name: spawn_subagent) with these parameters:

ParameterTypeRequiredDescription
taskstringYesThe task description for the subagent
system_promptstringNoOverride the default system prompt
model_rolestringNoOverride the default model role

Events

Subscribes To

EventPriorityPurpose
tool.invoke50Handles spawn tool invocations
tool.register50Collects available tools

Emits

EventWhen
tool.registerRegisters the spawn tool at boot
subagent.spawnWhen a new subagent is created

Multi-Instance Usage

Each instance creates its own spawn tool. Use instance suffixes to create specialized spawners:

plugins:
  active:
    - nexus.agent.react
    - nexus.agent.subagent/researcher
    - nexus.agent.subagent/writer

  nexus.agent.subagent/researcher:
    max_iterations: 15
    model_role: reasoning
    system_prompt: "You are a research specialist. Gather information thoroughly."
    tool_name: spawn_researcher

  nexus.agent.subagent/writer:
    max_iterations: 10
    model_role: balanced
    system_prompt: "You are a technical writer. Produce clear, concise documentation."
    tool_name: spawn_writer

The parent agent will see two tools: spawn_researcher and spawn_writer.

Subagent Events

When a subagent runs, these events are emitted:

EventPayloadWhen
subagent.spawnSpawnID, Task, ParentTurnIDSubagent created
subagent.startedSpawnID, Task, ParentTurnIDSubagent begins execution
subagent.iterationSpawnID, Iteration, ContentEach reasoning iteration
subagent.completeSpawnID, Result, TokensUsed, CostUSDSubagent finished

Example

A ReAct agent with a research subagent:

plugins:
  active:
    - nexus.io.tui
    - nexus.llm.anthropic
    - nexus.agent.react
    - nexus.agent.subagent
    - nexus.memory.capped

  nexus.agent.react:
    max_iterations: 10
    system_prompt: "You can delegate research tasks using the spawn_subagent tool."

  nexus.agent.subagent:
    max_iterations: 10
    system_prompt: "Take in the user input and summarize the problem."