🤖 AI Summary
This work addresses the inefficiency in existing routing strategies for multi-turn agent-based software engineering tasks, which either indiscriminately invoke high-performance large language models—wasting computational resources—or rely solely on initial task descriptions that fail to distinguish between simple fixes and complex refactorings. To overcome these limitations, the authors propose a novel value-based temporal routing mechanism that incorporates partial execution trajectories into routing decisions for the first time: a low-cost model initially explores several turns, and the system dynamically decides whether to switch to a high-performance model based on the generated trajectory. Theoretical analysis demonstrates that this approach strictly outperforms description-only routing when trajectory information is informative and achieves Bayesian optimality. Experiments show that the system preserves most of the high-performance model’s capabilities while significantly improving cost efficiency, and the authors release the first multi-LLM execution trajectory dataset tailored for trajectory-level routing.
📝 Abstract
Large language models (LLMs) embedded in multi-turn agentic harnesses are reshaping software engineering (SWE), but routing every task to a frontier model is wasteful when many issues admit cheap fixes. Existing LLM routers operate on the task description alone, which inherits an information-theoretic Bayes-error floor in agentic settings: a similar issue can hide either a localized typo or a multi-module refactor, and the prompt does not separate the two. We introduce SWE-Router, a value-based temporal approach that lets a cheap model run for a few exploratory turns and reads the resulting partial trajectory before deciding whether to continue cheaply or to escalate to an expensive model. We provide a Bayes-optimality theorem showing that conditioning on the partial trajectory never harms routing and is strictly better whenever exploration is informative. Across the LLM pairs of weak and strong models spanning the contemporary cost--capability frontier, we show that SWE-Router greatly improves the cost efficiency of SWE tasks, while maintaining the majority of the performances of the stronger model. We additionally release a multi-LLM trajectory dataset which allows reproduction of our trajectory-level routing.