@model tool gives the agent/coder loop the power to route itself: inspect every configured provider’s models — enriched with a price-derived tier, cost per 1M tokens, context window and capabilities — and decide which model should serve the task at hand. It can switch the rest of the task to another model (the provider switches together with it), or delegate a self-contained subtask to a cheaper model without touching the main loop.
This is the in-loop counterpart of the per-call routing the MCP Server surface exposes to external clients (
provider/model params + list_providers): the same power, now available to the AI itself while it works. Sub-tasks that don’t need a frontier model stop paying frontier prices.How it works
model: frontmatter hints — with three guarantees:
- Task-scoped. The override is cleared at the start of every agent run. The AI’s routing decision never silently outlives the task it was made for.
- Non-invasive. It never mutates the session’s own provider/model/client — outside the task,
/modeland/switchremain authoritative. - Accounted. Cost tracking attributes every turn to the model that actually served it —
/costshows exactly what each routed model consumed.
@model use decision wins over a skill’s model: frontmatter hint — an explicit in-task decision outranks a static preference.
Subcommands
What list returns
Pricing tiers
So the model reasons over a label instead of raw prices,list derives a tier from the same pricing tables cost tracking uses:
The tool’s own description teaches the agent the routing policy: delegate mechanical subtasks to a
fast-cheap model; use use only at a clear phase change, never per call — model switches invalidate the provider’s prompt cache, and frequent flip-flopping costs more than it saves.
Qualified handles: PROVIDER:model
With 15 supported providers, the same model id can exist in several of them (claude-* on CLAUDEAI, Bedrock and OpenRouter; deepseek on Ollama and GitHub Models). The canonical, deterministic form is the qualified handle exactly as list prints it:
model: hints — active provider first, then catalog, then a family heuristic (sonnet→CLAUDEAI, gpt-*→OPENAI, glm-*→ZAI, …). The tool result always names the provider that was chosen, so the agent never operates blind.
Ollama tags are safe. The qualified form splits only when the prefix names a real provider —
qwen2.5:14b is not split (its prefix isn’t a provider), and OLLAMA:qwen2.5:14b keeps the tag colon inside the model part.delegate: the biggest token saver
use moves the whole loop — history included — to another model. delegate does something cheaper: it runs one prompt on the target model, with no session history attached, and returns the answer to the main loop as a tool result.
- The main loop’s provider prompt cache stays intact (nothing about its history changes).
- The fat agent history never travels to the cheap model — the delegated call pays only for the prompt you hand it.
- The delegated usage is recorded in cost tracking under the delegated model.
delegate to fast-cheap. Sustained phase change (e.g. a long mechanical migration after the design is settled) → use.
Safety & governance
- Kill switch:
CHATCLI_AGENT_MODEL_TOOL=falseunregisters the tool entirely — the AI cannot route models by itself. Surfaced in/configunder agent → token efficiency. - Capability guard: when the catalog knows the target model lacks native tool support,
usewarns that the loop will fall back to the text protocol for tool calls. - Permission model:
list/statusare read-only;use/resetmutate the loop’s routing anddelegatespends tokens — they are declared as such to the permission system.use/resetare also serialized (never run inside a parallel tool batch). - MoA isolation: Mixture-of-Agents participants run on a strict read-only whitelist —
@modelis unreachable from panel turns.
Configuration
Usage example
See also
- Cost Tracking — per-model attribution of every routed turn
- Token Efficiency — the other levers the agent uses to spend less
- MCP Server — the same routing power for external MCP clients
- Supported Models — the catalog behind tiers and capabilities
- Environment Variables → Model routing