Model Routing Cost Optimizer
Route every agent task to the cheapest model that can still do it well. This skill
establishes a three-tier model hierarchy (cheap / mid / premium), a task classifier
that buckets work into ROUTINE / MODERATE / COMPLEX, and the decision rules that
turn a description into a model pick. It does not enforce any one provider — the
tier prices live in references/model-pricing.md so the body stays provider-
neutral — and it does not cover local quantized inference.
The core belief is blunt: most agent work is routine, and routing routine work to a
premium model is pure waste. Down-tier by default; escalate on evidence, never on
habit.
When to Use
Use this skill when you want to:
- Choose which model should handle a task, a sub-agent, or a cron job.
- Decide whether the current model is overkill for what you are about to run.
- Spawn sub-agents at a cost that matches the work.
- Keep heartbeat, monitoring, and scheduled-report traffic off premium models.
- Explain to a teammate why one model is running a task instead of another.
- Classify a batch of tasks into ROUTINE / MODERATE / COMPLEX for tiering.
Don't use for: fine-tuning a model, model evaluation or benchmarking, serving
infrastructure (vLLM / TGI), or any task where correctness risk is high and you
need the best possible reasoning regardless of price. If the work is irrecoverable
or safety-critical, stop tiering and use the premium model.
Prerequisites
- Visibility into the models your agent or gateway exposes (OpenRouter catalog,
a provider console, or the
model config of OpenClaw / Claude Code / Codex).
- No secret is required to operate this skill; the pricing table in
references/model-pricing.md is illustrative, so refresh it against provider
docs before relying on a number.
- If you run the classifier,
scripts/classify_task.py is stdlib-only.
Decision Rules (read these before you pick a model)
- Rule 1 — vision. If the task needs images (screenshots, photos, charts,
image generation), pick a vision-capable model. Never route vision work to a
text-only model just because it is the cheap tier — the cheapest viable model is
the cheapest one that can actually see.
- Rule 2 — escalation. If a cheaper model already failed the same task, move
one tier up, not down; re-trying the same failed tier burns more than one upgrade.
- Rule 3 — explicit signals. Complex words like
debug, architect,
design, security, adversarial, ambiguous push to Tier 3. Routine words
like read, fetch, check, format, status, list push to Tier 1.
- Rule 4 — classify by default. Otherwise classify the task with the procedure
and pick the tier that matches.
Task Classification
| Bucket |
Heuristic |
Typical Examples |
| ROUTINE → Tier 1 |
Single-step, deterministic, no judgment |
file I/O, heartbeat, status check, lookup, formatting, URL fetch |
| MODERATE → Tier 2 |
Multi-step but well-scoped |
code-gen on known patterns, summarization, draft writing, data transforms |
| COMPLEX → Tier 3 |
Ambiguous, multi-approach, high-stakes |
multi-step debugging, architecture, security review, long-context reasoning |
Quick Reference
| Concern |
Move |
| Task is routine |
Tier 1 |
| Task is moderate |
Tier 2 |
| Task needs image / vision |
vision-capable model (never a text-only tier-1) |
| Task already failed on cheap |
move up (escalation), never down |
| Heartbeat / cron / monitoring |
always Tier 1 |
| Sub-agent spawn |
default Tier 1 unless clearly moderate+ |
Procedure
Each step ends with a checkable completion criterion.
State the task. Write the task in one line, including whether it needs
images and whether a cheaper model already tried.
Completion: you have a task statement with its vision and prior-failure flags.
Classify. Run python3 scripts/classify_task.py "<task>" in the terminal,
or read the bucket heuristics above by hand.
Completion: you have a label of ROUTINE, MODERATE, or COMPLEX.
Apply the vision override. If the task is vision-requiring, restrict the
model choice to vision-capable options, ignoring any text-only option entirely —
a text-only model cannot take image input at any price.
Completion: the chosen model can actually accept image input.
Apply escalation and signal overrides. If a prior failure exists, go one
tier up from the classifier result. If explicit complex signals appear, go to
Tier 3.
Completion: the final tier is never lower than the classifier would have
produced.
Name a concrete model. From the provider's resolvable list, pick the
cheapest model of the final tier that meets that tier's bar.
Completion: you can name a concrete model, or a route to find one.
Run the anti-pattern sweep. If this is a sub-agent, heartbeat, cron, file
I/O, or routine batch, drop it to Tier 1 unless the classifier returned
MODERATE or above.
Completion: no heartbeat/cron work remains on a premium tier.
Anti-Patterns
- Feeding heartbeats / cron to premium models. A two-token status ping on a
flagship model is pure waste.
- Spawning sub-agents at the parent's tier. Daemon children should be one tier
down unless the work is provably complex.
- Refusing to upgrade when stuck. A cheap model that already failed costs more
if you keep retrying it; one step up is the cheaper path.
- Routing vision to a text-only model. GLM-5 (and other cheap text-only tier-1/2
models) must never see image input. Send vision to a vision-capable model.
- Tiering on habit. Do not stay on a new flagship model just because it is the
default; escalate on evidence only.
Verification
- The classifier
scripts/classify_task.py returns Tier 1 for a routine phrase,
Tier 2 for a moderate phrase, and Tier 3 for a complex phrase.
- A vision phrase (screenshot / photo / chart) routes to a vision-capable model,
and a text-only model is never selected for it.
- A failed-task phrase routes one tier up from baseline, never down.
- The heartbeat / cron phrase never lands on a premium tier.
references/model-pricing.md exists and contains the pricing table and the
"prices change, check provider docs" caveat.
1---2name: model-routing-cost-optimizer3description: Use when routing tasks to the cheapest fitting model tier.4license: MIT5---67# Model Routing Cost Optimizer89Route every agent task to the cheapest model that can still do it well. This skill10establishes a three-tier model hierarchy (cheap / mid / premium), a task classifier11that buckets work into ROUTINE / MODERATE / COMPLEX, and the decision rules that12turn a description into a model pick. It does not enforce any one provider — the13tier prices live in `references/model-pricing.md` so the body stays provider-14neutral — and it does not cover local quantized inference.1516The core belief is blunt: most agent work is routine, and routing routine work to a17premium model is pure waste. Down-tier by default; escalate on evidence, never on18habit.1920## When to Use2122Use this skill when you want to:2324- Choose which model should handle a task, a sub-agent, or a cron job.25- Decide whether the current model is overkill for what you are about to run.26- Spawn sub-agents at a cost that matches the work.27- Keep heartbeat, monitoring, and scheduled-report traffic off premium models.28- Explain to a teammate why one model is running a task instead of another.29- Classify a batch of tasks into ROUTINE / MODERATE / COMPLEX for tiering.3031**Don't use for**: fine-tuning a model, model evaluation or benchmarking, serving32infrastructure (vLLM / TGI), or any task where correctness risk is high and you33need the best possible reasoning regardless of price. If the work is irrecoverable34or safety-critical, stop tiering and use the premium model.3536## Prerequisites3738- Visibility into the models your agent or gateway exposes (OpenRouter catalog,39 a provider console, or the `model` config of OpenClaw / Claude Code / Codex).40- No secret is required to operate this skill; the pricing table in41 `references/model-pricing.md` is illustrative, so refresh it against provider42 docs before relying on a number.43- If you run the classifier, `scripts/classify_task.py` is stdlib-only.4445## Decision Rules (read these before you pick a model)4647- **Rule 1 — vision.** If the task needs images (screenshots, photos, charts,48 image generation), pick a *vision-capable* model. Never route vision work to a49 text-only model just because it is the cheap tier — the cheapest viable model is50 the cheapest one that can actually see.51- **Rule 2 — escalation.** If a cheaper model already failed the same task, move52 one tier up, not down; re-trying the same failed tier burns more than one upgrade.53- **Rule 3 — explicit signals.** Complex words like `debug`, `architect`,54 `design`, `security`, `adversarial`, `ambiguous` push to Tier 3. Routine words55 like `read`, `fetch`, `check`, `format`, `status`, `list` push to Tier 1.56- **Rule 4 — classify by default.** Otherwise classify the task with the procedure57 and pick the tier that matches.5859## Task Classification6061| Bucket | Heuristic | Typical Examples |62|---|---|---|63| ROUTINE → Tier 1 | Single-step, deterministic, no judgment | file I/O, heartbeat, status check, lookup, formatting, URL fetch |64| MODERATE → Tier 2 | Multi-step but well-scoped | code-gen on known patterns, summarization, draft writing, data transforms |65| COMPLEX → Tier 3 | Ambiguous, multi-approach, high-stakes | multi-step debugging, architecture, security review, long-context reasoning |6667## Quick Reference6869| Concern | Move |70|---|---|71| Task is routine | Tier 1 |72| Task is moderate | Tier 2 |73| Task needs image / vision | vision-capable model (never a text-only tier-1) |74| Task already failed on cheap | move up (escalation), never down |75| Heartbeat / cron / monitoring | always Tier 1 |76| Sub-agent spawn | default Tier 1 unless clearly moderate+ |7778## Procedure7980Each step ends with a checkable completion criterion.81821. **State the task.** Write the task in one line, including whether it needs83 images and whether a cheaper model already tried.84 *Completion: you have a task statement with its vision and prior-failure flags.*85862. **Classify.** Run `python3 scripts/classify_task.py "<task>"` in the terminal,87 or read the bucket heuristics above by hand.88 *Completion: you have a label of `ROUTINE`, `MODERATE`, or `COMPLEX`.*89903. **Apply the vision override.** If the task is vision-requiring, restrict the91 model choice to vision-capable options, ignoring any text-only option entirely —92 a text-only model cannot take image input at any price.93 *Completion: the chosen model can actually accept image input.*94954. **Apply escalation and signal overrides.** If a prior failure exists, go one96 tier *up* from the classifier result. If explicit complex signals appear, go to97 Tier 3.98 *Completion: the final tier is never lower than the classifier would have99 produced.*1001015. **Name a concrete model.** From the provider's resolvable list, pick the102 cheapest model of the final tier that meets that tier's bar.103 *Completion: you can name a concrete model, or a route to find one.*1041056. **Run the anti-pattern sweep.** If this is a sub-agent, heartbeat, cron, file106 I/O, or routine batch, drop it to Tier 1 unless the classifier returned107 MODERATE or above.108 *Completion: no heartbeat/cron work remains on a premium tier.*109110## Anti-Patterns111112- **Feeding heartbeats / cron to premium models.** A two-token status ping on a113 flagship model is pure waste.114- **Spawning sub-agents at the parent's tier.** Daemon children should be one tier115 down unless the work is provably complex.116- **Refusing to upgrade when stuck.** A cheap model that already failed costs more117 if you keep retrying it; one step up is the cheaper path.118- **Routing vision to a text-only model.** GLM-5 (and other cheap text-only tier-1/2119 models) must never see image input. Send vision to a vision-capable model.120- **Tiering on habit.** Do not stay on a new flagship model just because it is the121 default; escalate on evidence only.122123## Verification124125- The classifier `scripts/classify_task.py` returns Tier 1 for a routine phrase,126 Tier 2 for a moderate phrase, and Tier 3 for a complex phrase.127- A vision phrase (screenshot / photo / chart) routes to a vision-capable model,128 and a text-only model is never selected for it.129- A failed-task phrase routes one tier *up* from baseline, never down.130- The heartbeat / cron phrase never lands on a premium tier.131- `references/model-pricing.md` exists and contains the pricing table and the132 "prices change, check provider docs" caveat.