The AI Gazette

Cost and routingCoding agents

Changing models mid-session throws away the cache a coding agent paid for

A post from Edgee, which runs a gateway that routes coding agents between models, argues that choosing the cheapest capable model for each request is only half of routing. Every change of model throws away the prompt cache, so the other half is deciding when a running session should move, and that has the shape of a classic rent-or-buy problem.

A coding session is one long conversation. The agent resends everything said so far with every request, and providers cache that history so it is not processed from scratch each time. On Anthropic, writing a prefix to the cache for five minutes costs 1.25 times the normal input price and reading it back costs a tenth. A session that changes model loses that warm cache: the new model reads the whole conversation cold and writes it to its own cache. For a long session, Edgee writes, that one rewrite can cost more than many turns of the price difference between the two models.

Edgee's gateway splits the decision in two. A classifier scores each user turn on how much capability it needs and maps it to one of four tiers, from a typo or a rename up to architecture and security-critical work. Moving up is not a cost question: a turn that needs a stronger model gets one at once, whatever the switch costs, as long as the classifier is confident. Moving down to a cheaper model is a cost decision, made turn by turn without knowing what the developer will ask next.

That is the ski-rental problem. A skier can rent each day or buy once, without knowing how long the season will last. Staying on the current model is renting: each turn costs a little more than the cheaper model would. Switching is buying: one payment for the cheaper model to read and cache the conversation. The break-even rule, rent until the rent paid equals the price of the skis and then buy, never pays more than twice what perfect hindsight would, and no fixed rule does better in the worst case. Edgee switches when the rent paid reaches 1.5 times the price, because a hard turn can force an upgrade and waste a purchase made at exactly break-even.

A session differs from a ski season in ways that matter. The price of switching rises as the conversation grows. And sometimes the skis are free: when the cache has expired or the conversation has just been compacted, the current model has to rewrite everything anyway, so switching costs nothing extra. Once a week Edgee replays an organization's past 30 days of sessions under different tier maps and switching settings, and recommends the cheapest combination that keeps every turn on a capable model.

Edgee does not publish a saving, since each organization's report shows its own. One measurement it does share: in its replays about half of all switches were set off by text the agent wrote for itself, such as status lines, titles and suggested prompts, which says nothing about how hard the work is. The replay also assumes a different model would have written answers of the same length, which the company names as its main assumption.

From other editions

Say hi.