LangChain engineers use Open SWE, the company's open source coding agent, from Slack and a web UI to ask questions about LangChain codebases and request code changes. Monthly coding-agent spend was climbing rapidly while every thread ran on a top-tier frontier model, so the team built a model router inside the agent harness.
To map the task space, the team pulled thread-level data from LangSmith traces: the kinds of requests, plus each thread's cost and turn count as approximate measures of complexity. They explored it in LangSmith Custom Apps with a small interface built on the Open SWE traces, then labeled a week of interactive threads by task type with an LLM classifier. New features (22%) and bug fixes (17%) were the largest groups, followed by test or no-op runs (16%). Feature work threads tended to be longer and costlier, while testing and release threads were short and cheap.
The team chose three tiers from the Artificial Analysis intelligence-versus-cost Pareto frontier, from different providers: fast GLM-5.3-Flash (xhigh), an open model; balanced GPT-5.6 Sol (medium); and performance GPT-6 Astra (low). Because LangChain's model interface works across providers, swapping a tier is a one-line change.
The router is LangChain middleware, which can swap the model an agent calls without changing anything else about the agent. It runs on the thread's first human message and has three parts: a base prompt telling the classifier to pick the least expensive model likely to complete the task; short plain-language criteria per tier, written from the team's own task analysis and the providers' guides for each model; and a classifier model that reads the request and picks a tier. The first version used an LLM with structured output; the classifier now runs on Jev, a decision model, which made classification almost 50 times faster. The chosen model is used for the whole thread; there is no mid-thread re-routing, and subagents still pick their model independently of the router.
To track outcomes, Open SWE now records every PR it opens and whether it is merged or closed, and merged PRs per thread became the main success metric. The team also added thumbs up and down to Open SWE, logged as feedback on each thread's LangSmith trace, and tracked both in a LangSmith Custom App. Evaluation was an A/B test on live threads rather than an offline dataset.
In the self-reported test, half of 973 threads went through the router and half always used GPT-6 Astra. Median cost per thread was $0.94 routed versus $2.61 control (64% less). Merged-PR rate was 29.2% versus 27.3% (p = 0.49) and PR open rate 38.9% versus 39.6% (p = 0.82). Routed threads went 56% to balanced, 34% to fast and 10% to performance. A second test against an always-fast control was stopped within a day after engineers reported low output quality.
Details
- City
- San Francisco
- Organization
- LangChain
- Continent
- North America
- Country
- United States
- Category
- Software
- Type
- Deployment
- Id
- bb0a39ce-2ba4-4fd6-8633-b46d0d5af6eb
- Created At
- 26 Nov 2026