# Delegation Model Routing

## Setup

Configured in `~/.hermes/config.yaml`:

```yaml
delegation:
  child_timeout_seconds: 600
  max_concurrent_children: 3
  max_iterations: 50
  max_spawn_depth: 1
  orchestrator_enabled: true
  subagent_auto_approve: false
  model: openrouter/anthropic/claude-opus-4.7
  provider: admin-ai
  fallback:
    model: deepseek-chat
    provider: admin-ai
```

## Routing architecture

| Layer | Model | Provider |
|---|---|---|
| **My conversation** | `deepseek-chat` (fast, cheap) | admin-ai |
| **Subagents (delegation)** | `Claude Opus 4.7` (smarter background work) | admin-ai |
| **Fallback** | `deepseek-chat` | admin-ai |

## Verified behavior

- Subagent model routing works — subagents dispatched with `delegate_task()` correctly run on Claude Opus 4.7
- The fallback to deepseek-chat fires if the primary model is unavailable
- The main conversation thread never drops or degrades — delegation runs in independent background processes
- `deepseek-v4-pro` also works as a delegation model but Claude Opus was preferred for smarter background reasoning

## Standing instruction: delegate by default

User established (Jul 5, 2026) that **independent tasks should be automatically delegated to subagents** rather than serialized in the main thread. This includes:

- Research tasks (product research, pricing, API documentation)
- Data extraction and processing (parsing emails, extracting PDFs, formatting data)
- Parallel workstreams (multiple independent investigations)
- Any task that can run independently without blocking the conversation

This is recorded in memory as a standing practice. The user should not have to request delegation — it's the default for any task that can be parallelized.

## Testing

```bash
# Verify models available
curl -s https://admin-ai.itpropartner.com/v1/models \
  -H "Authorization: Bearer $(grep 'api_key:' ~/.hermes/config.yaml | head -1 | awk '{print $2}')" \
  | python3 -c "import sys,json; [print(m['id']) for m in json.load(sys.stdin)['data'] if 'claude-opus' in m['id'].lower()]"

# Test a subagent dispatch (runs in background, result returns as async message)
delegate_task(goal="Respond with what model you're running on.", context="Delegation routing test")
```
