Agent-as-a-Router: Agentic Model Routing for Coding Tasks

📄 arXiv: 2606.22902v1 📥 PDF

作者: Pengfei Zhou, Zhiwei Tang, Yixing Ma, Jiasheng Tang, Yizeng Han, Zhenglin Wan, Fanqing Meng, Wei Wang, Bohan Zhuang, Wangbo Zhao, Yang You

分类: cs.AI

发布日期: 2026-06-22

备注: 39 pages, 21 figures, a living technical report with a living benchmark that continuously updates

🔗 代码/项目: GITHUB


💡 一句话要点

提出Agent-as-a-Router框架以优化多模型任务路由

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 多模型路由 动态优化 任务分配 大型语言模型 信息积累

📋 核心要点

  1. 现有的路由器将多模型任务路由视为静态分类问题,导致信息不足,影响性能。
  2. 提出Agent-as-a-Router框架,通过C-A-F循环动态优化路由过程,积累执行经验以弥补信息差距。
  3. 实验结果显示,ACRouter在分布内任务上实现了最低的累积遗憾,相较于现有方法有显著提升。

📝 摘要(中文)

现实世界用户通常可以访问来自不同提供商的多个大型语言模型(LLMs),这些模型在不同领域表现出色,但没有一个模型能够在所有领域中占据主导地位。因此,将每个任务路由到最合适的模型对于性能和成本至关重要。现有的路由器将此视为静态的一次性分类问题。然而,我们发现这些路由器的性能瓶颈在于信息不足:仅通过在任务维度层面增强普通LLM路由器的性能统计数据,就能实现15.3%的相对提升,超越基于相同维度先验的启发式路由器。基于这一发现,我们提出了Agent-as-a-Router框架,将路由形式化为C-A-F循环(上下文->行动->反馈->上下文),通过在部署过程中积累执行基础经验来弥补信息差距。我们将该框架实例化为ACRouter,包含一个协调器、一个验证器和一个内存模块,并引入CodeRouterBench,一个包含约1万任务实例的评估环境,能够实现基于遗憾的流任务路由器比较。实验表明,ACRouter在分布内任务上实现了最低的累积遗憾,并能推广到分布外的代理编程任务,证明了我们的路由框架能够主动弥补信息差距。

🔬 方法详解

问题定义:本论文旨在解决如何有效路由任务到最适合的语言模型的问题。现有方法在处理多模型任务时存在信息不足的痛点,导致性能不佳。

核心思路:论文提出的核心思路是将路由过程视为一个动态的C-A-F循环,通过上下文、行动、反馈的循环机制,持续积累和更新信息,从而优化任务路由。

技术框架:整体架构包括一个协调器、一个验证器和一个内存模块。协调器负责任务的初步路由,验证器用于评估路由的有效性,内存模块则存储执行经验以供后续参考。

关键创新:最重要的技术创新点在于将路由过程动态化,利用实时反馈不断优化路由决策,这与现有静态路由方法形成了本质区别。

关键设计:在设计中,采用了基于遗憾的评估机制,设置了多种任务维度的性能统计,确保路由器能够在不同任务场景下灵活应对。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,ACRouter在分布内任务上实现了最低的累积遗憾,相较于基线方法有15.3%的提升。此外,ACRouter在分布外的代理编程任务中也表现出良好的泛化能力,验证了其有效性。

🎯 应用场景

该研究的潜在应用领域包括智能助手、编程辅助工具和多模型系统的任务分配等。通过优化任务路由,可以显著提高系统的响应速度和准确性,降低成本,具有重要的实际价值和广泛的未来影响。

📄 摘要(原文)

Real-world users typically have access to multiple Large Language Models (LLMs) from different providers, and these LLMs often excel at distinct domains, yet none dominate all. Consequently, routing each task to the most suitable model becomes critical for both performance and cost. Existing routers treat this as a static, one-off classification problem. However, we identify the performance bottleneck for these routers as information deficit: simply augmenting a vanilla LLM router with performance statistics at the task-dimension level yields a 15.3% relative gain, surpassing a heuristic router built on the same dimension-level priors. Motivated by this finding, we propose Agent-as-a-Router, a framework that formalizes routing as a C-A-F loop (Context->Action->Feedback->Context). It closes the information gap by accumulating execution-grounded experience during deployment. We instantiate this framework as ACRouter, composed of an Orchestrator, a Verifier, a Memory module, and introduce CodeRouterBench, an evaluation environment comprising ~10K task instances with verified scores from 8 frontier LLMs, enabling regret-based router comparison on streaming tasks. Experiments show that ACRouter achieves the lowest cumulative regret on in-distribution tasks and generalizes to out-of-distribution agentic-programming tasks, demonstrating that our routing framework actively closes the information gap. Codes and benchmarks are released at https://github.com/LanceZPF/agent-as-a-router.