| name | intelligent-router |
| description | Intelligent model routing for sub-agent task delegation. Choose the optimal model based on task complexity, cost, and capability requirements. Reduces costs by routing simple tasks to cheaper models while preserving quality for complex work. |
| version | 3.1.0 |
| core | true |
Intelligent Router — Core Skill
CORE SKILL: This skill is infrastructure, not guidance. Installation = enforcement.
Run bash skills/intelligent-router/install.sh to activate.
What It Does
Automatically classifies any task into a tier (SIMPLE/MEDIUM/COMPLEX/REASONING/CRITICAL)
and recommends the cheapest model that can handle it well.
The problem it solves: Without routing, every cron job and sub-agent defaults to Sonnet
(expensive). With routing, monitoring tasks use free local models, saving 80-95% on cost.
MANDATORY Protocol (enforced via AGENTS.md)
Before spawning any sub-agent:
python3 skills/intelligent-router/scripts/router.py classify "task description"
Before creating any cron job:
python3 skills/intelligent-router/scripts/spawn_helper.py "task description"
To validate a cron payload has model set:
python3 skills/intelligent-router/scripts/spawn_helper.py --validate '{"kind":"agentTurn","message":"..."}'
❌ VIOLATION (never do this):
{"kind": "agentTurn", "message": "check server..."}
✅ CORRECT:
{"kind": "agentTurn", "message": "check server...", "model": "ollama/glm-4.7-flash"}
Tier System
| Tier | Use For | Primary Model | Cost |
|---|
| 🟢 SIMPLE | Monitoring, checks, summaries | ollama/glm-4.7-flash | FREE |
| 🟡 MEDIUM | Code fixes, patches, research | DeepSeek V3.2 | $0.40/M |
| 🟠 COMPLEX | Features, architecture, debug | Sonnet 4.6 | $3/M |
| 🔵 REASONING | Proofs, formal logic | DeepSeek R1 32B | $0.20/M |
| 🔴 CRITICAL | Security, production | Opus 4.6 | $5/M |
SIMPLE fallback chain: ollama/glm-4.7-flash → anthropic-proxy-4/glm-4.7 → anthropic-proxy-6/glm-4.5-air
Installation (Core Skill Setup)
Run once to self-integrate into AGENTS.md:
bash skills/intelligent-router/install.sh
This patches AGENTS.md with the mandatory protocol so it's always in context.
CLI Reference
python3 skills/intelligent-router/scripts/router.py classify "task"
python3 skills/intelligent-router/scripts/spawn_helper.py --model-only "task"
python3 skills/intelligent-router/scripts/spawn_helper.py "task"
python3 skills/intelligent-router/scripts/spawn_helper.py --validate '{"kind":"agentTurn","message":"..."}'
python3 skills/intelligent-router/scripts/router.py models
python3 skills/intelligent-router/scripts/router.py score "task"
python3 skills/intelligent-router/scripts/router.py health
python3 skills/intelligent-router/scripts/discover_models.py
python3 skills/intelligent-router/scripts/discover_models.py --auto-update
python3 skills/intelligent-router/scripts/discover_models.py --tier COMPLEX
Scoring System
15-dimension weighted scoring (not just keywords):
- Reasoning markers (0.18) — prove, theorem, derive
- Code presence (0.15) — code blocks, file extensions
- Multi-step patterns (0.12) — first...then, numbered lists
- Agentic task (0.10) — run, fix, deploy, build
- Technical terms (0.10) — architecture, security, protocol
- Token count (0.08) — complexity from length
- Creative markers (0.05) — story, compose, brainstorm
- Question complexity (0.05) — multiple who/what/how
- Constraint count (0.04) — must, require, exactly
- Imperative verbs (0.03) — analyze, evaluate, audit
- Output format (0.03) — json, table, markdown
- Simple indicators (0.02) — check, get, show (inverted)
- Domain specificity (0.02) — acronyms, dotted notation
- Reference complexity (0.02) — "mentioned above"
- Negation complexity (0.01) — not, never, except
Confidence: 1 / (1 + exp(-8 × (score - 0.5)))
Config
Models defined in config.json. Add new models there, router picks them up automatically.
Local Ollama models have zero cost — always prefer them for SIMPLE tasks.
Auto-Discovery (Self-Healing)
The intelligent-router can automatically discover working models from all configured providers:
How It Works
- Provider Scanning: Reads
~/.openclaw/openclaw.json → tests each model
- Health Check: Sends minimal test prompt to verify auth + connectivity
- Auto-Classification: Assigns tiers based on cost, capabilities, provider
- Config Update: Replaces unavailable models (like broken OAuth tokens)
- Cron Integration: Hourly refresh keeps model list current
Usage
python3 skills/intelligent-router/scripts/discover_models.py
python3 skills/intelligent-router/scripts/discover_models.py --auto-update
openclaw cron add --job '{
"name": "Model Discovery Refresh",
"schedule": {"kind": "every", "everyMs": 3600000},
"payload": {
"kind": "systemEvent",
"text": "Run: bash skills/intelligent-router/scripts/auto_refresh_models.sh",
"model": "ollama/glm-4.7-flash"
}
}'
Benefits
✅ Self-healing: Automatically removes broken models (e.g., expired OAuth)
✅ Zero maintenance: No manual model list updates
✅ New models: Auto-adds newly released models
✅ Cost optimization: Always uses cheapest working model per tier
Discovery Output
Results saved to skills/intelligent-router/discovered-models.json:
{
"scan_timestamp": "2026-02-19T21:00:00",
"total_models": 25,
"available_models": 23,
"unavailable_models": 2,
"providers": {
"anthropic": {
"available": 2,
"unavailable": 0,
"models": [...]
}
}
}
Pinning Models
To preserve a model even if it fails discovery:
{
"id": "special-model",
"tier": "COMPLEX",
"pinned": true
}