Residual-Guided Model Selection for Terminal-Based Coding Agents

A terminal observation does not by itself indicate whether a command produced the outcome an agent expected. We introduce ARFA, which records expectations before command execution and uses a weighted execution residual to select the model for the next reasoning turn. We compare six routing policies for each of two model pairs on 100 InterCode NL2Bash tasks reserved for routing evaluation. Relative to always using the slow model, ARFA reduced mean wall-clock time per attempt by 21.5% with Gemma and 14.4% with Qwen, solving 37 versus 28 tasks and 42 versus 41, respectively. The Gemma configuration also solved 37 tasks versus 26 for an expectation-completeness gate. Compared with learned observation-only routing, Gemma solved more tasks but took longer, while Qwen solved one additional task at nearly the same mean time. Further model-pair experiments show that fewer slow-model calls need not reduce mean task time. In a separate development ablation with one cross-family pair, structured handoff used less time and fewer tokens than bounded visible history, with 28 versus 29 tasks solved.

Authors

Institutions

Publication Details

Journal
arXiv
Published
2026-12-02
Primary Topic
Software Engineering Research
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Residual-Guided Model Selection for Terminal-Based Coding Agents

Zhaoling Chen, Chang Zhou, Qian Zhang
arXiv
Software Engineering Research
preprint

Residual-Guided Model Selection for Terminal-Based Coding Agents

Zhaoling Chen, Chang Zhou, Qian Zhang
preprint en

Abstract

A terminal observation does not by itself indicate whether a command produced the outcome an agent expected. We introduce ARFA, which records expectations before command execution and uses a weighted execution residual to select the model for the next reasoning turn. We compare six routing policies for each of two model pairs on 100 InterCode NL2Bash tasks reserved for routing evaluation. Relative to always using the slow model, ARFA reduced mean wall-clock time per attempt by 21.5% with Gemma and 14.4% with Qwen, solving 37 versus 28 tasks and 42 versus 41, respectively. The Gemma configuration also solved 37 tasks versus 26 for an expectation-completeness gate. Compared with learned observation-only routing, Gemma solved more tasks but took longer, while Qwen solved one additional task at nearly the same mean time. Further model-pair experiments show that fewer slow-model calls need not reduce mean task time. In a separate development ablation with one cross-family pair, structured handoff used less time and fewer tokens than bounded visible history, with 28 versus 29 tasks solved.

arXiv
University of California, Riverside (US), University of Wisconsin–Madison (US)
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon