ClaudeMods
☰
ZH-TW
● 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 會列出這個工作階段的所有子代理程式。
  • 選擇記錄。 每個完成的子代理程式會將一行 JSON 寫入 ~/.local/state/model-router/picks.jsonl。
  • 誰做決定。 模型只能設定子代理程式路由。主迴圈、層級與設定檔仍由你掌控。

命令

/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.

更多類似作品