intelligent-routerIntelligent model routing for sub-agent task delegation. Choose the optimal model based on task complexity, cost, and capability requirements. Reduces costs...
Install via ClawdBot CLI:
clawdbot install bowen31337/intelligent-routerNew to this skill? Start here:
config.json.example to config.json (or customize the included config.json)config.json to add your available models with their costs and tierspython scripts/router.py classify "your task description"Example config entry:
{
"id": "anthropic/claude-sonnet-4",
"alias": "Claude Sonnet",
"tier": "COMPLEX",
"input_cost_per_m": 3.00,
"output_cost_per_m": 15.00,
"capabilities": ["text", "code", "reasoning", "vision"]
}
Major enhancements inspired by ClawRouter:
confidence = 1 / (1 + exp(-8 * (score - 0.5)))New CLI commands:
python scripts/router.py score "task" - Show detailed scoring breakdownThis skill teaches AI agents how to intelligently route sub-agent tasks to different LLM models based on task complexity, cost, and capability requirements. The goal is to reduce costs by routing simple tasks to cheaper models while preserving quality for complex work.
Use this skill whenever you:
Tasks are classified into five tiers based on complexity and risk:
| Tier | Description | Example Tasks | Model Characteristics |
|------|-------------|---------------|----------------------|
| 🟢 SIMPLE | Routine, low-risk operations | Monitoring, status checks, API calls, summarization | Cheapest available, good for repetitive tasks |
| 🟡 MEDIUM | Moderate complexity work | Code fixes, research, small patches, data analysis | Balanced cost/quality, good general purpose |
| 🟠 COMPLEX | Multi-component development | Feature builds, debugging, architecture, multi-file changes | High-quality reasoning, excellent code generation |
| 🧮 REASONING | Formal logic and proofs | Mathematical proofs, theorem derivation, step-by-step verification | Specialized reasoning models with chain-of-thought |
| 🔴 CRITICAL | High-stakes operations | Security audits, production deploys, financial operations | Best available model, maximum reliability |
Configure your available models in config.json and assign them to tiers. The router will automatically recommend models based on task classification.
Configuration pattern:
{
"models": [
{
"id": "{provider}/{model-name}",
"alias": "Human-Friendly Name",
"tier": "SIMPLE|MEDIUM|COMPLEX|CRITICAL",
"provider": "anthropic|openai|google|local|etc",
"input_cost_per_m": 0.50,
"output_cost_per_m": 1.50,
"context_window": 128000,
"capabilities": ["text", "code", "reasoning", "vision"],
"notes": "Optional notes about strengths/limitations"
}
]
}
Tier recommendations:
The router uses a sophisticated 15-dimension weighted scoring system to classify tasks accurately:
Scoring Dimensions (weights shown):
Confidence Calculation:
weighted_score = Σ(dimension_score × weight)
confidence = 1 / (1 + exp(-8 × (weighted_score - 0.5)))
This creates a smooth S-curve where:
View detailed scoring:
python scripts/router.py score "prove that sqrt(2) is irrational step by step"
# Shows breakdown of all 15 dimensions and top contributors
Tasks are automatically flagged as "agentic" if they involve:
Impact on routing:
"agentic": true flag are preferred for these tasksExample:
router.py classify "Build a React component with tests, then deploy it"
# → COMPLEX tier (agentic task detected)
router.py classify "Check the server status"
# → SIMPLE tier (not agentic)
Each tier now has a fallback chain (2-3 models) for automatic retry on failure:
Configured fallback chains:
{
"SIMPLE": {
"primary": "glm-4.7",
"fallback_chain": ["glm-4.7-backup", "glm-4.5-air", "ollama-qwen"]
},
"MEDIUM": {
"primary": "deepseek-v3.2",
"fallback_chain": ["llama-3.3-70b", "ollama-llama"]
},
"COMPLEX": {
"primary": "claude-sonnet-4.5",
"fallback_chain": ["gemini-3-pro", "nemotron-253b"]
},
"REASONING": {
"primary": "deepseek-r1-32b",
"fallback_chain": ["qwq-32b", "deepseek-reasoner"]
},
"CRITICAL": {
"primary": "claude-opus-4.6",
"fallback_chain": ["claude-opus-oauth", "claude-sonnet-4.5"]
}
}
Usage:
For coding tasks specifically:
Decision flow for coding:
IF task is simple code (lint, patch, single file):
→ {medium_model} as coder + optional {simple_model} QA
→ Only if (coder + QA cost) < {complex_model} solo
IF task is complex code (multi-file, architecture):
→ {complex_model} or {critical_model} directly
→ Skip delegation, skip QA — the model IS the quality
When spawning sub-agents, use the model parameter with IDs from your config.json:
# Use the router CLI to classify first (optional but recommended)
# $ python scripts/router.py classify "check GitHub notifications"
# → Recommends: SIMPLE tier, {simple_model}
# Simple task — monitoring
sessions_spawn(
task="Check GitHub notifications and summarize recent activity",
model="{simple_model}", # Use your configured SIMPLE tier model ID
label="github-monitor"
)
# Medium task — code fix
sessions_spawn(
task="Fix lint errors in utils.js and write changes to disk",
model="{medium_model}", # Use your configured MEDIUM tier model ID
label="lint-fix"
)
# Complex task — feature development
sessions_spawn(
task="Build authentication system with JWT, middleware, tests",
model="{complex_model}", # Use your configured COMPLEX tier model ID
label="auth-feature"
)
# Critical task — security audit
sessions_spawn(
task="Security audit of authentication code for vulnerabilities",
model="{critical_model}", # Use your configured CRITICAL tier model ID
label="security-audit"
)
Understanding cost structures helps optimize routing decisions:
Typical cost ranges per million tokens (input/output):
Cost estimation:
# Estimate cost before running
python scripts/router.py cost-estimate "build authentication system"
# Output: Tier: COMPLEX, Est. cost: $0.024 USD
Rule of thumb:
If a model produces unsatisfactory results:
Escalation path:
SIMPLE → MEDIUM → COMPLEX → CRITICAL
Quick classification rules for common patterns (now automated via weighted scoring):
SIMPLE tier indicators:
MEDIUM tier indicators:
COMPLEX tier indicators:
REASONING tier indicators (requires confidence ≥ 0.97):
CRITICAL tier indicators:
Classification is automatic: The weighted scoring system analyzes all 15 dimensions. These heuristics are for understanding what triggers each tier.
When in doubt: Go one tier up. Under-speccing costs more in retries than over-speccing costs in model quality.
Some models support extended thinking/reasoning which improves quality but increases cost:
Models with thinking support:
thinking="on" or thinking="budget_tokens:5000"When to use thinking:
When to avoid thinking:
# Enable thinking for complex architectural work
sessions_spawn(
task="Design scalable microservices architecture for payment system",
model="{complex_model}",
thinking="on", # or thinking="budget_tokens:5000"
label="architecture-design"
)
For large or uncertain tasks, use a cheaper model for initial work, then refine with a better model.
Note: Sub-agents are asynchronous — results come back as notifications, not synchronous returns.
# Phase 1: Draft with cheaper model
sessions_spawn(
task="Draft initial API design document outline",
model="{simple_model}",
label="draft-phase"
)
# Wait for draft-phase to complete and write output...
# Phase 2: Refine with capable model (after Phase 1 finishes)
sessions_spawn(
task="Review and refine the draft at /tmp/api-draft.md, add detailed specs",
model="{medium_model}",
label="refine-phase"
)
Savings: Process bulk content with cheap model, only use expensive model for refinement.
Group multiple similar SIMPLE tasks together to reduce overhead:
# Instead of spawning 10 separate agents:
tasks = [
"Check server1 status",
"Check server2 status",
# ... 10 tasks
]
# Batch them:
sessions_spawn(
task=f"Run these checks: {', '.join(tasks)}. Report any issues.",
model="{simple_model}",
label="batch-monitoring"
)
Start with MEDIUM tier, escalate to COMPLEX if needed:
# Try MEDIUM first
sessions_spawn(
task="Debug intermittent test failures in test_auth.py",
model="{medium_model}",
label="debug-attempt-1"
)
# If insufficient, escalate:
if debug_failed:
sessions_spawn(
task="Deep debug of test_auth.py failures (previous attempt incomplete)",
model="{complex_model}",
label="debug-attempt-2"
)
Before routing, consider:
The included router.py script helps with classification and cost estimation:
# Classify a task and get model recommendation
python scripts/router.py classify "fix authentication bug in login.py"
# Output: Classification: MEDIUM
# Recommended Model: {medium_model}
# List all configured models
python scripts/router.py models
# Output: Models grouped by tier
# Check configuration health
python scripts/router.py health
# Output: Validates config.json structure
# Estimate task cost
python scripts/router.py cost-estimate "build payment processing system"
# Output: Tier: COMPLEX, Est. tokens: 5000/3000, Cost: $0.060 USD
Integration tip: Run router.py classify before spawning agents to validate your tier selection.
{
"models": [
{
"id": "local/ollama-qwen-1.5b",
"alias": "Local Qwen",
"tier": "SIMPLE",
"provider": "ollama",
"input_cost_per_m": 0.00,
"output_cost_per_m": 0.00,
"context_window": 32768,
"capabilities": ["text"],
"notes": "Free local model, good for testing and simple tasks"
},
{
"id": "openai/gpt-4o-mini",
"alias": "GPT-4o Mini",
"tier": "MEDIUM",
"provider": "openai",
"input_cost_per_m": 0.15,
"output_cost_per_m": 0.60,
"context_window": 128000,
"capabilities": ["text", "code", "vision"],
"notes": "Great balance of cost and capability"
},
{
"id": "anthropic/claude-sonnet-4",
"alias": "Claude Sonnet",
"tier": "COMPLEX",
"provider": "anthropic",
"input_cost_per_m": 3.00,
"output_cost_per_m": 15.00,
"context_window": 200000,
"capabilities": ["text", "code", "reasoning", "vision"],
"notes": "Excellent for complex coding and analysis"
},
{
"id": "anthropic/claude-opus-4",
"alias": "Claude Opus",
"tier": "CRITICAL",
"provider": "anthropic",
"input_cost_per_m": 15.00,
"output_cost_per_m": 75.00,
"context_window": 200000,
"capabilities": ["text", "code", "reasoning", "vision", "function-calling"],
"notes": "Best available for critical operations"
}
]
}
python scripts/router.py health to validateFor additional guidance:
Classification:
Coding tasks:
Cost optimization:
General rule:
When in doubt, go one tier up — retries cost more than quality.
Generated Mar 1, 2026
Agencies can use the router to delegate tasks like bug fixes to cheaper models and complex feature development to high-quality models, optimizing client project costs while maintaining output quality. It helps manage multiple concurrent projects by automatically selecting the most cost-effective model for each subtask based on complexity scoring.
Firms can route routine data summarization and report generation to simple-tier models, while reserving complex-tier models for critical tasks like risk assessment and financial modeling. The reasoning tier handles mathematical derivations and proofs for quantitative analysis, ensuring accuracy without overspending on high-cost models for all tasks.
Platforms can use the router to generate simple explanations and summaries with low-cost models, and employ reasoning-tier models for creating step-by-step tutorials or solving complex math problems. This reduces operational costs while providing high-quality educational materials tailored to task complexity.
Companies can route basic customer queries and FAQ responses to simple-tier models for cost efficiency, while using medium or complex-tier models for handling intricate technical issues or multi-step troubleshooting. The agentic task detection helps identify when a support request requires higher-tier models for better resolution.
Labs can delegate literature reviews and data collection to simple models, use reasoning-tier models for formal proofs and experimental design, and reserve complex-tier models for innovative problem-solving and patent drafting. This structured routing maximizes research output while controlling computational expenses.
Offer the router as a cloud-based service with tiered pricing based on usage volume and model access, targeting businesses that need cost-effective AI task delegation. Revenue streams include monthly subscriptions, pay-per-use fees, and premium support for critical-tier model access.
Sell on-premise or custom deployments to large organizations requiring data privacy and integration with existing AI infrastructure. Revenue comes from one-time license fees, annual maintenance contracts, and consulting services for configuration and optimization.
Partner with consulting agencies and developers to white-label the router, enabling them to offer AI optimization services to their clients. Revenue is generated through partnership fees, revenue sharing on client projects, and training programs for effective router implementation.
💬 Integration Tip
Start by configuring a basic config.json with a few models per tier and use the CLI to test classifications before integrating into production workflows to ensure accurate routing.
Use CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
Gemini CLI for one-shot Q&A, summaries, and generation.
Research any topic from the last 30 days on Reddit + X + Web, synthesize findings, and write copy-paste-ready prompts. Use when the user wants recent social/web research on a topic, asks "what are people saying about X", or wants to learn current best practices. Requires OPENAI_API_KEY and/or XAI_API_KEY for full Reddit+X access, falls back to web search.
Check Antigravity account quotas for Claude and Gemini models. Shows remaining quota and reset times with ban detection.
Manages free AI models from OpenRouter for OpenClaw. Automatically ranks models by quality, configures fallbacks for rate-limit handling, and updates opencla...
Manages free AI models from OpenRouter for OpenClaw. Automatically ranks models by quality, configures fallbacks for rate-limit handling, and updates openclaw.json. Use when the user mentions free AI, OpenRouter, model switching, rate limits, or wants to reduce AI costs.