Per-task model selection for Hermes Agent subagents — route coding to Claude, research to Gemini, quick lookups to Flash, all in one parallel batch.
delegate_task can't select different models per subagent. This skill orchestrates independent hermes chat -q processes, each with its own -m flag, using asyncio.TaskGroup + asyncio.Semaphore(3) for true parallel execution with structured concurrency.
delegate_task |
dynamic-model-delegation | |
|---|---|---|
| Per-task model selection | ❌ Single model for all subagents | ✅ Different model per task |
| Parallel execution | ✅ Built-in | ✅ asyncio.TaskGroup |
| Structured concurrency | ❌ | ✅ Fail-fast, cancel siblings |
| Zombie process prevention | ❌ | ✅ terminate → wait → kill cascade |
| Characteristic-based routing | ❌ | ✅ coding→Claude, research→Gemini, etc. |
tasks: [{goal, characteristic}, {goal, model}, ...]
│
▼
orchestrator (asyncio.TaskGroup + Semaphore(3))
│
┌────┼────┐
▼ ▼ ▼
hermes hermes hermes ← each with its own -m flag
-m X -m Y -m Z
│
▼
JSON results: [{goal, model, success, result}, ...]
Engine selection:
asyncioavailable + >1 task → parallel (TaskGroup + Semaphore)- Otherwise → sequential (
subprocess.runfallback) - Override:
HERMES_ORCHESTRATOR_MODE=sequential
| characteristic | model | best for |
|---|---|---|
coding |
openrouter/anthropic/claude-sonnet-4 |
Code generation, PR review, architecture |
research |
google/gemini-2.5-flash |
Web research, summarization, long-context |
quick |
deepseek/deepseek-v4-flash |
Fast lookups, syntax checks |
reasoning |
deepseek/deepseek-v4-pro |
Complex reasoning, planning |
creative |
openrouter/anthropic/claude-sonnet-4 |
Design, creative writing |
Characteristic is inferred from goal keywords when not explicit (e.g., "implement" → coding, "research" → research).
Mode 1 — Background (fire-and-forget): Spawn subagents via terminal(background=True). Results arrive asynchronously. Best for long-running tasks.
Mode 2 — Synchronous (execute_code): Call scripts/orchestrate.py with JSON tasks. Returns compiled results inline. Best for quick batches.
# Pass tasks as JSON arg
python3 scripts/orchestrate.py '[{"goal":"What is the capital of France?","characteristic":"quick"},{"goal":"Explain recursion","characteristic":"reasoning"}]'
# Or via stdin
echo '[{"goal":"...","characteristic":"coding"}]' | python3 scripts/orchestrate.pyOutput:
{
"summary": "2/2 tasks succeeded",
"results": [
{
"goal": "What is the capital of France?",
"model": "deepseek/deepseek-v4-flash",
"success": true,
"exit_code": 0,
"result": "Paris."
}
]
}# Clone into Hermes skills directory
git clone https://github.com/<your-username>/dynamic-model-delegation.git \
~/.hermes/skills/autonomous-ai-agents/dynamic-model-delegation
# Start a new Hermes session (or run /reload-skills in an existing session)
hermesThen load the skill: /skill dynamic-model-delegation
Verify it works:
python3 ~/.hermes/skills/autonomous-ai-agents/dynamic-model-delegation/scripts/orchestrate.py \
'[{"goal":"Reply with exactly: pong","characteristic":"quick"}]'
# Expected: {"summary": "1/1 tasks succeeded", ...}-
Hermes Agent v0.14.0+ — check with
hermes --version -
Python 3.11+ — check with
python3 --version -
API keys for your chosen model providers in
~/.hermes/.env. The default model map uses:DEEPSEEK_API_KEY(for quick + reasoning characteristics)OPENROUTER_API_KEY(for coding + creative)GOOGLE_API_KEYorGEMINI_API_KEY(for research)
You are not locked into these providers. Edit
references/model-mapping.mdand theMODEL_MAPdict inscripts/orchestrate.pyto use any provider supported by Hermes Agent. Seehermes modelfor available options. -
Test dependencies (only needed to run tests):
pip install pytest
dynamic-model-delegation/
├── SKILL.md # Skill definition (Hermes frontmatter + full docs)
├── README.md # This file
├── LICENSE # MIT
├── CHANGELOG.md # Keep a Changelog format
├── CONTRIBUTING.md # Contribution guidelines
├── SECURITY.md # Security policy and defenses
├── scripts/
│ ├── orchestrate.py # Dual-engine orchestrator
│ ├── test_orchestrate.py # 29 unit + 7 integration tests
│ └── pytest.ini # Marker registration
└── references/
├── model-mapping.md # Characteristic → model table (user-editable)
├── asyncio-research.md # Asyncio design rationale with source citations
└── multi-model-review-pattern.md # 4-reviewer adversarial review template
- Python 3.11+
- Hermes Agent v0.14.0+
- API keys for target model providers in
~/.hermes/.env
# Install test dependencies
pip install pytest
# Unit tests (fast, no subprocess)
python3 -m pytest scripts/test_orchestrate.py -v -k "not integration"
# Integration tests (requires hermes binary, slower)
python3 -m pytest scripts/test_orchestrate.py -v -k "integration" -n 0
# Full suite (-n 0 disables xdist — required because tests spawn subprocesses)
python3 -m pytest scripts/test_orchestrate.py -v -n 0MIT — see LICENSE.