semantic-router
让 AI 代理根据对话内容自动选择最合适的模型。四层识别(系统过滤→关键词→指示词→语义相似度),四池架构(高速/智能/人文/代理),五分支路由,全自动 Fallback 回路。支持 trigger_groups_all 非连续词组命中。
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/halfmoon82/semantic-router🔷 Semantic Router v7.9.3 — 生产级会话路由系统 🔷
ClawHub: https://clawhub.ai/halfmoon82/semantic-router
版本: 7.6.3 (生产环境)
作者: halfmoon82
状态: ✅ ROM 级固化,完全测试通过
🎯 这个技能解决什么问题?
核心问题(v7.2 新解决)
你是否遇到过:
- Cron Job 导致会话频繁重置 — 后台定时任务打断用户交互
- Discord/Telegram 渠道会话突然清空 — 长任务无法延续
- AGENTS.md 被截断注入 — 大文件超过 20KB 限制
- 模型自动切换被全局配置覆盖 — 切换不生效
解决方案
会话隔离架构:
用户直连渠道(稳定)
├─ 主代理会话 → semantic-router(精准路由)
└─ Cron Job 隔离会话(独立环境)
├─ cloudflared-watchdog
├─ Fallback 回切检查
└─ 自定义后台任务
完整配置引导:
- 零冲突的智能合并配置
- 预检脚本防止覆盖现有设置
- 自动回滚失败的配置修改
🚀 快速安装
第一步:安装技能
# 从 ClawHub 安装
clawhub install https://clawhub.ai/halfmoon82/semantic-router
# 或手动复制到本地
cp -r ~/.openclaw/workspace/skills/semantic-router ~/my-projects/
第二步:运行配置引导
# 启动交互式配置向导
python3 ~/.openclaw/workspace/skills/semantic-router/scripts/setup_wizard.py
# 向导将:
# 1. 检测你的已有配置
# 2. 扫描可用模型
# 3. 推荐三池配置
# 4. 生成 pools.json 和 tasks.json
第三步:隔离现有 Cron Job(重要!)
# 列出你的所有 Cron Job
cron list | jq '.jobs[] | {id, name, sessionKey}'
# 对每个使用了渠道会话(telegram/discord/whatsapp)的 Job,执行隔离
cron update {job_id} \
--patch '{"sessionKey": null, "sessionTarget": "isolated"}'
# 示例(cloudflared-watchdog)
cron update ba28e228-473a-4963-8413-c228762bf2d1 \
--patch '{"sessionKey": null, "sessionTarget": "isolated"}'
第四步:验证安装
# 测试语义检查
python3 ~/.openclaw/workspace/skills/semantic-router/scripts/semantic_check.py \
"帮我写个Python爬虫" "Highspeed"
# 预期输出
# {
# "branch": "C",
# "task": "development",
# "target_pool": "Intelligence",
# "primary_model": "claude-opus-4.6",
# "declaration": "【语义检查 by DeepEye@halfmoon82】P1-任务切换..."
# }
🎓 核心概念
四池模型架构
| 池名 | 用途 | 模型示例 | 特点 |
|---|---|---|---|
| Highspeed | 查询、检索、信息搜索 | gemini-2.5-flash | 快速、成本低 |
| Intelligence | 开发、编程、复杂任务 | claude-sonnet-4.6 | 精准、能力强 |
| Humanities | 内容生成、翻译、写作 | gemini-2.5-pro | 平衡、流畅 |
| Agentic | 长上下文代理、Computer Use、专业知识工作 | gpt-5.4 | 1M上下文、工具调用、多步骤 |
两步判断法
Step 1: 关键词 + 指示词检测
"帮我写个爬虫" → 关键词 "写" + "爬虫" → 开发任务 → Intelligence
"继续刚才的" → 指示词 "继续" → 延续当前池 → B 分支
"查一下天气" → 关键词 "查" + "天气" → 查询任务 → Highspeed
"帮我整理这些材料做成PPT" → trigger_groups_all 规则命中 → 代理任务 → Agentic
trigger_groups_all 非连续词组命中(v7.7 新增)
支持在 tasks.json 中定义分组规则,每条规则内所有分组取 AND,分组内词取 OR,多条规则取 OR:
"trigger_groups_all": [
[["帮我","自动","用AI"], ["操作","填写","截图"]],
[["处理","生成","制作"], ["报告","表格","文档","PPT"]]
]
说"帮我自动操作浏览器"→ 规则①命中 → Agentic 池。无需精确关键词,口语自然表达即可触发。
Step 2: 上下文关联度评分(当 Step 1 无结果时)
相似度 ≥ 0.15 → 延续当前会话(B 分支)
相似度 0.08~0.15 → 延续但警告(B+ 分支)
相似度 < 0.08 → 新话题,重置会话(C-auto 分支)
五分支路由决策
| 分支 | 触发条件 | 动作 | 会话行为 |
|---|---|---|---|
| A | 关键词完全匹配 | 直接切到目标池 | 切换模型,不重置 |
| B | 指示词(延续) | 保持当前 | 无动作 |
| B+ | 中等关联度(0.08~0.15) | 保持 + 警告 | 输出漂移警告 |
| C | 新任务关键词 | 切到目标池 | 切换模型,不重置 |
| C-auto | 低关联度(<0.08) | 重置 + 切池 | /new + 切换模型 |
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-halfmoon82-semantic-router": {
"enabled": true,
"auto_update": true
}
}
}Tags
Related Skills
astrai-inference-router
Route all LLM calls through Astrai for 40%+ cost savings with intelligent routing and privacy controls
model-fallback
Multi-model automatic fallback system. Monitors model availability and automatically falls back to backup models when the primary model fails. Supports MiniMax, Kimi, Zhipu and other OpenAI-compatible APIs. Use when: (1) Primary model API is unavailable, (2) Model response time is too slow, (3) Rate limit exceeded, (4) Need to optimize costs by using cheaper models for simple tasks.
subagent-isolation-guard
固化子代理物理隔离与语义路由旁路。防止跨代理上下文污染及由于语义路由导致的子代理切模/重置问题。
spatix
Create beautiful maps in seconds. Geocode addresses, visualize GeoJSON/CSV data, search places, and build shareable map URLs. No GIS skills needed. Agents earn points for contributions.
astrai-code-review
AI-powered code review with intelligent model routing — saves 40%+ vs always using the most expensive model