Buckeyes22/subagent-model-routing

5 stars · Last commit 2026-07-30

Route Claude Code, Codex, and Copilot work across installed model CLIs with delegation guardrails and an observation-driven routing ledger.

README preview

# subagent-model-routing

You probably pay for more than one AI coding subscription. Delegating a task between Claude Code, Codex, Grok, Kimi, GLM, MiniMax, or a local model still means copy-pasting the prompt, watching another CLI, and pasting the answer back. That friction makes cross-model review easy to skip.

**subagent-model-routing** makes that handoff explicit with three pieces:

- **Five thin CLI shims** (`codex-shim.sh`, `claude-shim.sh`, `kimi-shim.sh`, `opencode-shim.sh`, and `grok-shim.sh`) backed by a shared local Python runtime. They dispatch a prompt to another agentic CLI and return the answer with a `SHIM-DONE exit=<n>` sentinel, while retaining private run records for inspection and recovery.
- **A routing skill** that defines when to delegate, which model to use, and how to phrase the dispatch, plus **tripwire guardrails** that catch silent delegation failures (missing sentinel, nonzero exit, truncated output) before they enter your context as usable results.
- **A model ledger** that records every dispatch's wall time, exit code, and outcome, so routing decisions improve from your own observations rather than someone else's defaults.

It's built for **Claude Code, Codex, and GitHub Copilot CLI users** who want to route work through the other installed agentic CLIs. Each host stays native for its own model family: Claude Code uses native Claude agents, Codex keeps Codex work inline, and shims handle cross-harness delegation.

The shared installer provides `~/.claude/scripts/model-routing` plus `codex-shim.sh` (GPT models via Codex), `claude-shim.sh` (Claude models via Claude Code), `kimi-shim.sh` (Kimi models via Kimi Code), `grok-shim.sh` (Grok 4.5 via Grok Build), and `opencode-shim.sh` (GLM, MiniMax, Qwen, local models, and any OpenCode provider). The Claude Code package targets codex, kimi, grok, and opencode; the Codex package targets claude, kimi, grok, and opencode; Copilot can target all five. Routed models can edit files and run commands in your workspace, then report completion with a `SHIM-DONE exit=<n>` sentinel.

## How this compares

**Isn't this just an LLM router?** No. Routers like LiteLLM or OpenRouter multiplex API requests to a single endpoint — you send a completion request, they pick a backend and proxy it. subagent-model-routing operates a layer above that: it delegates whole units of agentic work to full CLI harnesses, each with its own tools, workspace access, and subscription auth, then verifies the work actually finished. Nothing here proxies API calls.

**Why not just use OpenCode directly?** You can — and this project composes with OpenCode rather than replacing it. OpenCode remains the generic harness for GLM, MiniMax, Qwen, and local/custom providers, while Kimi can use its dedicated Kimi Code harness. What subagent-model-routing adds on top is the delegation doctrine, completion verification through the sentinel contract, guardrails against silent delegation failure, and a ledger that learns which model to trust for what from your own outcomes.

View full repository on GitHub →