Hermes Agent: Delegation

Last updated: 2026-08-31

Delegation is Hermes Agent's management capability — when facing complex tasks, it can create sub-Agents to work in parallel and aggregate results, like a project manager assigning tasks to team members.

💡 Tip: Delegation is the key capability for Hermes to handle complex tasks. The main Agent decomposes tasks, assigns to sub-Agents, monitors progress, and aggregates results for efficient parallel execution.

📋 Prerequisites: Lesson 7 Skills System, Lesson 8 Tools and Toolsets

1. What You Will Learn

# Content
Delegation mechanism principles
Sub-Agent creation and configuration
Task decomposition and assignment
Parallel execution and coordination
Result aggregation and quality checks

2. Story

(1) Pain Point: Large Tasks Take Too Long Sequentially

Bob asked the Agent to analyze a large project. The Agent reviewed files one by one — 20 files took 30 minutes. Bob thought: can't multiple agents review simultaneously?

(2) Solution: Delegate to Sub-Agents for Parallel Processing

BASH
me: Review the code quality of the entire project
Agent: The project has 20 files, I'll create 5 sub-Agents for parallel review:
  🤖 Sub-Agent-1: src/api/ (4 files)
  🤖 Sub-Agent-2: src/models/ (5 files)
  🤖 Sub-Agent-3: src/utils/ (4 files)
  🤖 Sub-Agent-4: src/views/ (4 files)
  🤖 Sub-Agent-5: tests/ (3 files)
  
  [Executing in parallel...] Completed in 8 minutes
  
  📊 Aggregated Report:
  - Security issues: 3
  - Performance issues: 5
  - Type issues: 7
  - Suggestions: ...

3. Delegation Mechanism Principles

(1) Main Agent → Sub-Agent Architecture

100%
graph TB
    A[Main Agent] --> B[Task Decomposition]
    B --> C1[Sub-Agent 1]
    B --> C2[Sub-Agent 2]
    B --> C3[Sub-Agent 3]
    
    C1 --> D[Result Aggregation]
    C2 --> D
    C3 --> D
    
    D --> E[Quality Check]
    E --> F[Final Output]
    
    A -.->|Monitor| C1
    A -.->|Monitor| C2
    A -.->|Monitor| C3

(2) Delegation Types

Type Description Use Case
Parallel Sub-Agents execute simultaneously Multi-file review, multi-source search
Sequential Sub-Agents execute in order Tasks with dependencies
Conditional Next step based on results Steps requiring human confirmation
Recursive Sub-Agents create their own sub-Agents Very large-scale tasks

4. Sub-Agent Creation and Configuration

(1) Automatic Creation

BASH
# Trigger delegation in conversation
me: Analyze the code quality of all Python files in this repo

Agent: Found 15 Python files, will create 3 sub-Agents for parallel analysis:
  - Sub-Agent "analyzer-1": 5 files
  - Sub-Agent "analyzer-2": 5 files
  - Sub-Agent "analyzer-3": 5 files
  
  Each sub-Agent config:
  - Model: gpt-4o-mini (cost-effective)
  - Tools: fs_read, code_python
  - Skill: python-quality-check

(2) Manual Sub-Agent Configuration

YAML
delegate:
  # Sub-Agent template
  sub_agent_template:
    model: "gpt-4o-mini"        # Use smaller model to save cost
    max_tokens: 2048
    timeout: 120
    
    # Available tools
    tools:
      - fs_read
      - code_python
      - web_search
    
    # Available skills
    skills:
      - code-review
      - test-runner
    
  # Delegation strategy
  strategy:
    max_sub_agents: 5            # Max 5 sub-Agents
    min_task_size: 1             # At least 1 task per sub-Agent
    cost_limit: 0.10             # Max cost per delegation

5. Task Decomposition and Assignment

(1) Automatic Decomposition

BASH
me: Research the latest features of React 19, Vue 4, and Svelte 5

Agent: [Task Decomposition]
  Total: 3 frameworks to research
  Strategy: Assign by framework
  
  🤖 Sub-Agent-1: Research React 19
    → web_search("React 19 features")
    → web_scrape("react.dev/blog")
    
  🤖 Sub-Agent-2: Research Vue 4
    → web_search("Vue 4 features")
    → web_scrape("vuejs.org/blog")
    
  🤖 Sub-Agent-3: Research Svelte 5
    → web_search("Svelte 5 features")
    → web_scrape("svelte.dev/blog")
    
  [Executing in parallel...]

(2) Custom Decomposition Rules

YAML
delegate:
  decomposition:
    # Decompose by file type
    - trigger: "review project"
      strategy: "by_file_type"
      group_by: "extension"
      
    # Decompose by directory
    - trigger: "analyze repo"
      strategy: "by_directory"
      max_per_group: 10
      
    # Decompose by task type
    - trigger: "research"
      strategy: "by_topic"
      identify_entities: true

6. Parallel Execution and Coordination

(1) Execution Monitoring

BASH
# View delegation execution status
/delegate status

# Output example:
# ┌─────────────┬──────────┬─────────┬──────────┐
# │ Sub-Agent   │ Status   │ Progress│ Cost     │
# ├─────────────┼──────────┼─────────┼──────────┤
# │ analyzer-1  │ ✅ Done  │ 5/5     │ $0.03    │
# │ analyzer-2  │ 🔄 Run   │ 3/5     │ $0.02    │
# │ analyzer-3  │ ⏳ Wait  │ 0/5     │ $0.00    │
# └─────────────┴──────────┴─────────┴──────────┘

(2) Error Handling

YAML
delegate:
  error_handling:
    on_sub_agent_fail: "retry"     # retry / skip / abort
    max_retries: 2
    retry_delay: 5
    
    on_timeout: "partial_result"   # partial_result / abort
    timeout_per_task: 120
    
    on_cost_exceed: "warn"         # warn / pause / abort

(3) Result Aggregation

BASH
Agent: [Aggregating sub-Agent results]
  
  📊 Comprehensive Analysis Report
  
  Sources: 3 sub-Agents, 15 files analyzed total
  
  Issue Summary:
  ├── 🔴 Critical: 2
  │   ├── api/auth.py: SQL injection risk
  │   └── utils/crypto.py: Hardcoded key
  ├── 🟡 Warning: 5
  └── 🔵 Suggestion: 8
  
  Priority: Fix 2 critical issues first
  Estimated fix time: 30 minutes

7. Advanced Delegation Scenarios

(1) Recursive Delegation

BASH
me: Analyze code quality of the entire monorepo

Agent: Monorepo has 5 packages, creating 5 sub-Agents:
  Each sub-Agent further decomposes by directory...
  
  🤖 Sub-Agent-frontend → creates 3 grandchild Agents
  🤖 Sub-Agent-backend → creates 4 grandchild Agents
  🤖 Sub-Agent-shared → processes directly
  🤖 Sub-Agent-infrastructure → processes directly
  🤖 Sub-Agent-tests → creates 2 grandchild Agents

(2) Human-Agent Collaborative Delegation

BASH
me: Help me complete the release process

Agent: Release process requires human confirmation, I'll execute step by step:
  
  Step 1: [Auto] Code review → ✅ Passed
  Step 2: [Auto] Run tests → ✅ Passed
  Step 3: [Awaiting confirmation] Deploy to staging?
  me: Confirmed
  Step 4: [Auto] Deploy staging → ✅ Done
  Step 5: [Awaiting confirmation] Deploy to production?
  me: Confirmed
  Step 6: [Auto] Deploy production → ✅ Done
  Step 7: [Auto] Notify team → ✅ Done

❓ FAQ

Q Do sub-Agents share memory with the main Agent?
A They share long-term memory and user models, but working memory is independent. Sub-Agents know user preferences but don't interfere with the main conversation context.
Q How many sub-Agents can be created?
A Default max 5, adjustable via delegate.strategy.max_sub_agents. Too many increases cost and coordination overhead.
Q What model do sub-Agents use?
A Default gpt-4o-mini for cost savings. Can be configured to use the same model as the main Agent.
Q Will parallel execution cause conflicts?
A File write operations are automatically locked to prevent concurrency conflicts. Read operations have no restrictions.
Q How is delegation cost calculated?
A Sub-Agent Token consumption is calculated independently but merged into the main account. /delegate status shows real-time cost per sub-Agent.
Q Does sub-Agent failure affect the overall result?
A Depends on configuration. Default skips failed tasks and aggregates completed ones. Can be configured to abort all.

📖 Summary


📝 Exercises

  1. Basic (⭐): Let the Agent use delegation to search 3 different topics in parallel, observe sub-Agent creation and result aggregation.
  2. Intermediate (⭐⭐): Configure sub-Agents to use a different model (gpt-4o-mini), verify cost savings, compare execution time vs sequential.
  3. Advanced (⭐⭐⭐): Design a recursive delegation scheme for monorepo code review, including error handling and cost control strategies.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏