CodeRescue: Budget-Calibrated Recovery Routing for Coding Agents

Agent Autonomous Workflows AI Systems and Hardware CACRR
2026年07月21日
编码智能体日益在可执行环境中运行,此时一次失败的尝试所产生的并非单纯错误答案,而是具有实际指导意义的执行反馈。现有的成本感知型系统通常将此类失败视为级联决策问题:先调用成本较低的模型进行尝试,若失败则将难题升级交由更强大但更昂贵的模型处理。然而,在编程任务中,执行反馈本身还可用于引导低成本模型开展后续修复尝试,从而引出一个关键的预算约束型部署问题:智能体究竟应在何时投入更多低成本计算资源以尝试修复,又该在何时选择升级至更昂贵的模型?我们将这一失败后的决策建模为面向异构动作的“修复路由”(recovery routing)问题,并基于大量执行轨迹(execution rollouts)训练了一个监督式路由模型。为进一步提升该路由模型在不同预算约束下的泛化能力,我们引入了一层“共形风险控制”(Conformal Risk Control, CRC)机制——该机制可在部署阶段无需重新训练,仅通过动态选取成本惩罚系数,即可在数据满足交换性假设的前提下,对边际期望成本实现可控调节。在五个编程评测基准上留出的未见失败案例中,低成本修复与模型升级展现出互补的成功模式。经CRC校准的决策前沿(calibrated frontier)在性能上显著优于固定策略、仅依赖提示词的路由方法以及二元级联基线;在主实验设定(GPT-5.4-nano / GPT-5.4)下,某一个CRC校准前沿点的求解率已超越“始终升级”策略,同时其平均修复成本仅为后者的35%。相关代码开源地址为:https://github.com/Qijia-He/agent-budget-control。
Coding agents increasingly operate in executable environments where a failed attempt produces actionable feedback rather than merely an incorrect answer. Existing cost-aware systems typically treat such failures as cascade decisions: try a cheap model first, then escalate hard cases to a stronger and more expensive model. In coding, however, execution feedback can also make further cheap-model recovery worthwhile, raising a budgeted deployment question: when should an agent spend more cheap compute, and when should it escalate? We formulate this post-failure decision as recovery routing over heterogeneous actions and train a supervised router from execution rollouts. To make the same router usable under changing budgets, we add a Conformal Risk Control (CRC) layer that selects a deployment-time cost penalty without retraining and provides marginal expected-cost control under exchangeability. Across held-out failures from five coding benchmarks, cheap recovery and escalation exhibit complementary success patterns. The calibrated frontier improves over fixed actions, prompt-only routers, and a binary cascade baseline; in the main GPT-5.4-nano/GPT-5.4 setting, one CRC-calibrated frontier point exceeds always-escalate solve rate while using 35% of its mean recovery cost. Code is available at https://github.com/Qijia-He/agent-budget-control.
许愿