1. Limits first
Organization, team, person and session budgets, rate limits and the per-request cost ceiling are checked from the gateway's own counters. Over a limit, the request is refused before it costs anything, and the error says which limit.
2. A level for the work
Rules read the request, with no model call. Plain text is general 2. Tools or code make it coding, at 3, and the task's wording then sets the level: "write tests", renames, typos and docstrings put it at 2; hard wording such as "race condition", "migration" or "under load" adds one for each kind, up to two; "architecture" or "design a" puts it at 5. What the harness adds (Claude Code's system reminders, Codex's AGENTS.md) isn't read as the task. Length never raises a level.
3. Each model's chance
Every model has a 1 to 5 score per kind of work, from Epoch AI's benchmark data against a fixed bar, or from your own evals, and from it a chance of finishing work at each level. A model may serve the task when the conversation fits its context window, the team may use it, and its chance is above the floor.
4. Price for the rest of the session
Every route of every model that may serve the task is priced as rebuild + expected turns × cost per turn. The rebuild is what it costs to get the conversation into that provider's cache: zero where it is already warm. That is the try.
5. Pick, shape, send, record
The lowest expected total wins: try + (1 − chance) × (person's time + next attempt), with a person's time at $1 a failure by default (a minute of a developer), set per team. The gateway adds cache markers, compresses tool output if the team turned it on, and sets reasoning effort from the level. If the provider fails, the next route takes it, before anything reaches your tool. A ledger row records the cost, what the baseline model would have cost, and why.