SWE-Router: Routing in Multi-turn Agentic Software Engineering Tasks¶
🕒 Published (v1): 2026-06-30 01:46 UTC · Source: Arxiv · Venue: ICML 2026 · link
Why this paper was selected
ICML 2026; cost-routing in multi-turn agentic SWE harnesses directly actionable
Ask a follow-up
Open an assistant pre-loaded with this paper's context.
💬 Ask ChatGPT✦ Ask Claude
TL;DR¶
SWE-Router introduces value-based temporal routing for multi-turn SWE agents: a cheap model runs \(K\) exploratory turns, then a learned value head reads the resulting partial trajectory to decide whether to continue cheaply or escalate to a frontier model. A formal Bayes-optimality theorem proves that conditioning on the partial trajectory \(\mathcal{T}_{\leq K}\) weakly dominates prompt-only conditioning, and is strictly better whenever early exploration is informative. On SWE-Bench Verified, this yields Route-AUC improvements of +12–15 pp over the best prompt-only baselines.
Problem¶
Existing LLM routers condition only on the task description \(q\), but in agentic SWE tasks a similar issue description can hide either a localized typo or a multi-module refactor. This creates an information-theoretic Bayes-error floor: the prompt does not carry enough signal to reliably discriminate task difficulty, so routing decisions are systematically noisy regardless of classifier quality.
Method¶
At deployment time, the weak model \(m_1\) executes \(K\) ReAct-style turns (thought \(z_t\), action \(a_t\), observation \(o_t\)) to produce a partial trajectory \(\mathcal{T}_{\leq K,1}\). A value head — Qwen2.5-Coder-7B-Instruct with a LoRA-fine-tuned 2-class classification head — is trained with cross-entropy on binary task-success rewards to estimate \(\hat{r}_1(\mathcal{T}_{\leq K,1}) \in [0,1]\).
The one-sided routing rule is:
where \(\lambda''\) absorbs all cost terms and is tuned on validation. On escalation, \(m_2\) restarts from \(q\) (not from \(m_1\)'s context) to avoid anchoring \(m_2\) on \(m_1\)'s potentially erroneous reasoning. The \(K\) exploratory turns are counted in the escalated run's cost budget.
Key Contributions¶
- Identifies the Bayes-error floor of prompt-only routing in multi-turn agentic settings and frames it information-theoretically.
- Theorem 4.1: for any integrable utilities \(U_1, U_2\), \(V(\mathcal{S}_t) \geq V(Q)\), with strict improvement when exploration is informative (proved via conditional Jensen inequality on \(|\cdot|\)).
- SWE-Router: first routing framework that conditions on the agent's own intermediate observations (file reads, stack traces, test failures) rather than the original prompt.
- Multi-LLM trajectory dataset covering four LLMs on SWE-Smith and SWE-Bench for reproducibility.
Results¶
- Route-AUC on SWE-Bench Verified (threshold sweep, normalized so all-weak = 0, all-strong = 1):
- deepseek-v3.2 → gemini-3-pro-preview: 0.780 (+15.3 pp over non-temporal K=0 baseline)
- gpt-5-mini → gemini-3-pro-preview: +12 pp over strongest prompt-only baseline
- SWE-Router cost–resolved curve sits strictly above the random-assignment band (400 Monte-Carlo permutations) across both pairs.
- For some thresholds, the routing curve briefly exceeds the all-strong endpoint, indicating synergistic complementarity between weak and strong model solve sets.
- AUROC of the value head does not strongly correlate with Route-AUC, suggesting raw discriminative accuracy is not the binding factor.
Limitations¶
- Escalation restarts \(m_2\) from \(q\), discarding all \(K\) turns of \(m_1\)'s context; continuation rules requiring \(m_2\) to read \(m_1\)'s trajectory are noted as too costly for online use.
- \(K\) exploration turns are sunk costs even for escalated instances, widening the cost gap relative to pure prompt routing when \(m_1\) explores unproductively.
- Value head trained on trajectories from a specific weak model; cross-model generalization is untested.
- Only binary weak/strong model pairs evaluated; extension to \(N\)-model cascades is not addressed.
- Safety risk acknowledged: routing away from safety-focused frontier models based on trajectory content could be exploited.
Relevance to Harnesses / Meta-Harnesses¶
SWE-Router is a meta-harness component: it wraps around an existing agentic harness (mini-SWE-agent) and dynamically selects which underlying LLM the harness should use mid-trajectory, treating the harness's intermediate state as a first-class routing signal. This is a direct instantiation of the meta-harness pattern where a controller observes and steers inner agents rather than being blind to their execution. The work demonstrates that harness-level trajectory data (thoughts, actions, observations) is strictly more informative than the task input alone for orchestration decisions — a principle applicable to any meta-harness that must allocate compute, select tools, or escalate between agents.