Edgee, the company behind the Agent Gateway, argues that picking the right model for each request solves only half of routing for coding agents. The other half is deciding when a session already in progress should change models at all. In a blog post by Khaled Maâmra on the Edgee site, the company maps that decision onto ski rental, a textbook puzzle from the theory of online algorithms.

Start with the puzzle itself. A skier pays a daily rental fee, or pays B once to own the equipment. Nobody knows how long the season will last. Rent every day of a long season and you overspend. Buy on day one and a season that ends tomorrow leaves you with skis you never use.

The standard answer is to rent until your total rent equals B, then buy. Worst case, you pay 2B against the B an all-knowing planner would have paid, so the rule is called 2-competitive. Sleator and Tarjan introduced that style of analysis in 1985, and Karlin, Manasse, Rudolph and Sleator studied this exact rent-or-buy shape for multiprocessor caches in 1988. Randomizing the purchase moment lowers the bound to about 1.58, a result from 1994. Edgee keeps its gateway deterministic so a replay of any session gives identical decisions.

The cost that plays the role of the skis is a cache rewrite. A coding agent resends the whole conversation on every request, and providers cache it. On Anthropic, holding a prefix in cache for five minutes is billed at 1.25 times the base input rate, and a cache read at one tenth of it. Change model and the new one reads the full history cold. Over a lengthy conversation, a single rewrite can outweigh the price gap between the two models across a lot of turns.

So the gateway rents by staying on the current model and forgoing the saving each turn, and buys by switching. It keeps a running total of the saving forgone and switches when that total reaches 1.5 times the one-off switching cost. Textbook ski rental would use a multiplier of 1. Edgee’s reason for 1.5 is practical: a hard task can force an upgrade on the very next turn, so a downgrade bought at exact break-even risks a second rewrite for nothing. The worst-case ratio at 1.5 is 2.5, and Edgee accepts the weaker bound knowingly.

Difficulty still comes first. A classifier scores each user turn from 0 to 1, with cutoffs at 0.2, 0.5 and 0.8 separating low, medium, high and max tiers. Upgrades ignore cost entirely, though a confidence of 0.75 or more is needed to move at once, and a label between 0.5 and 0.75 must repeat for two consecutive turns. After any switch the gateway waits four turns before switching again to save money. Switching is free when the cache has lapsed or the conversation shrinks below 60 percent of its length, as happens when Claude Code compacts it. The gateway holds a session’s state for six hours.

Edgee’s own example is a 28-turn real session replayed on OpenAI’s GPT-6 Astra. A compaction cut the conversation from about 224,000 tokens to 25,000, which made the downgrade cheap, and a later 38-minute pause also expired the cache. Both are the free-switch cases in action.

The company also admits the theory is a guide, not a guarantee. Prices rise as conversations grow, and the proof assumes fixed prices. To close that gap, Edgee replays 30 days of an organization’s traffic, up to 2m requests, once a week. It tests up to 81 tier-to-model maps per agent and compares six switching settings, including thresholds of 0.5 and 5, against the hindsight optimum. Edgee rates its confidence high only when the replayed sessions account for at least 70 percent of spend. Edgee also says about half of the switches it saw in its own replays were triggered by the agent’s own self-written text, such as status lines, which says nothing about task difficulty.

Edgee does not publish a headline saving figure. Each customer gets a replayed estimate with a 95 percent interval, which means the numbers come only from the vendor’s own method on the customer’s own traffic.

For teams running coding agents at scale, the practical lesson holds even without Edgee: log how often sessions change model and what each switch costs in cache rewrites, because a router that switches on every easy-looking turn can spend its savings on rebuilding context.

Edgee blog post “Switching LLMs mid-conversation is a ski-rental problem” by Khaled Maâmra, published on edgee.ai (publication date not stated on the page).