Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FaridLU/openclaw-task-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

OpenClaw Task Router 6 Specialist Models Auto Fallback

πŸ”€ OpenClaw Task Router

Production-grade multi-agent orchestration for OpenClaw
Route tasks to the best AI model. Get real-time status. Never wait at a blank terminal.

Quick Start Β· Agents Β· How It Works Β· Customize Β· Gist Mirror


What Is This?

A single prompt + config that turns your OpenClaw instance into an AI command center. Instead of one model doing everything poorly, 6 specialist agents handle what they're best at:

You Say Router Picks Model Why
"Plan the architecture" plan GLM-5.1 High reasoning for design decisions
"Build the payment module" build Kimi K2.6 Strong multi-file code generation
"Debug the 500 error" debug DeepSeek V4 Pro Deep code understanding, terminal work
"Review PR #42" review Kimi K2.6 Thorough analysis with high thinking
"Convert this screenshot to code" visual MiMo V2 Omni Vision-native model
"Find where sessions are handled" fast DeepSeek V4 Flash Cheap, fast, good enough

All models served via OpenCode β€” one API, one subscription, no per-provider keys needed.


✨ Features

  • 🧠 Smart Task Classification β€” automatically routes to the right specialist
  • ⚑ Async Delegation β€” spawns agents and returns instantly; no waiting
  • πŸ“Š 2-Minute Heartbeat β€” live status trees showing what's running, blocked, or done
  • πŸ”„ Automatic Fallback β€” when a model hits its rate limit, switches to the next best
  • πŸ›‘οΈ Hallucination Prevention β€” hard NEVER/ALWAYS constraints from production experience
  • πŸ” Loop Detection β€” catches stuck agents and intervenes
  • πŸ’° Cost Optimization β€” cheap models for simple tasks, powerful reasoning for complex ones

Quick Start

1. Install OpenClaw

npm install -g openclaw
openclaw onboard

See the OpenClaw docs for full setup.

2. Place AGENTS.md

# Clone this repo or download directly
mkdir -p ~/.openclaw/workspace
curl -o ~/.openclaw/workspace/AGENTS.md https://raw.githubusercontent.com/FaridLU/openclaw-task-router/main/AGENTS.md

Where does OpenClaw look for AGENTS.md? OpenClaw loads AGENTS.md from the workspace directory at session start. Default: ~/.openclaw/workspace/. Configure it in openclaw.json:

{ "agents": { "defaults": { "workspace": "/path/to/your/workspace" } } }

3. Configure the Agents

Add the openclaw.json from this repo to your OpenClaw config:

cp openclaw.json ~/.openclaw/openclaw.json
# Then edit to add your OpenCode API key and any personal preferences

Or manually add the 6 specialist agents to your existing config β€” see openclaw.json for the full template.

4. Start Routing

Just talk to OpenClaw normally:

Plan a microservices architecture for our e-commerce app
Debug the 500 error in production
Review PR #42

The router announces the chosen agent and model, then returns instantly. Every 2 minutes you'll see:

Router
β”œβ”€β”€ plan (Microservices architecture) β†’ GLM-5.1 (thinking: high) [RUNNING]
└── fast (Search session handling) β†’ DeepSeek V4 Flash (thinking: off) [FINISHED: Found in auth/views.py]

Agent Directory

Agent Best For Primary Model Thinking Fallback Chain
plan Architecture, specs, design docs GLM-5.1 High Kimi K2.6
build Features, refactors, multi-file Kimi K2.6 High DeepSeek V4 Pro β†’ Qwen 3.6 Plus
debug Production errors, terminal work DeepSeek V4 Pro Medium Kimi K2.6 β†’ DeepSeek V4 Flash
review Code review, security audits Kimi K2.6 High DeepSeek V4 Pro
visual Screenshots, mockups, UI analysis MiMo V2 Omni Off Qwen 3.6 Plus
fast Quick edits, search, tests, docs DeepSeek V4 Flash Off Qwen 3.5 Plus

All models via OpenCode (opencode-go/) provider β€” opencode.ai


How It Works

Request Flow

User β†’ Task Router β†’ Classify β†’ Spawn Specialist Agent β†’ Return to User
 ↓
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ plan β†’ GLM-5.1 (high thinking) β”‚
 β”‚ build β†’ Kimi K2.6 (high thinking) β”‚
 β”‚ debug β†’ DeepSeek V4 Pro (medium) β”‚
 β”‚ review β†’ Kimi K2.6 (high thinking) β”‚
 β”‚ visual β†’ MiMo V2 Omni (no thinking) β”‚
 β”‚ fast β†’ DeepSeek V4 Flash (no thinking)β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 ↓
 Agent finishes β†’ Result appears in session

Fallback Chain

If the primary model is unavailable (rate limit, outage, etc.):

plan: GLM-5.1 β†’ Kimi K2.6
build: Kimi K2.6 β†’ DeepSeek V4 Pro β†’ Qwen 3.6 Plus
debug: DeepSeek V4 Pro β†’ Kimi K2.6 β†’ DeepSeek V4 Flash
review: Kimi K2.6 β†’ DeepSeek V4 Pro
visual: MiMo V2 Omni β†’ Qwen 3.6 Plus
fast: DeepSeek V4 Flash β†’ Qwen 3.5 Plus

You never see the switch. The router handles it and reports fallbacks in the next heartbeat.


Customization

Swap Models

Replace any model in openclaw.json with your preferred provider:

{
 "id": "plan",
 "model": {
 "primary": "anthropic/claude-sonnet-4-20250514",
 "fallbacks": ["opencode-go/kimi-k2.6"]
 }
}

Works with any OpenRouter, OpenAI, Anthropic, or local model provider OpenClaw supports.

Add New Agents

Define new specialists in openclaw.json and add routing rules to AGENTS.md:

{
 "id": "security",
 "description": "Security audits and vulnerability scanning",
 "model": { "primary": "opencode-go/deepseek-v4-pro" }
}

Adjust Thinking Levels

Change high β†’ medium β†’ off per agent to trade reasoning depth for speed/cost:

{ "id": "fast", "thinking": "off" } // cheapest, fastest
{ "id": "debug", "thinking": "medium" } // balanced
{ "id": "plan", "thinking": "high" } // deepest reasoning

Why It Works

Problem Solution
One model does everything poorly 6 specialists, each best at their job
Expensive reasoning on simple tasks Fast agent uses Flash (cheap), complex tasks use Pro
Waiting at a blank screen Async delegation β€” instant confirmation
No visibility into agent status 2-minute heartbeat trees
Model outages break everything Automatic fallback chains
AI hallucinates nonexistent code Hard NEVER constraints + mandatory search-before-write

Repository Structure

openclaw-task-router/
β”œβ”€β”€ AGENTS.md ← The router prompt (copy to ~/.openclaw/workspace/)
β”œβ”€β”€ openclaw.json ← Full agent configuration (copy to ~/.openclaw/)
β”œβ”€β”€ README.md ← This file
β”œβ”€β”€ LICENSE ← MIT
β”œβ”€β”€ CHANGELOG.md ← Version history
└── examples/
 └── demo-session.md ← Example router conversation

Contributing

  1. Fork this repo
  2. Create your feature branch (git checkout -b feature/my-improvement)
  3. Commit your changes
  4. Push to the branch (git push origin feature/my-improvement)
  5. Open a Pull Request

This is a living project. Every time the router makes a mistake, update the Anti-Patterns section in AGENTS.md to encode the lesson.


Authors

  • Farid (@FaridLU) β€” OpenClaw power user who wanted the ultimate AI orchestration experience
  • Claw πŸ”€ β€” The OpenClaw Task Router agent that eats its own dogfood

Powered by OpenCode models β€” one API, six specialists, zero per-provider keys.


License

MIT β€” use it, fork it, share it.

About

πŸ€– Production-grade multi-agent task router for OpenClaw β€” 6 specialist agents, automatic model fallback, async delegation, and real-time status heartbeats. Powered by OpenCode models.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /