Agent Task Delegator
Brain-and-muscle delegation: premium model orchestrates, cheap models execute. Save 70%+ on API costs.
Quick Start
# Configure delegation rules
python3 scripts/agent-task-delegator.py config --show
# Set orchestrator model
python3 scripts/agent-task-delegator.py config --orchestrator "opus-4.6"
# Add a worker model for a task type
python3 scripts/agent-task-delegator.py config --add-worker coding --model "gpt-5.4"
python3 scripts/agent-task-delegator.py config --add-worker research --model "haiku-4.5"
python3 scripts/agent-task-delegator.py config --add-worker writing --model "gemma-4"
# Delegate a task
python3 scripts/agent-task-delegator.py delegate "Write a Python function to parse CSV files" --type coding
# Auto-classify and delegate
python3 scripts/agent-task-delegator.py delegate "Research the latest AI funding rounds in Q1 2026"
# View delegation history and performance
python3 scripts/agent-task-delegator.py history --last 20
# Show delegation stats (cost savings, success rates per worker)
python3 scripts/agent-task-delegator.py stats
# Test delegation without executing
python3 scripts/agent-task-delegator.py delegate "Debug this race condition" --dry-run
Architecture
┌─────────────────────────────────┐
│ Orchestrator (Opus 4.6) │ ← Plans, validates, decides
│ - Analyzes incoming task │
│ - Classifies task type │
│ - Selects worker model │
│ - Validates worker output │
└───────────┬─────────────────────┘
│ delegates to
┌───────┴───────┐
▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Worker 1 │ │ Worker 2 │ │ Worker 3 │
│ GPT-5.4 │ │ Haiku4.5 │ │ Gemma 4 │
│ (coding) │ │(research)│ │(writing) │
└──────────┘ └──────────┘ └──────────┘
Task Types
| Type | Default Worker | Use Cases |
|------|---------------|-----------|
| coding | gpt-5.4 | Write code, fix bugs, refactor |
| research | haiku-4.5 | Web search, data gathering, summarization |
| writing | haiku-4.5 | Articles, docs, emails, social posts |
| analysis | sonnet-4.6 | Data analysis, financial modeling, reports |
| creative | gemma-4 | Brainstorming, ideation, creative content |
| admin | haiku-4.5 | File management, formatting, simple transforms |
| security | opus-4.6 | Security audits, vulnerability analysis |
| orchestration | opus-4.6 | Multi-step planning, agent coordination |
Escalation
When a worker fails or produces poor output:
1. Retry once with same worker (different prompt framing)
2. Escalate to next tier model for that task type
3. Fall back to orchestrator model if all workers fail
4. Log failure for future routing optimization
Cost Tracking
Every delegation logs:
- Task type, worker model used
- Input/output token estimates
- Estimated cost
- Opus-baseline cost comparison
- Success/failure
- Escalation events
Configuration
Config at ~/.openclaw/workspace/delegator-config.json:
{
"orchestrator": "opus-4.6",
"workers": {
"coding": {"primary": "gpt-5.4", "fallback": "sonnet-4.6"},
"research": {"primary": "haiku-4.5", "fallback": "sonnet-4.6"},
"writing": {"primary": "haiku-4.5", "fallback": "gemma-4"},
"analysis": {"primary": "sonnet-4.6", "fallback": "opus-4.6"},
"creative": {"primary": "gemma-4", "fallback": "haiku-4.5"},
"admin": {"primary": "haiku-4.5", "fallback": "gemma-4"},
"security": {"primary": "opus-4.6", "fallback": "sonnet-4.6"},
"orchestration": {"primary": "opus-4.6", "fallback": "sonnet-4.6"}
},
"auto_escalate": true,
"max_retries": 1,
"track_file": "delegator-usage.jsonl"
}
Integration with OpenClaw
Add to AGENTS.md:
### Task Delegation
Use agent-task-delegator for all task execution:
1. Classify incoming task
2. Route to appropriate worker model
3. Validate output before returning
4. Log delegation for cost tracking