Déléguer des tâches à des sous-agents
Cette page fait partie du guide pratique francophone consacré à Hermes Agent. Elle répond à l'intention de recherche : utiliser la délégation.
Le contenu s'appuie sur la documentation officielle Hermes Agent associée à cette page. L'objectif n'est pas de remplacer la documentation de Nous Research, mais de fournir une lecture claire en français, structurée pour aller vite, avec un maillage logique vers les pages complémentaires du même site.
À retenir
- Sujet principal : hermes agent delegation.
- Type de page : spoke.
- Cluster : automatisation.
- Source canonique : documentation officielle Hermes Agent.
- Aucun lien vers l'autre domaine n'est utilisé dans cette page.
Quand utiliser cette page
Utilisez cette page quand vous voulez utiliser la délégation. Elle part du principe que Hermes Agent est déjà identifié comme l'outil à mettre en place ou à comprendre, puis détaille les points importants issus de la documentation officielle.
Si vous découvrez seulement l'outil, revenez d'abord au hub parent puis suivez les liens internes proposés en fin de page.
Base officielle
The delegate_task tool spawns child AIAgent instances with isolated context, restricted toolsets, and their own terminal sessions. Each child gets a fresh conversation and works independently — only its final summary enters the parent's context.
Single Task
delegate_task(
goal="Debug why tests fail",
context="Error: assertion in test_foo.py line 42",
toolsets=["terminal", "file"]
)
Parallel Batch
Up to 3 concurrent subagents by default (configurable, no hard ceiling):
delegate_task(tasks=[
{"goal": "Research topic A", "toolsets": ["web"]},
{"goal": "Research topic B", "toolsets": ["web"]},
{"goal": "Fix the build", "toolsets": ["terminal", "file"]}
])
How Subagent Context Works
Subagents start with a completely fresh conversation. They have zero knowledge of the parent's conversation history, prior tool calls, or anything discussed before delegation. The subagent's only context comes from the goal and context fields the parent agent populates when it calls delegate_task.
This means the parent agent must pass everything the subagent needs in the call:
delegate_task(goal="Fix the error")
delegate_task(
goal="Fix the TypeError in api/handlers.py",
context="""The file api/handlers.py has a TypeError on line 47:
'NoneType' object has no attribute 'get'.
The function process_request() receives a dict from parse_body(),
but parse_body() returns None when Content-Type is missing.
The project is at /home/user/myproject and uses Python 3.11."""
)
The subagent receives a focused system prompt built from your goal and context, instructing it to complete the task and provide a structured summary of what it did, what it found, any files modified, and any issues encountered.
Practical Examples
Parallel Research
Research multiple topics simultaneously and collect summaries:
delegate_task(tasks=[
{
"goal": "Research the current state of WebAssembly in 2025",
"context": "Focus on: browser support, non-browser runtimes, language support",
"toolsets": ["web"]
},
{
"goal": "Research the current state of RISC-V adoption in 2025",
"context": "Focus on: server chips, embedded systems, software ecosystem",
"toolsets": ["web"]
},
{
"goal": "Research quantum computing progress in 2025",
"context": "Focus on: error correction breakthroughs, practical applications, key players",
"toolsets": ["web"]
}
])
Code Review + Fix
Delegate a review-and-fix workflow to a fresh context:
delegate_task(
goal="Review the authentication module for security issues and fix any found",
context="""Project at /home/user/webapp.
Auth module files: src/auth/login.py, src/auth/jwt.py, src/auth/middleware.py.
The project uses Flask, PyJWT, and bcrypt.
Focus on: SQL injection, JWT validation, password handling, session management.
Fix any issues found and run the test suite (pytest tests/auth/).""",
toolsets=["terminal", "file"]
)
Multi-File Refactoring
Delegate a large refactoring task that would flood the parent's context:
delegate_task(
goal="Refactor all Python files in src/ to replace print() with proper logging",
context="""Project at /home/user/myproject.
Use the 'logging' module with logger = logging.getLogger(__name__).
Replace print() calls with appropriate log levels:
- print(f"Error: ...") -> logger.error(...)
- print(f"Warning: ...") -> logger.warning(...)
- print(f"Debug: ...") -> logger.debug(...)
- Other prints -> logger.info(...)
Don't change print() in test files or CLI output.
Run pytest after to verify nothing broke.""",
toolsets=["terminal", "file"]
)
Batch Mode Details
When you provide a tasks array, subagents run in parallel using a thread pool:
- Maximum concurrency: 3 tasks by default (configurable via
delegation.max_concurrent_childrenor theDELEGATION_MAX_CONCURRENT_CHILDRENenv var; floor of 1, no hard ceiling). Batches larger than the limit return a tool error rather than being silently truncated. - Thread pool: Uses
ThreadPoolExecutorwith the configured concurrency limit as max workers - Progress display: In CLI mode, a tree-view shows tool calls from each subagent in real-time with per-task completion lines. In gateway mode, progress is batched and relayed to the parent's progress callback
- Result ordering: Results are sorted by task index to match input order regardless of completion order
- Interrupt propagation: Interrupting the parent (e.g., sending a new message) interrupts all active children
Single-task delegation runs directly without thread pool overhead.
Model Override
You can configure a different model for subagents via config.yaml — useful for delegating simple tasks to cheaper/faster models:
delegation:
model: "google/gemini-flash-2.0" # Cheaper model for subagents
provider: "openrouter" # Optional: route subagents to a different provider
If omitted, subagents use the same model as the parent.
Toolset Selection Tips
The toolsets parameter controls what tools the subagent has access to. Choose based on the task:
- Toolset Pattern — Use Case
["terminal", "file"]— Code work, debugging, file editing, builds["web"]— Research, fact-checking, documentation lookup["terminal", "file", "web"]— Full-stack tasks (default)["file"]— Read-only analysis, code review without execution["terminal"]— System administration, process management
Certain toolsets are blocked for subagents regardless of what you specify:
delegation— blocked for leaf subagents (the default). Retained forrole="orchestrator"children, bounded bymax_spawn_depth— see Depth Limit and Nested Orchestration below.clarify— subagents cannot interact with the usermemory— no writes to shared persistent memorycode_execution— children should reason step-by-step
Max Iterations
Each subagent has an iteration limit (default: 50) that controls how many tool-calling turns it can take:
delegate_task(
goal="Quick file check",
context="Check if /etc/nginx/nginx.conf exists and print its first 10 lines",
max_iterations=10 # Simple task, don't need many turns
)
Child Timeout
By default there is no wall-clock timeout on subagents. Children fail only from what they're actually doing — API errors, tool errors, or hitting their iteration budget — never from a delegation-level stopwatch. Earlier releases shipped a hard cap (300s, later 600s), which kept killing legitimately busy children mid-task: deep code reviews, large research fan-outs, and slow reasoning models routinely need more than 10 minutes while making steady progress the whole time.
Genuinely stuck children are still detected: the heartbeat staleness monitor stops refreshing the parent's activity when a child makes no progress (no API calls, no tool starts), letting the gateway inactivity timeout fire on a truly wedged worker.
If you want a hard cap anyway (e.g. cost control on unattended cron-driven delegation), opt in per-install:
delegation:
child_timeout_seconds: 0 # default: 0 = no timeout
# child_timeout_seconds: 1800 # opt-in hard cap (floor 30s)
A positive value enforces a hard wall-clock limit on each child; 0 or a negative value disables it.
With a hard cap configured, if a subagent times out having made zero API calls (usually: provider unreachable, auth failure, or tool-schema rejection), delegate_task writes a structured diagnostic to ~/.hermes/logs/subagent-timeout-<session>-<timestamp>.log containing the subagent's config snapshot, credential-resolution trace, and any early error messages. Much easier to root-cause than the previous silent-timeout behavior.
Monitoring Running Subagents (/agents)
The TUI ships a /agents overlay (alias /tasks) that turns recursive delegate_task fan-out into a first-class audit surface:
- Live tree view of running and recently-finished subagents, grouped by parent
- Per-branch cost, token, and file-touched rollups
- Kill and pause controls — cancel a specific subagent mid-flight without interrupting its siblings
- Post-hoc review: step through each subagent's turn-by-turn history even after they've returned to the parent
The classic CLI just prints /agents as a text summary; the TUI is where the overlay shines. See TUI — Slash commands.
Depth Limit and Nested Orchestration
By default, delegation is flat: a parent (depth 0) spawns children (depth 1), and those chi
Points de vigilance
- Vérifiez toujours la version active de Hermes Agent avant d'appliquer une commande ou une configuration.
- Ne collez pas de clé API dans un chat public ou dans une page visible.
- Gardez les secrets dans les fichiers ou gestionnaires prévus pour cela.
- Si une fonctionnalité dépend d'un provider, d'un plugin ou d'une plateforme de messagerie, vérifiez que le composant est bien activé dans votre profil.
- Pour une installation de production, testez d'abord le flux complet sur une machine ou un profil isolé.
Exemple de parcours logique
- Lire la page courante pour comprendre hermes agent delegation.
- Ouvrir le hub parent du cluster automatisation.
- Passer ensuite aux pages complémentaires proposées dans « À lire ensuite ».
- Revenir à la documentation officielle si vous avez besoin du détail exact ou d'une commande récemment modifiée.
FAQ rapide
Cette page remplace-t-elle la documentation officielle ?
Non. Elle sert de guide francophone structuré. Le lien vers la source officielle est disponible en bas de page.
Les commandes sont-elles garanties à jour ?
Elles sont basées sur la documentation officielle récupérée au moment de la génération. Pour un usage critique, vérifiez toujours la page officielle liée en bas.
Pourquoi autant de liens internes ?
Hermes Agent est un système modulaire. L'installation, les providers, les outils, la mémoire, les skills, la sécurité et les plateformes se répondent. Le maillage interne aide à suivre ce chemin sans tomber sur des pages orphelines.