ClaudeMods
☰
JA
● 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 で、メインループ、各サブエージェント層、各サブエージェント種別のモデル、プロバイダー、effort を切り替えられます。別のランチャーは不要です。

セットアップ

  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(各 upstream が今日提供している全 id をサブスクリプション別にまとめたもの)を読み、ネイティブの /model ピッカーを一致させます。ハードコードはありません。
  • ルート。 ルートは 1 つの層(fable、opus、sonnet、haiku)または 1 種類のサブエージェントに、モデル、effort、任意のフォールバックチェーンを設定します。
  • spawn ごとに固定。 サブエージェントのルートは spawn 時に 1 回だけ決まります。その後の変更は新しい spawn にだけ届きます。--now を付けた場合を除きます。
  • spawn タグ。 @MODEL:EFFORT で終わる Agent の説明(例:fix fee rounding @gpt-6.1-sol:medium)は、その spawn だけをルーティングします。
  • 可視化。 各 Agent 行に実際のモデル、effort、プロバイダー、選択者が表示されます。/model agents でセッション内の全サブエージェントを一覧できます。
  • 選択ログ。 完了したサブエージェントごとに 1 行の JSON が ~/.local/state/model-router/picks.jsonl に書き込まれます。
  • 決める人。 モデルが設定できるのはサブエージェントのルートだけです。メインループ、層、プロファイルはそのまま管理します。

コマンド

/model                          メインループ用の組み込みピッカー
/model ID                       メインループを ID にする(組み込み)
/model routes                   ルート表とライブモデル
/model list                     プロバイダー別のモデル id(id がプロバイダーを選ぶ)
/model agents                   このセッションの全サブエージェント:ステータス、実モデル、effort、プロバイダー、選択者
/model sonnet ID [LVL]          層:fable、opus、sonnet、haiku、nomodel;またはエージェント種別(coder ID high)
/model sonnet LVL | sonnet off  effort のみ | ルールをクリア
/model --model ID --effort LVL  submux を経由してメインループをルートとして実行
/model --agent Explore=ID[:LVL] 1 つのサブエージェント種別(ID は空でも可:--agent coder=:high)
/model --profile NAME           保存済みプロファイルを読み込む     --save NAME / --delete NAME
/model --default                現在の設定を新しいセッションのデフォルトとして保存
/model --fallback TARGET=ID,ID  リクエスト失敗時にこれらの id を順に試す(TARGET:スロットまたはエージェント種別)
/model ... --now                実行中のサブエージェントも切り替える(既定は新しい spawn のみ)
/model --reset

モデルまたは effort を変更すると、プロンプトキャッシュがモデル単位なのでコンテキスト全体を 1 回読み直します。

インストール

まず作者の 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.

関連作品