October 13, 2026
Open SWE now picks the model for each task, cutting the median run's cost by 64%
LangChain taught its coding agent to pick a model for each task and now pays $0.94 for the median branch instead of $2.61.

Harrison Chase
@hwchase17
The router lives in the agent harness, not in a gateway in front of the models: the harness knows the task. blog: https://www.langchain.com/blog/how-to-build-a-model-router-in-the-harness
LangChain gave its coding agent three models and a router. Open SWE, their open-source coding agent, now sends each thread to the cheapest model likely to finish the job. they tested it on 973 threads, half routed and half always on GPT-6 Astra. median cost per thread: $0.94 against $2.61. that's 64% lower. threads ending in a merged PR: 29.2% routed, 27.3% on Astra. LangChain's p-value for that gap is 0.49. the router sent 56% of threads to the balanced model, 34% to the fast one and 10% to the performance one. they also tried always using the fast model. that test ended within a day, because engineers reported low output quality. LangChain's own caveats: the control was the most expensive model, and the router is a proof of concept. Which three models would you put in the tiers?

· 7.4K views
LangChain routed 973 branches of live traffic across three models. The median branch got almost three times cheaper.
The company left the choice of model to the agent itself. The router sits inside Open SWE, its open-source coding agent, and decides once, on the human's first message, which model gets the branch: the fast one, the mid-tier one or the strongest.
A branch here is one agent run, from the task statement to the pull request.
The bill per branch. With the router, the median branch cost $0.94. In the control group, where everything ran on GPT-6 Astra, it came to $2.61. That's 64% savings across 973 branches of live traffic (LangChain measurement, Oct 1).
Quality held up. 29.2% of router branches ended in a merged pull request versus 27.3% in the control, and the authors themselves call the gap statistically insignificant.
Previously the agent used one model for everything, and the company paid top-model prices even for a test run. Now 34% of branches go to the fast model, 56% to the mid-tier one and only 10% to the strongest. A median branch on the fast model costs 30 times less than on the strong one.
Putting the cheap model on everything didn't work. A second test, which switched the fast model on for every branch, was shut down at LangChain the same day: engineers themselves complained that the output quality got in the way of their work.
You can take it for yourself. The Open SWE router is open: the ModelSelectionMiddleware class in the langchain-ai/open-swe repository, file openswe/middleware/model_selection.py. There are no feature flags or environment variables; behavior is set by parameters at initialization.
For your own agent, LangChain published a ready-made ModelRouterMiddleware, installed with `pip install "langchain-typesafe[experimental]" langchain-openai`. The router reads the human's latest message, matches it against the model descriptions and keeps the chosen model until the end of the run.
LangChain has already moved classification from a general-purpose LLM to Jev, a dedicated decision model, and the choice is now made almost 50 times faster.
Source