Skip to content

feat(delegate): orchestrator role and configurable spawn depth (default flat)#13691

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-914ac272
Apr 21, 2026
Merged

feat(delegate): orchestrator role and configurable spawn depth (default flat)#13691
teknium1 merged 1 commit into
mainfrom
hermes/hermes-914ac272

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Adds role="leaf"|"orchestrator" on delegate_task. When delegation.max_spawn_depth >= 2, an orchestrator child retains the delegation toolset and can spawn its own workers. Default stays flat (depth 1 = current behavior) — users opt in by raising max_spawn_depth in config.yaml.

Also fixes a silent drop of acp_command/acp_args on the main agent loop's delegate path, and adds a DelegateEvent enum with legacy-string back-compat for gateway/ACP/CLI progress consumers.

Salvaged from @pefontana's #11215 with these deliberate overrides:

Original PR This PR
max_concurrent_children default 5 (with hard cap 8) 3 (floor-only, no upper cap)
max_spawn_depth default 2 (nested enabled for everyone) 1 (flat — nested is opt-in)
max_spawn_depth range 1-3 1-3 (unchanged)

Changes

  • tools/delegate_tool.py: role param on schema + delegate_task() signature; _dispatch_delegate_task helper (fixes acp_args drop); _build_child_agent degrades role to leaf when depth >= max_spawn_depth OR the kill switch is off; role-aware system prompt; DelegateEvent enum + _LEGACY_EVENT_MAP + _build_child_progress_callback accepts enum + new-style strings + legacy strings; dedicated TASK_PROGRESS render branch (no more misrendering batched summaries as tool names).
  • hermes_cli/config.py defaults: max_concurrent_children: 3, max_spawn_depth: 1, orchestrator_enabled: true.
  • cli-config.yaml.example, website/docs/user-guide/features/delegation.md, guides/delegation-patterns.md, features/overview.md, hermes_cli/tips.py: docs + example config updated to match the flat-by-default posture.
  • Tests: 54 new tests covering dispatch helper, event enum, concurrency floor-but-no-ceiling, spawn-depth clamping (1-3), role plumbing (schema + signature + stash), role-aware prompt branches, batch mode per-task role override, and an end-to-end parent → orchestrator → 2 leaves nested orchestration test (all require explicitly setting max_spawn_depth: 2 in their mock config since the default is now flat).

Validation

Result
py_compile on all changed files clean
pytest tests/tools/test_delegate.py tests/hermes_cli/test_config_drift.py tests/agent/test_subagent_progress.py 126 passed
E2E (isolated HERMES_HOME, real config.yaml, real delegate_task dispatch) Default config → orchestrator role silently degrades to leaf + delegation toolset stripped; max_spawn_depth: 2 → role honored, delegation toolset re-added
E2E uncapped concurrency max_concurrent_children: 50 returns 50 (no ceiling); 0 floors to 1
E2E depth clamping max_spawn_depth: 99 clamps to 3; max_spawn_depth: 0 clamps to 1

Rollout

Existing users see zero behavior change at defaults: delegation is still flat, still 3 parallel children, orchestrator role is a no-op. Raising max_spawn_depth to 2 or 3 is an explicit opt-in documented in cli-config.yaml.example and the delegation docs.

Closes the orchestrator portion of #11215. Credit to @pefontana — commit authorship preserved via rebase-merge.

…lt flat)

Adds role='leaf'|'orchestrator' to delegate_task. With max_spawn_depth>=2,
an orchestrator child retains the 'delegation' toolset and can spawn its
own workers; leaf children cannot delegate further (identical to today).

Default posture is flat — max_spawn_depth=1 means a depth-0 parent's
children land at the depth-1 floor and orchestrator role silently
degrades to leaf. Users opt into nested delegation by raising
max_spawn_depth to 2 or 3 in config.yaml.

Also threads acp_command/acp_args through the main agent loop's delegate
dispatch (previously silently dropped in the schema) via a new
_dispatch_delegate_task helper, and adds a DelegateEvent enum with
legacy-string back-compat for gateway/ACP/CLI progress consumers.

Config (hermes_cli/config.py defaults):
  delegation.max_concurrent_children: 3   # floor-only, no upper cap
  delegation.max_spawn_depth: 1           # 1=flat (default), 2-3 unlock nested
  delegation.orchestrator_enabled: true   # global kill switch

Salvaged from @pefontana's PR #11215. Overrides vs. the original PR:
concurrency stays at 3 (PR bumped to 5 + cap 8 — we keep the floor only,
no hard ceiling); max_spawn_depth defaults to 1 (PR defaulted to 2 which
silently enabled one level of orchestration for every user).

Co-authored-by: pefontana <fontana.pedro93@gmail.com>
@teknium1 teknium1 merged commit 48ecb98 into main Apr 21, 2026
12 of 13 checks passed
@teknium1 teknium1 deleted the hermes/hermes-914ac272 branch April 21, 2026 21:23
@teknium1 teknium1 mentioned this pull request Apr 21, 2026
9 tasks
@alt-glitch alt-glitch added type/feature New feature or request tool/delegate Subagent delegation comp/agent Core agent loop, run_agent.py, prompt builder labels Apr 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Supersedes #11215 with flat-by-default posture (max_spawn_depth=1 vs original's 2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants