ClaudeMods
☰
ZH-CN
● 0 人在线 · 浏览 0 次
赞助提交作品
GitHub 仓库 · 发布者 arkadevbanerjee

model-router

一个能在普通 `claude` 工作阶段中驱动 submux 的 Claude Code 插件。

arkadevbanerjee@arkadevbanerjee

arkadevbanerjee/submux/tree/main/claude-plugin/model-router

已翻译

关于这个 mod

model-router

一个能在普通 claude 工作阶段中驱动 submux 的 Claude Code 插件。通过 /model,可以为主循环、每个子代理层级以及每种子代理类型切换模型、提供商和工作量,不需要单独的启动器。

设置

  1. 运行 submux serve(见顶层 README),然后在 ~/.claude/settings.json 中将 Claude Code 指向它:

    { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:8787" } }
    
  2. 加载插件:在同一个 env 区块中,将此目录加入 CLAUDE_CODE_PLUGIN_DIRS(以冒号分隔)。

  3. 可选:在 ~/.config/submux/routing-guide.md 中编写自己的路由指南。插件会将它加入每个工作阶段的提示中。routing-guide.example.md 是一个起点。

  4. 运行测试:claude plugin test claude-plugin/model-router。

功能

  • 实时目录。 插件读取 submux models(每个上游今天提供的所有 id,按订阅分组),让原生 /model 选择器与其保持一致。没有任何内容写死。
  • 路由。 一条路由为一个层级(fable、opus、sonnet、haiku)或一种子代理类型设置模型、工作量和可选的回退链。
  • 每次生成后冻结。 子代理生成时只决定一次路由。之后的变更只会影响新生成的子代理,除非加入 --now。
  • 每次生成的标签。 以 @MODEL:EFFORT 结尾的 Agent 描述(例如 fix fee rounding @gpt-6.1-sol:medium)会为该次生成指定路由。
  • 可见。 每个 Agent 行会显示实际模型、工作量、提供商以及选择者。/model agents 会列出该工作阶段的所有子代理。
  • 选择日志。 每个完成的子代理会向 ~/.local/state/model-router/picks.jsonl 写入一行 JSON。
  • 由谁决定。 模型只能设置子代理路由。主循环、层级和配置仍由你掌控。

命令

/model                          主循环的内置选择器
/model ID                       将主循环切换到 ID(内置)
/model routes                   路由表和实时模型
/model list                     按提供商列出模型 id(id 会选择提供商)
/model agents                   此工作阶段的所有子代理:状态、实际模型、工作量、提供商、选择者
/model sonnet ID [LVL]          一个层级:fable、opus、sonnet、haiku、nomodel;或一种代理类型(coder ID high)
/model sonnet LVL | sonnet off  仅工作量 | 清除规则
/model --model ID --effort LVL  通过 submux 将主循环作为路由运行
/model --agent Explore=ID[:LVL] 一种子代理类型(ID 可以为空:--agent coder=:high)
/model --profile NAME           加载保存的配置     --save NAME / --delete NAME
/model --default                将当前设置保存为新工作阶段的默认值
/model --fallback TARGET=ID,ID  请求失败时按顺序尝试这些 id(TARGET:槽位或代理类型)
/model ... --now                同时切换正在运行的子代理(默认为仅新生成的子代理)
/model --reset

模型或工作量变更会重新读取整个上下文一次,因为提示缓存按模型区分。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add arkadevbanerjee/submux
claude plugin install model-router
原文 / README

model-router

A Claude Code plugin that drives submux from inside a normal claude session. You switch model, provider and effort for the main loop, each subagent tier and each subagent type with /model, with no separate launcher.

Setup

  1. Run submux serve (see the top-level README) and point Claude Code at it in ~/.claude/settings.json:

    { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:8787" } }
    
  2. Load the plugin: add this directory to CLAUDE_CODE_PLUGIN_DIRS (colon-separated) in the same env block.

  3. Optional: write your own routing guide at ~/.config/submux/routing-guide.md. The plugin adds it to every session's prompt. routing-guide.example.md is a starting point.

  4. Run the tests: claude plugin test claude-plugin/model-router.

What it does

  • Live catalogue. The plugin reads submux models (every id each upstream serves today, grouped by subscription) and keeps the native /model picker equal to it. Nothing is hardcoded.
  • Routes. A route sets a model, an effort and an optional fallback chain for one tier (fable, opus, sonnet, haiku) or one subagent type.
  • Frozen per spawn. A subagent's route is decided once, when it spawns. Later changes reach new spawns only, unless you add --now.
  • Per-spawn tag. An Agent description that ends with @MODEL:EFFORT (for example fix fee rounding @gpt-6.1-sol:medium) routes that one spawn.
  • Visible. Each Agent row shows the real model, effort, provider and who picked it. /model agents lists every subagent of the session.
  • Pick log. One JSON line per finished subagent goes to ~/.local/state/model-router/picks.jsonl.
  • Who decides. The model may set subagent routes only. The main loop, the tiers and profiles stay yours.

Commands

/model                          built-in picker for the main loop
/model ID                       main loop to ID (built-in)
/model routes                   routes table plus live models
/model list                     model ids by provider (the id picks the provider)
/model agents                   every subagent this session: status, real model, effort, provider, who picked
/model sonnet ID [LVL]          a tier: fable, opus, sonnet, haiku, nomodel; or an agent type (coder ID high)
/model sonnet LVL | sonnet off  effort only | clear the rule
/model --model ID --effort LVL  main loop through submux, as a route
/model --agent Explore=ID[:LVL] one subagent type (ID may be empty: --agent coder=:high)
/model --profile NAME           load a saved profile     --save NAME / --delete NAME
/model --default                save current as default for new sessions
/model --fallback TARGET=ID,ID  try these ids in order when a request fails (TARGET: slot or agent type)
/model ... --now                also switch running subagents (default: new spawns only)
/model --reset

A model or effort change re-reads the whole context once, because the prompt cache is per model.

更多类似作品