| name | subagent-model-routing |
| description | Copilot-compatible workflow for routing work to local external-model shims: codex/GPT-5.x through codex-shim.sh, Claude models through claude-shim.sh, Kimi through kimi-shim.sh, Grok 4.5 through grok-shim.sh, and GLM/MiniMax through opencode-shim.sh. Local/self-hosted models (including Qwen) route through opencode-shim.sh as a custom provider. Use when the user asks Copilot to dispatch, compare, review, fan out, or sequence work across those local shims. This port avoids Claude Code orchestration surfaces and uses the shared model-routing JSON workflow runner for durable dependency graphs. |
Model Routing For Copilot
This is the Copilot-compatible companion to the Claude Code subagent-model-routing-claude plugin. It uses the same local shim scripts, but not the Claude Code transport layer.
Use it when the user wants Copilot to route work to external model harnesses through:
~/.claude/scripts/codex-shim.sh for GPT-5.x via the local codex CLI wrapper.
~/.claude/scripts/claude-shim.sh for Claude models via the local Claude Code CLI.
~/.claude/scripts/kimi-shim.sh for Kimi models via the local Kimi Code CLI.
~/.claude/scripts/grok-shim.sh for Grok 4.5 via the local Grok Build CLI.
~/.claude/scripts/opencode-shim.sh for GLM, MiniMax, or local/self-hosted models via the local opencode wrapper.
Local/self-hosted models (including Qwen) are routed as custom providers through opencode-shim.sh; see the root README for an example.
Do not use Claude-only concepts here. The Copilot path uses direct shell dispatch for flat work and the shared model-routing workflow JSON runner for durable graphs across all five transports.
First Decision
Before dispatching, classify the task.
Flat dispatch
Flat dispatch means independent one-shot work with no dependency edge between units. Examples:
- Ask Kimi and codex for independent reviews, then compare findings yourself.
- Send N unrelated files/prompts for classification.
- Generate two candidate implementations from the same prompt, then synthesize inline.
For flat work, write prompt files under /tmp/subagent-model-routing-<task>/ and run the relevant shim commands directly from the shell. Same-turn collation by Copilot does not make a workflow.
Dependency workflow
Dependency workflow means there are edges: A must finish before B can start, an upstream artifact is read by a downstream prompt, a mechanical reduce needs all prior outputs, or Copilot must judge/synthesize between stages.
For a small graph with judgment between every stage, keep the decisions inline. When dependency ordering, bounded concurrency, artifact handoff, retry, verification, cancellation, or resume matters, write a versioned JSON workflow and run:
~/.claude/scripts/model-routing workflow run workflow.json --host copilot
Copilot workflows may use Codex, Claude, Kimi, Grok, and OpenCode routes. Select dependency artifacts explicitly with contextFrom; never inject every transcript. Use workflow list|show|cancel|resume for recovery. --host is advisory metadata rather than a security boundary.
If the user explicitly asks for parallel model work, use independent shim calls for independent read-heavy exploration or parallel checks. Do not hide dependency edges inside a single undifferentiated shell batch.
Preflight
Run these before first use on a machine or when auth is suspect:
test -x ~/.claude/scripts/codex-shim.sh
test -x ~/.claude/scripts/claude-shim.sh
test -x ~/.claude/scripts/kimi-shim.sh
test -x ~/.claude/scripts/opencode-shim.sh
test -x ~/.claude/scripts/grok-shim.sh
mkdir -p /tmp/subagent-model-routing-pilot
printf 'Reply with exactly: pong\n' > /tmp/subagent-model-routing-pilot/pong.md
~/.claude/scripts/kimi-shim.sh /tmp/subagent-model-routing-pilot/pong.md 2>/dev/null | grep -m1 -i pong
~/.claude/scripts/codex-shim.sh /tmp/subagent-model-routing-pilot/pong.md -c model_reasoning_effort=low | grep -m1 -i pong
~/.claude/scripts/claude-shim.sh /tmp/subagent-model-routing-pilot/pong.md --model haiku | grep -m1 -i pong
~/.claude/scripts/grok-shim.sh /tmp/subagent-model-routing-pilot/pong.md --effort low | grep -m1 -i pong
If a pong fails, fix shim provider config, endpoint reachability, or local installation before using this skill for real work.
Prompt File Pattern
Use files as the boundary between Copilot and the external harness.
DIR=/tmp/subagent-model-routing-task
mkdir -p "$DIR"
cat > "$DIR/review.md" <<'EOF'
Review the repository for correctness bugs.
Write findings with file paths, line references, severity, and evidence.
Do not make code changes.
EOF
~/.claude/scripts/kimi-shim.sh "$DIR/review.md"
For authoring tasks, tell the external harness exactly which files it may edit and which verification command it must run. After the shim returns, Copilot must inspect the diff and run verification itself.
Model Routes
The canonical Copilot-hosted transport/model inventory is generated from config/provider-registry.json and bundled at references/routes.generated.md. Copilot has no native-family exclusion, so all five transports appear. Unknown provider-accepted model IDs remain pass-through; use the generated catalog for route syntax and the prose below for routing judgment.
Tier example (seed — copy into your own ledger and adjust):
codex GPT-5.6 Sol (provisional flagship seat) ≥ GLM-5.2 > Kimi K2.7 > MiniMax-M3; Grok 4.5, GPT-5.6 Terra/Luna, and local/self-hosted models remain unranked pending local evidence. Within the Claude family, the officially hosted system cards provide a provisional capability prior of Fable 5 > Opus 4.8 > Sonnet 5, but not a cross-provider local ranking: use Sonnet 5 as the default workhorse, Opus 4.8 for difficult or verification-heavy work, and Fable 5 for the hardest generally available Claude work where its safeguards and possible fallback are acceptable. GLM-5.2 holds the default authoring seat; GPT-5.6 Sol is reserved for the hardest/critical units and deepest review; Kimi is mid-tier utility, parallel candidates, and burst; MiniMax M3 handles Sonnet-grade throughput (stall policy retained).
Per-model capability cards (excels-at / struggles-with / operational caveats / evidence) live in the Claude Code package within this repo clone at plugins/subagent-model-routing-claude/skills/subagent-model-routing/ledger/{claude-fable-5,claude-opus-4.8,claude-sonnet-5,codex,grok,glm,kimi,minimax,qwen}.md. They are maintained there by that package's /subagent-model-routing-claude:distill command and are read-only reference material from Codex/Copilot; they are present in the repo clone but not in an isolated plugin-cache install.
Per-dispatch ceiling: the repo-installed shim enforces SHIM_TIMEOUT_SECS (default 1140s, about 19 min) per run and emits a final SHIM-DONE exit=<n> sentinel; its absence in a captured blob signals clipped or still-running output. Long flat jobs (>~15 min expected wall): split the prompt into smaller units, or raise SHIM_TIMEOUT_SECS (and your host agent's own command timeout) deliberately.
The shared installer also provides ~/.claude/scripts/model-routing. Run model-routing doctor before first use or when provider/plugin drift is suspected; its default path performs no discovery. Use explicit doctor --discover-models only when a catalog refresh is actually needed. When a dispatch needs recovery or audit, use model-routing runs list, runs show <id>, or runs logs <id> --channel both; use workflow list|show|cancel|resume for graphs. Do not parse metadata after the sentinel because nothing may be printed there. Prompt bodies are not retained by default. Add --routing-retain-prompt only with explicit need and treat retained stdout/stderr/workflow context as sensitive artifacts.
For a write task routed through any of the five shims, add --routing-workspace isolated --routing-task-mode write. Inspect with model-routing runs diff <id>, apply only after review with runs apply <id> --target <repo>, and remove the owned branch/worktree explicitly with runs discard <id> --yes. auto is allowed only when the prompt declares --routing-task-mode read|write; never let the runtime guess whether a Copilot-routed task writes.
Prompt Reference Cards
Use these cards when writing prompt files for the local shims. For new, high-stakes, broad fan-out, or reusable prompt templates, load the linked package-local reference section before dispatch.
codex / GPT
- Select Sol (
gpt-5.6-sol) for flagship capability, Terra (gpt-5.6-terra) for a capable lower-cost route, or Luna (gpt-5.6-luna) for the fastest and most cost-efficient route.
- Use Goal, Context, Constraints, and Completion Criteria.
- Name allowed files, allowed edits, validation commands, and exact completion criteria.
- State authorization boundaries and destructive actions that require confirmation; GPT-5.6 system-card evaluations found a greater tendency than GPT-5.5 to go beyond user intent.
- Include deterministic verification such as tests, typecheck, lint, or static detectors, and inspect artifacts rather than trusting completion claims after tool failures.
- Add an initiative nudge before raising effort when the model stops at the first plausible answer.
- Tools: if your CLI has MCP tools configured, prompts may direct their use.
- Full reference:
references/model-prompting.md#openai-gpt-56-through-codex
Anthropic / Claude Code transport
- Route Claude through
claude-shim.sh; it defaults to the latest sonnet alias. Use --model opus, --model haiku, --model fable, or a full model name when the task calls for it.
- State the objective, repository context, scope/authorization boundaries, expected artifacts, deterministic validation, and completion criteria.
- Claude Code is agentic: inspect the resulting diff and rerun decisive checks after it returns.
- Use only effort levels supported by the selected model. For bounded automation, consider
--max-turns and --max-budget-usd.
- The shim disables session persistence but preserves normal project discovery; do not add
--bare unless intentionally skipping CLAUDE.md, hooks, skills, plugins, MCP servers, and memory.
- Set
SUBAGENT_MODEL_ROUTING_UNRESTRICTED=0 when Claude Code should retain its configured permission policy instead of bypassing prompts.
- Full reference:
references/model-prompting.md#claude-code-transport
Claude Sonnet 5
- Use as the default Claude workhorse for normal implementation, analysis, review, extraction, and agentic search. Its system card reports clear coding and tool-use gains, while still trailing the stronger Claude configurations.
- Require source/tool inspection and deterministic checks: the card found more closed-book uncertainty than stronger peers and a slight flawed-result regression relative to Opus 4.8.
- Full reference:
references/model-prompting.md#claude-sonnet-5
Claude Opus 4.8
- Use for difficult, long-context, adversarial, or verification-heavy work. Require actual command evidence despite strong diligence evaluations: the card's case studies still include fabrication, ignored corrections, and skipped cheap checks.
- Mark instructions in repository, browser, tool, and issue content as untrusted data; unsafeguarded prompt-injection robustness regressed in some agentic settings.
- Full reference:
references/model-prompting.md#claude-opus-48
Claude Fable 5
- Use for the hardest generally available Claude work when additional capability justifies the route. Fable's production safeguards can block or fall back to Opus 4.8 in protected high-risk domains.
- Name authorization boundaries and confirmation gates for destructive, external, financial, security-sensitive, or irreversible actions. This project intentionally defines no Mythos-specific route or reference.
- Full reference:
references/model-prompting.md#claude-fable-5
xAI / Grok
- Route Grok Build through
grok-shim.sh; it defaults to grok-4.5.
- Use a concrete objective, relevant repository context, scope/authorization boundaries, requested work, validation commands, and completion criteria.
- Treat Grok Build as an agentic harness: inspect the resulting diff and rerun decisive checks after it returns.
- Keep xAI's default
high reasoning effort for hard debugging and architecture; use --effort low or --effort medium for routine, tightly scoped work.
- Grok Build's sandbox is off by default. Forward
--sandbox workspace when isolation is required; set SUBAGENT_MODEL_ROUTING_UNRESTRICTED=0 if approvals should not be auto-accepted.
- Full reference:
references/model-prompting.md#xai-grok-45-through-grok-build
Kimi / Moonshot
- Use clear detailed instructions, delimiters, explicit steps, examples, and reference text.
- Keep shim prompts focused on task and output contract; opencode owns the tool harness.
- Pilot new templates before fan-out.
- Do not use non-tool completion routes for grounded review.
- Tools: if your CLI has MCP tools configured, prompts may direct their use.
- Full reference:
references/model-prompting.md#kimi
GLM / Z.ai
- Put critical instructions early when useful, but treat that as a field heuristic to validate, not a vendor guarantee.
- Use a concrete role, delimiters, exact JSON/output formats, and decomposed subtasks.
- Prefer explicit thinking controls when available.
- Through the shim, demand parseable JSON when JSON is required and validate after return.
- Tools: if your CLI has MCP tools configured, prompts may direct their use.
- Full reference:
references/model-prompting.md#glm
MiniMax
- MiniMax has no official text prompt-engineering guide; use Anthropic-style structured prompts.
- Give clear role, task, success criteria, constraints, and output shape.
- Allow architect-style planning for coding prompts when useful.
- Treat
--thinking as a binary visibility toggle, not an effort dial.
- Detect missing text stalls and retry the same model up to 3 times.
- Tools: if your CLI has MCP tools configured, prompts may direct their use.
- Full reference:
references/model-prompting.md#minimax
Qwen / Alibaba
- Route status: any OpenAI-compatible endpoint (local or hosted) via an opencode custom provider — route through
~/.claude/scripts/opencode-shim.sh with your custom-provider entry; see the root README for an example.
- Use the six-element framework for prompt work: Context, Objective, Style, Tone, Audience, Response.
- Add examples, explicit task steps, and separators such as
###, ===, or >>>.
- Qwen3 thinking can be steered with
enable_thinking, /think, and /no_think.
- Do not route local Qwen work through
codex-shim; use the opencode-shim custom-provider route.
- Tools: MCP tool availability follows your opencode configuration; for small-context local models, consider skipping heavy tool schemas — context is better spent on prompt and source.
- Full reference:
references/model-prompting.md#qwen