Agents in action
LangChain's model router cut median cost per coding-agent thread 64% in a 973-thread test
On its own blog, LangChain describes adding a model router to Open SWE, its open source coding agent. The router picks one of three model tiers at the start of each thread instead of always using a top-tier frontier model.
What the agent did
- Labeled a week of Open SWE threads by task type. New features were 22%, bug fixes 17% and test or no-op runs 16%.
- Built the router as LangChain middleware that reads the first message and picks a fast, balanced or performance model. Moving the classifier to Jev made classification almost 50× faster.
- Ran an A/B test over 973 threads against always using GPT-6 Astra. Median cost fell from $2.61 to $0.94, the mean fell 42% and the p90 fell 37%.
- Merged-PR rates did not change measurably: 29.2% routed vs. 27.3% control (p = 0.49).
- Sent 56% of routed threads to the balanced tier, 34% to fast and 10% to performance. Median tier costs ranged from $0.097 to $2.88.
What AgentGid data shows
- LangChain: 41,108,351 weekly package downloads as of 2026-10-11, down 16.9% over 30 days.
- LangChain: 147,530 GitHub stars, #1 by Gid Score among agent frameworks and SDKs, and #4 of all tracked agents.
- LangChain is open source (MIT) and free to use. You pay only for the models and infrastructure it runs on.
What it means for you
- The framework costs nothing to try. Your spend is the models each tier calls, so the cost gap between tiers drives the savings.
- Other frameworks in the same category worth comparing include LangGraph, AI SDK, Strands Agents, Mastra and DSPy.
- Measure outcomes before you route. LangChain stopped a router-vs-fast-only test within a day after engineers flagged low output quality from the fast-only arm.
Why it matters
Many agent tasks don't need the most expensive model, and a router that understands the agent's own task mix can send them somewhere cheaper. LangChain's result suggests the savings depend on tracking real outcomes, such as merged PRs, alongside cost.
These are LangChain's own figures from one internal A/B test on its own coding agent, compared against its most expensive model. LangChain calls the router a proof of concept.
Source: LangChain blog
Numbers about what happened come from the source; numbers in "What AgentGid data shows" come from our tracking (methodology). Figures a vendor reports about its own product are as reported, not tested by us.
Comments
- Tried something like this? Share how it went for you.
Agents in this story
| # | Agent | Gid Score | Downloads 7d | 7d | 30d | Stars | Latest release | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 |
LangChainLangChain |
79 | 41.8M | — | down 2.8% | 149K+67/day | 1.4.710d ago | ||||
| No agents match that filter. | |||||||||||