🧭

智能模型路由与成本优化专家

smart-router · vv0.1.2
可以安装,但有提示 HAS_SCRIPTS
AI 增强 安全 S 级 作者 c0nSpIc0uS7uRk3r 公开目录收录
1.1k 下载 506 安装 2.3k 收藏 7.1k 浏览

简介

基于2026年基准测试的智能模型路由系统,自动为代码、分析、创意等任务选择最优AI模型,支持Claude/GPT/Gemini/Grok四大家族,具备成本优化与故障自动切换能力。

原始描述

Expertise-aware model router with semantic domain scoring, context-overflow protection, and security redaction. Automatically selects the optimal AI model using weighted expertise scoring (Feb 2026 benchmarks). Supports Claude, GPT, Gemini, Grok with automatic fallback chains, HITL gates, and cost optimization.

通过你的 Agent 添加

安装目录:smart-router/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/smart-router/
Codex CLI~/.codex/skills/smart-router/
DeepSeek Harness~/.agents/skills/smart-router/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

A.I. Smart-Router 是一个透明的智能模型路由中间件,用户无需学习任何特殊指令即可使用。系统通过三层决策架构自动分析请求:第一层识别意图类型(代码/分析/创意/实时/通用),第二层评估复杂度(简单/中等/复杂),第三层处理特殊覆盖场景(超长上下文、实时数据需求、用户显式指定)。支持 [show routing]] 查看路由决策,也可通过 use claude:: 等前缀强制指定模型。

显著优点

智能化程度极高:基于语义域检测而非简单关键词匹配,能识别混合意图任务并自动升级至最高能力模型。超长上下文保护机制在超过15万token时自动切换至Gemini Pro(100万上下文),避免任务失败。

成本优化精细:建立四级成本体系($到$$$$),简单任务强制限定在Flash/Haiku等低价模型,复杂任务才启用Opus/GPT-5,从源头杜绝"用大炮打蚊子"。

容错机制完善:熔断器防止级联故障,速率限制避免预算失控,token耗尽时自动降级并透明通知用户,支持流式响应的中途故障恢复。

安全设计周全:四级数据分类(PUBLIC/INTERNAL/CONFIDENTIAL/RESTRICTED)、敏感数据自动检测、API密钥绝不硬编码、错误信息脱敏处理。

潜在缺点与局限性

实时任务存在单点风险:Grok是唯一实时数据源,若XAI服务故障且无备用实时源,实时查询将降级为普通模型并丢失时效性。

T3来源维护不确定性:个人开发者项目,长期更新承诺需观察,企业级部署建议fork后自主维护。

配置复杂度较高:需同时管理多厂商API密钥,auth profiles配置对新手不够友好,调试路由决策需要一定学习成本。

中文优化待验证:虽声称支持100+语言,但意图检测关键词库以英文为主,复杂中文表达的意图识别准确率可能下降。

适合的目标群体

  • 多模型AI团队:已订阅多个AI服务,希望统一入口并优化成本的技术团队
  • 长文档处理场景:法律、科研、金融等需要处理百万token级文档的专业领域
  • 成本敏感型应用:C端产品或大规模内部工具,需严格控制AI调用成本
  • 高可用要求场景:不能容忍单模型故障导致服务中断的生产环境

使用风险

性能风险:模型自动切换增加首次响应延迟(需检测可用性),流式响应需等待首chunk确认才输出,极端情况下延迟可达10秒以上。

依赖风险:强依赖外部AI服务商稳定性,若Anthropic/Google/OpenAI/XAI同时出现区域性故障,系统将完全不可用(虽概率极低)。

成本失控风险:自动降级机制可能将复杂任务路由至低价但能力不足模型,导致多次重试反而增加总成本;实时任务强制使用Grok可能产生意外高额账单。

数据合规风险:自动路由可能将敏感数据发送至用户未预期的模型(如欧盟数据被路由至美国服务商),需配合数据分类功能谨慎配置。

技能正文


name: smart-router description: Enable or disable Unity Gateway subagent model routing for the current smart-routed Claude or Codex session, along with Smart Router Orchestrator when opted in. allowed-tools: ug_smart_router, Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli claude --enable-smart-routing), Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli claude --disable-smart-routing), Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli claude --disable-smart-routing --smart-router-feedback *), Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli codex --enable-smart-routing), Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli codex --disable-smart-routing), Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli smart-router-logs --harness codex --session "$CODEX_SESSION_ID" --format table), Bash("$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli smart-router-logs --harness codex --session "$CODEX_SESSION_ID" --format table --decision *) metadata: version: "1.12.0"

Smart Router

Keep toggle and feedback replies in ordinary product language. Do not announce skill usage, cite instructions, or show skill names, file paths, or internal tool names unless the user asks about the implementation. Asking for a feedback reason is ordinary user input within the requested toggle, not a permission or approval request. Ask the user directly without explaining which instruction requires it.

In Codex, only the explicit $smart-router off skill command may start the off flow. A natural-language request must leave routing unchanged; tell the user to invoke the command. Do not interpret a quoted command or a command with a reason appended as an off invocation. When this session has the launcher-provided native ug_smart_router tool, call it with {"action":"on"} or {"action":"off"} and run no toggle, capture, submission, or status shell commands. If the native tool is unavailable, run exactly "$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli codex --enable-smart-routing for on or "$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli codex --disable-smart-routing for off, with no other arguments, and relay its result. If that off reports that a reason is required, report that this session needs an updated Unity Gateway launch to turn Smart Router off; do not ask for or pass a reason. If it refuses for another reason, relay its message and stop. Do not restart the conversation yourself.

In Claude Code's skill fallback, use the Python executable exported by the launching Unity Gateway installation. Keep its path quoted and do not substitute ug or python from PATH. Run exactly "$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli claude --enable-smart-routing for on or "$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli claude --disable-smart-routing for off.

  • In Codex only, for logs, run exactly "$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli smart-router-logs --harness codex --session "$CODEX_SESSION_ID" --format table and reply with ONLY a fenced code block (```text) containing its stdout exactly, with no text before or after it. Without the fence, Codex reflows the text, loses the alignment, and prepends a bullet to the first line. Do not reformat, summarize, or drop rows, because Codex collapses long command output. If CODEX_SESSION_ID is unset, ask the user to restart through an updated Unity Gateway with smart routing enabled. Claude Code handles /smart-router logs natively; do not run this command there.
  • In Codex only, for logs --id <ID>, first check that <ID> is 4 to 32 hex characters (0-9a-f) and nothing else; otherwise ask for an ID from the table and run nothing. Then run exactly "$UCODE_SMART_ROUTER_PYTHON" -m ucode.cli smart-router-logs --harness codex --session "$CODEX_SESSION_ID" --format table --decision <ID> and reply with ONLY a fenced code block (```text) containing its stdout exactly, with no text before or after it, like the overview.

In PowerShell, use & "$env:UCODE_SMART_ROUTER_PYTHON" in place of "$UCODE_SMART_ROUTER_PYTHON" and "$env:CODEX_SESSION_ID" in place of "$CODEX_SESSION_ID"; keep the remaining arguments the same. If UCODE_SMART_ROUTER_PYTHON or UCODE_SESSION_ENV_FILE is unset, ask the user to restart through an updated Unity Gateway with smart routing enabled.

If the command reports that Smart Router is already on or already off, return that result and stop. Do not retry, restart a turn, or request feedback for unchanged settings.

SKIP_ISAAC_FEEDBACK_TO_DISABLE_SMART_ROUTING=1 skips feedback when turning routing off. The default is 0; unset or any value other than exactly 1 keeps the existing feedback flow. Let the native tool or CLI apply this setting. Do not change it yourself. If off succeeds without requesting feedback, relay the result and stop.

Omnigent launches (ISAAC_LAUNCH_MODE=omni) are exempt from this feedback flow. Relay the toggle result and stop if no feedback is requested. In Codex, the off call opens a native selection prompt when feedback is required: "Provide a reason" opens text entry, and "Cancel" keeps routing on and sends nothing. The launcher requires at least 16 characters, discloses that the reason and session details go to the Isaac team, and handles cancellation. Wait for the tool result; do not ask a duplicate chat question, call a separate question tool, or switch to Plan mode. Always collect the reason through this disclosed prompt, including when the user mentioned a reason earlier. Never supply a reason yourself, invent one, or pad their input. If the result reports a validation error, relay it and stop. A short reason ends this attempt with routing still on and nothing sent. Do not reopen the prompt, ask another question, or retry automatically; wait for the user's next request. The launcher identifies the preceding task, freezes its routing context, starts Isaac's background feedback submission, and turns routing off, as Claude does. Delivery failures leave routing off. Reason submission needs no additional shell approval. Do not submit the same report through /isaac-feedback or another command. Relay the native result briefly, including any notices. If delivery is pending, say the user can keep working; do not poll or block the conversation. The launcher reports completion. Keep routing off throughout delivery; never claim delivery succeeded merely because routing is off. In Claude's skill fallback, if the off result requires feedback, routing is still on. Ask why the user is turning Smart Router off and explain that their reason and session details will be sent to the Isaac team. Require at least 16 characters after trimming surrounding whitespace; ask again if shorter. Never invent or pad their reason. Reuse a reason already supplied for this toggle. If they cancel, stop without disabling routing or submitting feedback. Repeat off with --smart-router-feedback '<reason>' appended, quoting the exact text as one shell argument, then submit it through /isaac-feedback --category smart-routing <reason> as before. Report a submission failure without re-enabling routing. This requirement applies outside Omnigent when Isaac sets ISAAC_SMART_ROUTER_FEEDBACK to 1, true, yes, or on (case-insensitive); do not change that flag to bypass it.

With no argument, explain that only on, off, and (in Codex) logs and logs --id <ID> are accepted. Do not edit the state file. This affects subsequent subagent model selection in the current session, not the root model or first prompt. In sessions launched with ENABLE_SMART_ROUTER_ORCHESTRATOR=1, it also controls Smart Router Orchestrator. When turned off, earlier Smart Router Orchestrator instructions are superseded: do not start new automatic delegation or fall back to Smart Router Orchestrator role models. Continue in the root unless the user explicitly requests a subagent. Honor that request using native tools and normal harness model selection, without Smart Router Orchestrator; keep routing off. Existing children can finish. When turned on, apply the smart-router-orchestrator skill to further work only if the session was launched with ENABLE_SMART_ROUTER_ORCHESTRATOR=1. For Claude launches with ENABLE_SMART_ROUTING_SAVINGS=1, off/on also disables/restores savings tracking and its display row. The savings presets are subagent_orch_savings_v0_blind_subagent_model for blinded subagent routing with orchestration, subagent_auto_savings_v0 for Claude and Codex Auto, and subagent_auto_savings_v0_claude_only for Claude Auto only. Other presets disable savings. In Claude Auto, use the native model picker to control routing; its mod handles savings too. Do not change the orchestration or savings launch baseline. Return the command's result briefly, then stop. ENABLE_SUBAGENT_MODEL_IN_MAIN_TUI=0 hides routing details in Claude's main terminal; Auto's and the blind orch v0 config versions set this flag. Hidden details do not mean routing is off. In Codex, the current main turn keeps its original routing attribution; the next user turn gets the new state. Do not interrupt, restart, or reload any conversation.

正文来自原始仓库, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

原始仓库

作者的项目地址:https://github.com/databricks/ucode

标签

ai-mlapiautomationbackendcost-optimizationmulti-modelroutingproduction

同类 Skill