unhardcoded
concepts & recipes

Policies

How routing decides: filter first, rank survivors, no silent downgrade. Plus copyable presets grouped by goal.

Routing semantics

Filter first. Rank survivors. No silent downgrade. Routing is deterministic and ordered, and spend ceilings and quality minimums live in the filter, not the score, so a cheap model can never win on points against your rules. If it does not clear the floor, it is not a candidate at all.

filter first
Candidates lacking a required capability, missing the quality floor, or over the price ceiling are eliminated, removed, never silently substituted.
rank survivors
Among models that cleared the floor, the scorer orders them, usually cheapest-first.
select the top
One model, chosen deterministically. The same policy, inputs, and catalog always select the same model.
fall back in order
If the selected model times out or errors, the router moves to the next passing candidate, cheapest-first, and records every hop.

A decision, step by step

One policy (tools, bench_intelligence ge 0.5, cheapest) over a live catalog (price_out is USD per million output tokens). The filter drops the two models below the floor; the cheapest survivor wins:

modelprice_outintelverdict
deepseek-v4-flash$0.400.465below floor
minimax-m2.7$0.500.496below floor
deepseek-v4-pro$1.500.515selected
glm-5.1$2.000.514over floor
gpt-5.5$10.000.602over floor
The floor is a guarantee, not a suggestion. Routing optimizes cost beneath your floor, never around it. If no model meets the requirements, the request fails loudly (no_candidates); you never get a silent downgrade you didn't ask for. Terms are admitted and fingerprinted before they run, so a malformed policy is rejected (invalid_policy) rather than mis-routed.

Preview a decision without spending inference: POST /x/rank returns the ranked survivors and the rule that dropped each model.

Watch policies resolve

The same idea inside a workflow: each node declares its own policy: a filter and a rank. Watch every step drop what fails its bar and lock the cheapest survivor (the output node declares no model; it just returns the last step).

Policy presets

Copyable routing patterns, grouped by goal. Each is an ordinary policy_ir: paste it, adjust the floor and ceiling, and ship. Dry-run with POST /x/rank first.

Smart balancecapability and price in balance, no thinking requiredcost · quality
smart-balance.json
["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
  ["add",
    ["scale", 0.6, ["normalize", ["field", "bench_intelligence"]]],
    ["scale", 0.4, ["neg", ["normalize", ["field", "price_out"]]]]],
  ["argmax"], ["id"], ["always", {"action": "next_candidate"}]]
Cheapest decenttrims the bill behind an intelligence floor, the unhardcoded hookcost
cheapest-decent.json
["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]],
         ["cmp", "bench_intelligence", "ge", 0.5]],
  ["neg", ["normalize", ["field", "price_out"]]],
  ["argmax"], ["id"], ["always", {"action": "next_candidate"}]]
Free-onlyzero output-cost models onlycost
free-only.json
["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["cmp", "price_out", "le", 0]],
  ["field", "bench_intelligence"],
  ["argmax"], ["id"], ["always", {"action": "next_candidate"}]]
← Back to docs