Skip to content

Orchestrator Pattern

The Orchestrator Pattern is a structural design pattern used within multi-agent systems to manage the decomposition and coordination of complex tasks.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

In this pattern, a central "Orchestrator" agent is responsible for analyzing a large objective and distributing specific sub-tasks to multiple "Leaf" agents.^[001-TODO__Hermes_Agent_v0.11_-结构升级与实战工作流解读.md] This structure enables parallel execution and modular problem-solving, while maintaining a centralized point for aggregating results.^[001-TODO__Hermes_Agent_v0.11-_结构升级与实战工作流解读.md]

Core Roles

The pattern defines two primary roles with distinct capabilities and permissions.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

Orchestrator

  • Capability: Can invoke delegate_task to spawn new layers of sub-agents.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]
  • Function: Responsible for breaking down high-level tasks, assigning work to leaf agents, and synthesizing the final output from parallel results.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]
  • Access: Unlike leaf agents, the orchestrator retains access to the delegate_task tool.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

Leaf

  • Capability: Independent execution only; cannot delegate tasks further.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]
  • Function: Acts as the primary worker unit, executing assigned tasks such as code review, data search, or processing.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]
  • Restrictions: Blocked from using tools like delegate_task, clarify, memory, and send_message to prevent recursive complexity and ensure side-effect isolation.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

Architectural Hierarchy

Agents are organized in a hierarchical tree structure defined by spawn depth and role assignment.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

  • Depth 0: The Parent Agent (the primary agent interacting with the user).
  • Depth 1: Child agents spawned by the parent. These can be Orchestrators (to delegate further) or Leafs (to execute work).
  • Depth 2+: Further nested layers (Grandchildren), typically restricted to Leaf roles to control complexity and token costs.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

Configuration Constraints

To balance performance with resource consumption, the pattern introduces specific configuration limits:^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

  • max_concurrent_children: Limits the number of parallel sub-agents (e.g., default 5) to prevent out-of-memory (OOM) issues or API rate limiting.
  • max_spawn_depth: Controls nesting depth (typically 1-3). Deeper nesting increases token consumption and latency.
  • subagent_auto_approve: Defaults to false to prevent sub-agents from executing dangerous commands without manual approval.

File Coordination & Conflict Resolution

A critical challenge in parallel execution is managing concurrent file access.^[001-TODO__Hermes_Agent_v0.11_-结构升级与实战工作流解读.md] The Orchestrator Pattern often implements a FileStateRegistry to handle concurrency safety.^[001-TODO__Hermes_Agent_v0.11-_结构升级与实战工作流解读.md]

This mechanism functions as a process-level singleton that tracks the state of files across all active agents:^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

  1. Tracking: When an agent reads a file, a "read stamp" is recorded. When an agent writes a file, a "last writer" stamp is recorded.
  2. Stale Detection: Before writing, the system checks if the file has been modified by another agent (sibling) or external process (mtime change) since the current agent last read it.
  3. Resolution:
    • Locking: Uses per-path threading.Lock to serialize read-modify-write operations on the same file.
    • Warnings: Rather than blocking execution, it returns warning prompts to the agent model (e.g., "Re-read the file before writing, Agent B modified it"), allowing the agent to self-correct.

Use Cases

Parallel Code Review

An Orchestrator analyzes a Pull Request (PR) diff, delegates modules to different Leaf agents (e.g., Payment, Settlement, Web), and aggregates their findings into a unified report.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

Multi-Source Research

An Orchestrator assigns data gathering tasks to specialized Leaf agents querying different sources (e.g., Database A, API B, Logs C) and synthesizes the outputs into a single insight.^[001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md]

Best Practices

  • Limit Nesting: Keep max_spawn_depth at 1 or 2 to minimize token overhead.
  • Scoped Context: Provide specific file paths or constraints to Leaf agents to prevent ambiguity.
  • Cost Control: Configure delegation to use cheaper models for Leaf agents while reserving capable models for the Orchestrator.
  • Conflict Management: Ensure Leaf agents' goals target distinct file areas to reduce FileStateRegistry warnings.
  • [[Multi-Agent Systems]]
  • Hermes Agent
  • [[Delegation Pattern]]
  • [[Concurrency Control]]

Sources

  • 001-TODO__Hermes_Agent_v0.11_-_结构升级与实战工作流解读.md