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

Orchestrator

The orchestrator implements a manager-worker pattern. It uses an LLM to decompose complex tasks into subtasks, then dispatches them to parallel subagent workers. Results are synthesized into a final response.

Details

IDnexus.agent.orchestrator
Dependenciesnexus.agent.subagent

Configuration

KeyTypeDefaultDescription
max_workersint5Maximum concurrent subagent workers
max_subtasksint8Maximum number of subtasks to decompose into
worker_max_iterationsint10Max iterations per worker subagent
orchestrator_model_rolestringreasoningModel for task decomposition
worker_model_rolestringbalancedModel for worker execution
synthesis_model_rolestringbalancedModel for result synthesis
fail_fastboolfalseStop all workers if one fails
system_promptstring(none)System prompt for the orchestrator
system_prompt_filestring(none)Path to system prompt file

Events

Subscribes To

EventPriorityPurpose
io.input50Receives user tasks
tool.result50Tool results during decomposition
llm.response / llm.stream.*50LLM responses
skill.loaded50Skill content
tool.register50Tool discovery
subagent.started50Worker started notification
subagent.iteration50Worker progress
subagent.complete50Worker finished
cancel.active / cancel.resume5Cancellation
memory.compacted50History compaction

Emits

EventWhen
llm.requestDecomposition and synthesis LLM calls
before:tool.invoke / tool.invokeTool invocation
before:tool.resultBefore tool result propagation (vetoable)
thinking.stepDecomposition and synthesis reasoning
io.statusPhase transitions
agent.turn.start / agent.turn.endTurn boundaries

Phases

stateDiagram-v2
    direction LR
    [*] --> idle
    idle --> decomposing: agent.turn.start
    decomposing --> dispatching: subtasks ready
    dispatching --> executing: workers spawned
    executing --> executing: subtask completed
    executing --> synthesizing: all subtasks done
    synthesizing --> idle: agent.turn.end
    idle --> [*]

    note right of decomposing
        orchestrator LLM
        breaks task into
        subtasks
    end note
    note right of executing
        parallel workers
        respect max_workers
    end note
  1. Decomposing — The orchestrator LLM breaks the task into subtasks with descriptions and optional dependencies
  2. Dispatching — Subtasks are queued and sent to subagent workers (respecting max_workers concurrency)
  3. Executing — Workers run in parallel; the orchestrator tracks progress and collects results
  4. Synthesizing — All results are gathered and the synthesis LLM produces a unified response

Subtask Dependencies

The orchestrator can recognize dependencies between subtasks. Dependent subtasks wait until their prerequisites complete before dispatching.

Failure Handling

  • fail_fast: false (default) — Other workers continue even if one fails. Failed results are included in synthesis.
  • fail_fast: true — All remaining workers are cancelled when any worker fails.

Example Configuration

plugins:
  active:
    - nexus.io.tui
    - nexus.llm.anthropic
    - nexus.agent.orchestrator
    - nexus.agent.subagent
    - nexus.agent.react
    - nexus.tool.shell
    - nexus.tool.file
    - nexus.memory.capped
    - nexus.control.cancel

  nexus.agent.orchestrator:
    max_workers: 3
    max_subtasks: 6
    orchestrator_model_role: reasoning
    worker_model_role: balanced
    synthesis_model_role: balanced
    fail_fast: false

  nexus.agent.subagent:
    max_iterations: 10

When to Use

The orchestrator is ideal for:

  • Complex tasks that naturally decompose into independent subtasks
  • Research across multiple topics that can be explored in parallel
  • Code analysis across multiple files or modules simultaneously
  • Any task where parallel execution significantly reduces total time