How-toMulti-sourceSelected

Agent model routing implementation

Why we picked it

This approach demonstrates how significant cost savings can be achieved without compromising quality by intelligently routing tasks based on complexity. Developers can implement similar routing in their own systems using LangChain middleware, with the decision model Jev offering 50x faster classification. The method is particularly valuable for organizations managing large-scale AI operations where cost efficiency is critical.

LangChain team implemented model routing in their open-source Coding Agent 'Open SWE' to distribute tasks based on difficulty across different price tiers.

Body

In a 973-thread A/B test, median costs decreased 64% ($2.61 to $0.

94) while maintaining quality (29.2% vs 27.

3% merged PR rate, p=0.49).

The routing uses GLM-5.3-Flash, GPT-5.

6 Sol, and GPT-6 Astra models, with 56% of requests going to balanced, 34% to fast, and only 10% to performance tier.

Original · shao__meng

在你的 Agent Harness 里怎么构建一个模型路由? 以及,为什么要建在 Harness 里,不能建在网关层? 来自 @LangChain 团队 @sydneyrunkle 的分享,在开源 Coding Agent「Open SWE」构建了一个模型路由,根据任务难度把请求分发给不同价位的模型,结果在 973 个线程的 A/B 测试中,中位成本降低 64%($2.61 → $0.94),质量(合并 PR 率 29.2% vs 27.3%,p=0.49)没有统计学上的显著差异。 Sydney 认为:路由决策应该放在 Agent Harness 里,而不是通用网关层,因为只有 Harness 拥有判断“该用哪个模型”所需的领域与任务上下文。 # 四步构建方法 1. 理解任务(先看数据) 从 LangSmith 追踪数据中取一周的真实线程,用 LLM 分类器打标。任务分布:新功能 22%、bug 修复 17%、测试/空跑 16%。关键发现是复杂度信号清晰,功能调研类线程又长又贵,测试/发布类短且便宜,说明“从初始请求推断难度”是可行的。 2. 理解模型(沿 Pareto 前沿选) 借助 Artificial Analysis 的智能指数绘制“智能-成本”曲线,选出三个层级: · Fast:GLM-5.3-Flash(开放权重,性价比前沿) · Balanced:GPT-5.6 Sol · Performance:GPT-6 Astra(顶级前沿模型) 3. 在 Harness 中构建路由 通过 LangChain 中间件实现,Agent 本身零改动。路由只在线程的首条人类消息上运行一次,由三部分组成:基础提示词(“挑最便宜的可能完成任务的模型”)+ 每个层级的自然语言准入标准 + 分类器。第一版用带结构化输出的 LLM,后换成新发布的决策模型 Jev,分类速度提升近 50 倍。已知局限:模型选定后整个线程不再更换。 4. 追踪任务结果 主指标是合并 PR 率,辅以用户点赞/点踩反馈(虽然稀疏,但恰好暴露了路由错误)。 # 实验结果的关键细节 路由分布:56% 走 balanced,34% 走 fast,只有 10% 真正需要 performance 层,印证了大量日常请求根本用不着顶级模型。 层级间成本差约 30 倍(fast 中位 $0.097,performance $2.88)。 均值只降 42%、p90 只降 37%,而中位数降 64%;说明重度任务该贵还是贵,省的是“大多数普通任务”的钱。 反向验证很有说服力:他们还测了“只用 fast 模型”的对照组,结果一天内就因质量问题被叫停,证明路由不是“全用便宜模型”,而是“该省的省、该花的花”。 用户反馈也印证了痛点:简单查询跑在最强模型上时,工程师会直接吐槽 "pretty expensive for this query"。 Sydney Runkle @sydneyrunkle x.com/i/article/2105… 🔗 View Quoted Tweet📊 1 ⚡

Industry Coordinates & Source Verification

This report is categorized under AITOP's "How-to" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows and US-China foundation model benchmarks and commercialization comparison. Key entities and technical topics under continuous tracking include LangChain, model routing, Open SWE, Jev.

Source attribution: curated from shao__meng (@shao__meng). Cross-source corroboration: 7 independent sources have covered this development (including Harrison Chase, rohanpaul_ai, LangChain), confirming industry-wide signal strength.