Hive Task Router
Smart task distribution system for OpenClaw — Automatically routes tasks to optimal models and execution modes based on task type recognition.
Universal Model Support — Works with any AI model provider (Bailian, OpenAI, Anthropic, etc.) via environment variable configuration.
When to Use
Automatic Trigger Rules (For AI Agents)
Use this skill automatically when the user's message contains ANY of these patterns:
| Trigger Pattern | Keywords | Action |
|---|
| Code tasks | 代码、编程、脚本、函数、nodejs、react、vue、typescript、javascript、html、css、前端、后端、api、接口、调试、bug、优化、重构 | Run router.sh → Execute with code model + subagent |
| Web research |
搜索、查找、调研、研究、github、项目、趋势、报告、分析、对比、评测、最新、2026、新闻、动态 | Run
router.sh → Execute with
web model + subagent |
|
Data tasks | 数据、分析、统计、图表、可视化、excel、csv、json、处理、转换 | Run
router.sh → Execute with
data model + subagent |
|
Documentation | 文档、说明、教程、指南、手册、readme、wiki、注释、文档化 | Run
router.sh → Execute with
doc model + subagent |
|
Batch tasks | 多个、批量、同时、并行、一起 | Run
router.sh for each → Execute in parallel |
Do NOT use this skill when:
- - Simple chat/conversation (你好、谢谢、安排、计划、汇报、总结)
- Quick questions (what is, how to, explain)
- Tasks already in progress
- User explicitly says "don't use subagent" or "just answer directly"
Manual Trigger (For Users)
Users can explicitly trigger this skill by:
- - Running
router.sh "task description" directly - Saying "use hive router" or "analyze this task"
- Asking "which model should I use for this task"
Decision Flow for AI Agents
CODEBLOCK0
Vague Task Handling
When user message is vague (e.g., "做个任务", "帮忙处理一下", "搞定这件事"):
Step 1: Acknowledge and ask
CODEBLOCK1
Step 2: User clarifies
CODEBLOCK2
Vague Keywords (trigger clarification):
- - 任务、帮忙、处理、搞定、完成、做一下、弄一下
- 这个、那个、一件事、一个东西
Specific Keywords (trigger automatic routing):
- - code: 脚本、代码、编程、函数、nodejs、react...
- web: 搜索、调研、分析、趋势、报告、对比...
- data: 数据、统计、图表、excel、csv、json...
- doc: 文档、教程、指南、readme、wiki...
Ideal scenarios:
- - Handling multiple concurrent tasks
- Technical development requiring code-specialized models
- Research tasks needing web search capabilities
- Mixed workloads with varying complexity
- Multi-provider environments (Bailian + OpenAI + Anthropic)
Quick Reference
Task Type Recognition Keywords
| Type | Keywords (Chinese) | Keywords (English) | Priority |
|---|
| web 🔍 | 搜索、查找、调研、研究、github、项目、趋势、报告、分析、对比、评测、最新、2026、新闻、动态 | search, research, github, project, trend, report, analysis, comparison, latest, news | 1 (Highest) |
| code 💻 |
代码、编程、脚本、函数、nodejs、react、vue、typescript、javascript、html、css、前端、后端、api、接口、调试、bug、优化、重构 | code, programming, script, function, nodejs, react, vue, typescript, javascript, html, css, frontend, backend, api, debug, bug, optimize, refactor | 2 |
|
data 📊 | 数据、分析、统计、图表、可视化、excel、csv、json、处理、转换 | data, analysis, statistics, chart, visualization, excel, csv, json, processing, conversion | 3 |
|
doc 📄 | 文档、说明、教程、指南、手册、readme、wiki、注释、文档化 | documentation, guide, tutorial, manual, readme, wiki, comment, document | 4 |
|
chat 💬 | 你好、谢谢、再见、今天、明天、安排、计划、汇报、总结、提醒、备忘 | hello, thanks, goodbye, today, tomorrow, plan, schedule, summary, reminder, memo | 5 (Default) |
Model Selection Rules
Note: Model IDs are configurable via environment variables. Replace provider/ with your actual model provider (e.g., bailian/, openai/, anthropic/).
| Task Type | Default Model | Environment Variable | Reason |
|---|
| code | INLINECODE14 | INLINECODE15 | Specialized in code generation and debugging |
| web |
provider/qwen3-max |
HIVE_MODEL_WEB | Strong search and reasoning capabilities |
|
data |
provider/qwen3-coder-plus |
HIVE_MODEL_DATA | Code-based data processing |
|
doc |
provider/qwen3.5-plus |
HIVE_MODEL_DOC | Good text generation, cost-effective |
|
chat |
provider/qwen3.5-plus |
HIVE_MODEL_CHAT | Best for casual conversation, cost-effective |
Model Configuration Examples
Bailian (通义千问):
CODEBLOCK3
Model Validation Modes
Automatic Model Detection (Recommended):
CODEBLOCK4
First run: Detects models and caches configuration
Subsequent runs: Uses cached config (24h TTL)
Benefit: No manual configuration needed!
Manual Validation Modes:
| Mode | Environment Variable | Behavior | Use Case |
|---|
| Auto (Recommended) | INLINECODE24 | Auto-detect + cache 24h | Best for most users |
| Cache |
export HIVE_VALIDATE_MODEL=cache | Validate once, cache 24h | Manual config, stable |
|
Always |
export HIVE_VALIDATE_MODEL=1 | Validate every execution | Debugging, changes |
|
Never |
export HIVE_VALIDATE_MODEL=0 | Skip validation | Production, known config |
Cache Configuration:
CODEBLOCK5
Validation Behavior:
- - ✅ Checks if model IDs contain
provider/ placeholder - ✅ Warns if placeholder detected
- ✅ Caches validation result (configurable TTL)
- ✅ Non-blocking (warnings only, doesn't stop execution)
OpenAI:
CODEBLOCK6
Anthropic (Claude):
CODEBLOCK7
Mixed Providers:
CODEBLOCK8
Execution Mode Rules
| Task Type | Execution Mode | Reason |
|---|
| chat | Main Session | Quick response, no need for isolation |
| code/web/data/doc |
Subagent | Long-running tasks, parallel execution, session isolation |
Priority Rule: When multiple keywords match, use the highest priority type (web > code > data > doc > chat).
Usage
For AI Agents (Automatic Integration)
When installed as an OpenClaw Skill, the agent will automatically use this skill when:
- 1. User message contains task keywords (code/web/data/doc/batch)
- Task is long-running (not a simple Q&A)
- Multiple tasks need parallel execution
Agent Decision Example:
CODEBLOCK9
Configuration for Agents:
Add to agent's AGENTS.md or SOUL.md:
## Hive Task Router Integration
When receiving tasks:
1. Check if message contains task keywords (see SKILL.md)
2. If yes → Use hive-task-router skill
3. If no → Handle directly
Method 1: Router Script (Recommended)
The router script automatically analyzes tasks and outputs recommended execution commands.
CODEBLOCK11
Output format:
CODEBLOCK12
Method 2: Manual Commands
Code Tasks
CODEBLOCK13
Web Research Tasks
CODEBLOCK14
Chat Tasks (Main Session)
CODEBLOCK15
Data Processing Tasks
CODEBLOCK16
Documentation Tasks
CODEBLOCK17
Method 3: Parallel Execution
For batch tasks, use parallel subagents:
CODEBLOCK18
Examples
Example 1: Code Development Task
User Input:
CODEBLOCK19
Router Analysis:
- - Matched Keywords: Node.js, 脚本,文件处理
- Task Type: code
- Recommended Model: bailian/qwen3-coder-plus
- Execution Mode: subagent
Execution Command:
openclaw sessions spawn \
--mode run \
--runtime subagent \
--model bailian/qwen3-coder-plus \
--task "帮我写一个 Node.js 文件处理脚本,支持读取 CSV 和 JSON 格式"
Example 2: Web Research Task
User Input:
CODEBLOCK21
Router Analysis:
- - Matched Keywords: 搜索,2026, 趋势,对比
- Task Type: web (Priority 1)
- Recommended Model: bailian/qwen3-max-2026-01-23
- Execution Mode: subagent
Execution Command:
openclaw sessions spawn \
--mode run \
--runtime subagent \
--model bailian/qwen3-max-2026-01-23 \
--task "搜索 2026 年最新的前端趋势,包括 React、Vue、Svelte 的对比"
Example 3: Daily Chat Task
User Input:
CODEBLOCK23
Router Analysis:
- - Matched Keywords: 今天,安排,总结
- Task Type: chat
- Recommended Model: bailian/qwen3.5-plus
- Execution Mode: main_session
Execution Command:
openclaw agent \
--session-id agent:main:chat \
--model bailian/qwen3.5-plus \
--message "今天有什么安排?帮我总结一下昨天的工作"
Example 4: Data Analysis Task
User Input:
CODEBLOCK25
Router Analysis:
- - Matched Keywords: 分析,数据,Excel, 图表,统计
- Task Type: data
- Recommended Model: bailian/qwen3-coder-plus
- Execution Mode: subagent
Execution Command:
openclaw sessions spawn \
--mode run \
--runtime subagent \
--model bailian/qwen3-coder-plus \
--task "分析这个销售数据 Excel 文件,生成可视化图表和统计报告"
Example 5: Documentation Task
User Input:
CODEBLOCK27
Router Analysis:
- - Matched Keywords: 文档,教程
- Task Type: doc
- Recommended Model: bailian/qwen3.5-plus
- Execution Mode: subagent
Execution Command:
openclaw sessions spawn \
--mode run \
--runtime subagent \
--model bailian/qwen3.5-plus \
--task "为这个 Python 项目编写完整的 API 文档和使用教程"
Example 6: Mixed Task Batch (Parallel)
User Input (Multiple Tasks):
CODEBLOCK29
Router Analysis:
- - Task 1: code → qwen3-coder-plus + subagent
- Task 2: web → qwen3-max-2026-01-23 + subagent
- Task 3: chat → qwen3.5-plus + main_session
Parallel Execution:
CODEBLOCK30
Performance: 3x faster than sequential execution
Installation
Install via ClawHub
CODEBLOCK31
Manual Installation
- 1. Clone or download this skill folder
- Copy to your OpenClaw skills directory:
cp -r hive-task-router ~/.openclaw/workspace/skills/
- 3. Make router script executable:
chmod +x ~/.openclaw/workspace/skills/hive-task-router/router.sh
- 4. Configure models for your provider:
export HIVE_MODEL_CODE="bailian/qwen3-coder-plus"
export HIVE_MODEL_WEB="bailian/qwen3-max-2026-01-23"
export HIVE_MODEL_CHAT="bailian/qwen3.5-plus"
Configuration
Prerequisites
- - OpenClaw CLI installed
- Bash shell available
- Models configured (adjust for your provider):
- Code model (e.g.,
bailian/qwen3-coder-plus)
- Web model (e.g.,
bailian/qwen3-max-2026-01-23)
- Chat model (e.g.,
bailian/qwen3.5-plus)
Environment Variables
Optional environment variables for customization:
CODEBLOCK35
Verify Setup
CODEBLOCK36
Troubleshooting
Issue 1: Router script not found
CODEBLOCK37
Issue 2: Model not available
CODEBLOCK38
Issue 3: Task type misidentified
CODEBLOCK39
Issue 4: Wrong model used
CODEBLOCK40
Best Practices
- 1. Task Distribution Principles
- ✅ Short tasks → Main session
- ✅ Long tasks → Subagent
- ✅ Batch tasks → Multiple parallel subagents
- ✅ Fixed types → Session isolation + specialized models
- 2. Model Selection
- Use code-specialized models for programming tasks
- Use reasoning models for research tasks
- Use cost-effective models for chat tasks
- Mix providers for best-in-class results
- 3. Concurrency Control
- Recommended max concurrent subagents:
5-10
- For 10+ tasks → Execute in batches
- Monitor API quota usage
- 4. Environment Management
- Set environment variables in
.bashrc or
.zshrc
- Use different configs for different projects
- Document your model choices
Performance
| Metric | Traditional | Hive Router | Improvement |
|---|
| 3 project research | ~180s | ~60s | 3x ⚡ |
| Model utilization |
Single model | Multi-model | Flexible |
| Task routing | Manual | Automatic | Intelligent |
| Multi-provider | Manual switching | Auto config | Seamless |
Provider Compatibility
| Provider | Status | Notes |
|---|
| Bailian (通义千问) | ✅ Tested | Default configuration |
| OpenAI (GPT) |
✅ Compatible | Set HIVE
MODEL* variables |
|
Anthropic (Claude) | ✅ Compatible | Set HIVE
MODEL* variables |
|
Google (Gemini) | ✅ Compatible | Set HIVE
MODEL* variables |
|
Other OpenAI-compatible | ✅ Compatible | Use provider/ prefix |
License
MIT License - Feel free to use and modify.
Author: qiongcao
Version: 1.0.0
Last Updated: 2026-03-12
Universal Model Support: Yes
Hive Task Router
OpenClaw 智能任务分发系统 — 根据任务类型识别,自动将任务路由到最优模型和执行模式。
通用模型支持 — 通过环境变量配置,可与任何 AI 模型提供商(百炼、OpenAI、Anthropic 等)配合使用。
何时使用
自动触发规则(适用于 AI 智能体)
当用户消息包含以下任意模式时,自动使用此技能:
| 触发模式 | 关键词 | 操作 |
|---|
| 代码任务 | 代码、编程、脚本、函数、nodejs、react、vue、typescript、javascript、html、css、前端、后端、api、接口、调试、bug、优化、重构 | 运行 router.sh → 使用 code 模型 + 子智能体执行 |
| 网络调研 |
搜索、查找、调研、研究、github、项目、趋势、报告、分析、对比、评测、最新、2026、新闻、动态 | 运行 router.sh → 使用 web 模型 + 子智能体执行 |
|
数据任务 | 数据、分析、统计、图表、可视化、excel、csv、json、处理、转换 | 运行 router.sh → 使用 data 模型 + 子智能体执行 |
|
文档任务 | 文档、说明、教程、指南、手册、readme、wiki、注释、文档化 | 运行 router.sh → 使用 doc 模型 + 子智能体执行 |
|
批量任务 | 多个、批量、同时、并行、一起 | 为每个任务运行 router.sh → 并行执行 |
在以下情况下不要使用此技能:
- - 简单的聊天/对话(你好、谢谢、安排、计划、汇报、总结)
- 快速提问(什么是、如何、解释)
- 任务已在执行中
- 用户明确表示不要使用子智能体或直接回答
手动触发(适用于用户)
用户可以通过以下方式显式触发此技能:
- - 直接运行 router.sh 任务描述
- 说使用 hive router或分析此任务
- 询问我应该为此任务使用哪个模型
AI 智能体决策流程
接收用户消息
↓
包含特定触发关键词?(代码/网络/数据/文档/批量)
↓
是 → 运行 router.sh 进行分析
↓
获取推荐的模型 + 执行模式
↓
使用推荐的配置执行
↓
向用户报告结果
↓
否 → 检查是否包含模糊任务关键词?(任务、帮忙、处理、搞定、完成)
↓
是 → 提出澄清性问题(参见模糊任务处理)
↓
用户澄清 → 使用新信息重新分析
↓
否 → 直接处理(无需路由)
模糊任务处理
当用户消息模糊时(例如:做个任务、帮忙处理一下、搞定这件事):
步骤 1:确认并询问
好的主人,请问是什么类型的任务?
💻 写代码/脚本?
- 例如:写个 Python 脚本、开发一个 API
🔍 搜索调研?
- 例如:搜索最新趋势、调研竞品
📊 数据处理?
- 例如:分析 Excel 数据、转换 JSON 格式
📄 写文档?
- 例如:写 API 文档、编写教程
💬 还是只是聊天?
- 例如:今天有什么安排、帮我总结一下
或者您直接告诉我具体内容,我来判断!
步骤 2:用户澄清
用户:写个脚本处理数据
↓
现在包含:脚本(代码)+ 数据(数据)
↓
优先级:代码 > 数据
↓
使用执行:qwen3-coder-plus + 子智能体
模糊关键词(触发澄清):
- - 任务、帮忙、处理、搞定、完成、做一下、弄一下
- 这个、那个、一件事、一个东西
特定关键词(触发自动路由):
- - 代码:脚本、代码、编程、函数、nodejs、react...
- 网络:搜索、调研、分析、趋势、报告、对比...
- 数据:数据、统计、图表、excel、csv、json...
- 文档:文档、教程、指南、readme、wiki...
理想场景:
- - 处理多个并发任务
- 需要代码专用模型的技术开发
- 需要网络搜索能力的研究任务
- 复杂度各异的工作负载混合
- 多提供商环境(百炼 + OpenAI + Anthropic)
快速参考
任务类型识别关键词
| 类型 | 关键词(中文) | 关键词(英文) | 优先级 |
|---|
| 网络 🔍 | 搜索、查找、调研、研究、github、项目、趋势、报告、分析、对比、评测、最新、2026、新闻、动态 | search, research, github, project, trend, report, analysis, comparison, latest, news | 1(最高) |
| 代码 💻 |
代码、编程、脚本、函数、nodejs、react、vue、typescript、javascript、html、css、前端、后端、api、接口、调试、bug、优化、重构 | code, programming, script, function, nodejs, react, vue, typescript, javascript, html, css, frontend, backend, api, debug, bug, optimize, refactor | 2 |
|
数据 📊 | 数据、分析、统计、图表、可视化、excel、csv、json、处理、转换 | data, analysis, statistics, chart, visualization, excel, csv, json, processing, conversion | 3 |
|
文档 📄 | 文档、说明、教程、指南、手册、readme、wiki、注释、文档化 | documentation, guide, tutorial, manual, readme, wiki, comment, document | 4 |
|
聊天 💬 | 你好、谢谢、再见、今天、明天、安排、计划、汇报、总结、提醒、备忘 | hello, thanks, goodbye, today, tomorrow, plan, schedule, summary, reminder, memo | 5(默认) |
模型选择规则
注意: 模型 ID 可通过环境变量配置。将 provider/ 替换为您的实际模型提供商(例如 bailian/、openai/、anthropic/)。
| 任务类型 | 默认模型 | 环境变量 | 原因 |
|---|
| 代码 | provider/qwen3-coder-plus | HIVEMODELCODE | 专精于代码生成和调试 |
| 网络 |
provider/qwen3-max | HIVE
MODELWEB | 强大的搜索和推理能力 |
|
数据 | provider/qwen3-coder-plus | HIVE
MODELDATA | 基于代码的数据处理 |
|
文档 | provider/qwen3.5-plus | HIVE
MODELDOC | 良好的文本生成能力,性价比高 |
|
聊天 | provider/qwen3.5-plus | HIVE
MODELCHAT | 最适合日常对话,性价比高 |
模型配置示例
百炼(通义千问):
bash
export HIVEMODELCODE=bailian/qwen3-coder-plus
export HIVEMODELWEB=bailian/qwen3-max-2026-01-23
export HIVEMODELCHAT=bailian/qwen3.5-plus
export HIVEMODELDOC=bailian/qwen3.5-plus
export HIVEMODELDATA=bailian/qwen3-coder-plus
模型验证模式
自动模型检测(推荐):
bash
从 OpenClaw 自动检测可用模型
export HIVE
VALIDATEMODEL=auto
首次运行: 检测模型并缓存配置
后续运行: 使用缓存的配置(24 小时 TTL)
优势: 无需手动配置!
手动验证模式:
| 模式 | 环境变量 | 行为 | 使用场景 |
|---|
| 自动(推荐) | export HIVEVALIDATEMODEL=auto | 自动检测 + 缓存 24 小时 | 最适合大多数用户 |
| 缓存 |
export HIVE
VALIDATEMODEL=cache | 验证一次,缓存 24 小时 | 手动配置,稳定 |
|
始终 | export HIVE
VALIDATEMODEL=1 | 每次执行都验证 | 调试,变更 |
|
从不 | export HIVE
VALIDATEMODEL=0 | 跳过验证 | 生产环境,已知配置 |
缓存配置:
bash
缓存目录(默认:~/.hive-task-router)
export HIVE
CACHEDIR=$HOME/.hive