Self-learning routing
Learn the cheapest model for each difficulty level from your own sessions, and keep your smart routing up to date every week.
Smart routing sends each task to the model you picked for its complexity level: low, medium, high, or max. Self-learning routing picks those models for you. It labels the turns of your coding-agent sessions as they run, then replays your real sessions every week with different models and recommends the cheapest tier map that keeps each turn on a model fit for its difficulty.
The recommendation is based on your own traffic: your agents, prompts, cache behavior, and prices. You can apply it in one click, or let the weekly run keep your strategy up to date, within guardrails.
How it works
Classification labels each turn
When a developer sends a new message to their agent, the gateway rates it while the request runs: its difficulty (the tier), the kind of work (front-end, debugging, code review, and so on), and whether a person or the agent wrote it. Only the labels are stored, with the request's usage record.
A weekly run replays your sessions
Once a week, Edgee takes the labelled sessions of the last 30 days and runs them again through a model of the gateway's smart routing, with many candidate tier maps. Each replay follows the same rules as live routing: models switch only at user turns, and switching to a model whose cache is cold pays to rewrite that cache.
You get a recommendation
The run recommends the cheapest tier map, and the switching settings that suit it best. It never recommends a map that would have cost more than what you paid.
The map runs as a strategy
Applying the recommendation writes it to a smart routing strategy named Self-learned routing. You choose where it runs, like any other strategy.
Turn it on
In the console, open Rerouting Strategies and click Self-learning routing. You can also reach it from Settings → Gateway.
The setup has two switches. Classification is required; the rest is optional.
| Setting | What it does |
|---|---|
| Classification | Labels each new turn's difficulty as it is served. It adds no latency. |
| Help train Edgee's classifier | Optional. Edgee also keeps the labelled text to train a classifier tuned to coding-agent work. |
| Self-learning | Each week, replays the labelled sessions and recommends a tier map and switching settings. Needs classification. |
| Updates | Manual: each week's recommendation waits for an admin to apply it. Automatic: the weekly run updates the self-learned strategy itself when every guardrail passes. |
Turning on classification, or training, asks you to accept a notice that says what is sent and what is kept. Turn on all enables classification and weekly self-learning in one step.
Turning classification off also turns off self-learning and training.
Your first recommendation
A replay needs labelled sessions, so the report starts empty. The page walks you through three steps:
- Turn on classification.
- Let your sessions be labelled. New turns are labelled as your developers work: the first labels appear within minutes.
- Read your recommendation. The first weekly run comes within a week. To get one sooner, click Recompute now to compute one from what is labelled so far.
Traffic from before you turned classification on cannot be replayed. Give it a few days of normal use before you rely on the first recommendation.
What is sent, and what is kept
- Sent: the latest message of each new turn of a session, truncated to its first 4,000 characters. Nothing else from the conversation.
- Not sent: tool loops, subagent calls, Claude Code's permission checks, and requests without a session id. Agent chores and continuations are recognized by rule and labelled without a call.
- Kept: only the labels (difficulty, confidence, kind of work, who wrote the turn), with the request's usage record. The message text is never stored or logged, and is never part of debug logs.
- Cost: labelling runs on Edgee's credentials, never your BYOK keys, and does not appear in your usage.
- Latency: none. Labelling runs alongside the request.
With Help train Edgee's classifier on, Edgee also keeps the labelled text with its labels, only to train and evaluate its own routing classifier. Turn it off at any time to stop the collection.
Read the recommendation
The Self-Learning Routing page shows the latest run's report in three tabs.
- Data behind the recommendation: the share of your spend the run could replay, and why the rest could not be.
- Recommended routing: the model for each tier, the share of replayed spend each tier carries, and the replayed saving with its range.
- Subagents: a model for delegated work, such as Claude Code's Task tool. A subagent call starts in a fresh context, so its recommendation needs no label and is ready before your first run. Only models rated Elite or better qualify, and its saving is computed at catalog prices.
- Compare maps: the candidate maps that came closest. A calmer map switches models less often and serves fewer requests below their label.
How the map is chosen
For each tier, the run considers the three cheapest models that meet the tier's minimum catalog rating:
| Tier | Minimum rating |
|---|---|
| Low | Strong |
| Medium | Elite |
| High | Frontier |
| Max | Frontier |
The floors are one notch above the bare minimum, so a catalog that over-rates a small model cannot put it in front of a hard task. Candidates are the model and provider routes that every active key can use under your organization, squad, and key policies, including Model access. Keys restricted to BYOK exclude routes billed to Edgee credits.
Every combination of candidates is replayed, and the cheapest map wins. The run then replays that map under a few switching settings: the gateway defaults, the setting in force, and variants with a different switch threshold, no pause between switches, or no confidence gate. A setting replaces the one in force only when it saves clearly more without serving more requests below their label, so a weekly run does not flip between settings that differ by noise.
Savings and confidence
Savings are what the replay bills, so switching costs and timing are included. Every request keeps its real token counts; a request served exactly as it was costs what it was billed. Prices are your selected provider's catalog rates, without negotiated discounts or prepaid commitments. Monthly figures scale the 30-day window to a month.
The saving comes with a 95% range, computed by resampling your sessions. Confidence depends on how much of your spend was replayed:
| Confidence | When |
|---|---|
| High | At least 70% of spend replayed, and a 95% range under 10 points wide |
| Medium | Neither high nor low |
| Low | Less than 40% of spend replayed |
Spend the run cannot replay is split by reason: traffic from before labelling was turned on, sessions with no labelled turn, and requests with no session id. The page names the keys behind most of it.
Apply a recommendation
Click Apply tier map. The first time, this creates a smart routing strategy named Self-learned routing, built for all agents. It routes nothing until you choose where it runs: the organization, a squad, or members. Later applies update the same strategy.
Self-learned strategies carry a Self-learned badge on the strategies list, with the data they were learned from. Like every smart routing strategy, a self-learned strategy takes priority over any other strategy on the keys it reaches. See which strategy wins.
To check it is working, start a new session and look at the served model and provider in Logs.
Weekly runs
With self-learning on, a run starts about once a week. Each run replays the last 30 days. Click Recompute now to queue a run at any time: it starts within a few minutes. One run per organization can be in progress at once.
The Runs list shows what became of each run:
| Status | Meaning |
|---|---|
| Applied automatically / Applied by an admin | The map now runs in the self-learned strategy. |
| Proposed: waiting for an admin | The recommendation is ready. Apply it from the report. |
| Nothing to change | No map would have cost less, the strategy already runs this map, or there was nothing to replay yet. |
| Held back by a guardrail | Automatic updates are on, but a guardrail failed. The reason is shown under the run. |
Automatic updates and guardrails
With Updates set to Automatic, the weekly run applies its recommendation only when all of these hold:
- A self-learned strategy already exists and runs somewhere. The first apply, and where the strategy runs, are always an admin's choice.
- Nobody edited the strategy since it was last applied. After a manual edit, runs propose instead, and an admin decides whether the new map replaces the edit.
- Confidence is medium or high, and the saving's 95% range is entirely above zero.
- The new map saves at least 3 points of billed spend more than the map in force, without serving more requests below their label.
- Every model in the map has served enough of your traffic to judge. A model new to your organization is proposed, not rolled out automatically.
- No model in the map fails more often on your traffic than the models your agents ask for.
Undo a change
Changes to the self-learned strategy lists every apply. Click Undo on the latest one to restore the tier map and switching the strategy ran before. Undoing turns Apply automatically off, so the next weekly run proposes its recommendation instead of applying it again.
You can only undo the latest change, and only while the strategy still runs exactly what that change applied. The run that created the strategy cannot be undone: delete the strategy from Rerouting Strategies instead.
See how your work is classified
With classification on, admins also get a Classification tab under the organization's activity:
- Classified turns and spend per day, by difficulty.
- Spend on easy turns: how much of your spend went to turns labelled low.
- Where the spend goes: the model each request ran on, the kind of work of its turn, then the turn's difficulty.
- Kind of work, and who wrote the turns.
- Latest recommendation, with a link to review and apply it.
- Latest sessions: open one to see the difficulty of each of its turns.
Good to know
- Self-learning only recommends smart routing tier maps. Your manual strategies are not changed.
- A tier map can only use models allowed by Model access and covered by your providers.
- Editing the self-learned strategy changes routing for every scope it is assigned to, and stops automatic updates until an admin applies a new recommendation.
- Turning off self-learning stops the weekly runs. The self-learned strategy keeps running until you unassign or delete it.