arXiv:2606.22902cs.AI2026-06被引 5

让智能体自动选最合适的模型写代码,边用边学更准更省。

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

论文配图:Agent-as-a-Router: Agentic Model Routing for Coding Tasks
图 1 · 摘自论文原文
  • 用上下文-动作-反馈循环动态选模型,边执行边积累经验。
  • 在1万+任务上测试,比传统方法少15.3%错误率,效果显著提升。
  • 适合需要多模型协作的编程场景,尤其适合部署后持续优化的系统。

现实用户通常能访问多个来自不同提供商的大语言模型(LLMs),这些模型在不同领域表现优异,但没有一个能全面领先。因此,将每个任务路由到最适合的模型对性能和成本都至关重要。现有路由器将此视为静态、一次性分类问题。我们发现其性能瓶颈在于信息不足:仅通过任务维度的性能统计数据增强基础模型,即可带来15.3%的相对性能提升,超过基于相同维度先验构建的启发式路由器。受此启发,我们提出Agent-as-a-Router框架,将路由建模为C-A-F循环(上下文→动作→反馈→上下文),通过部署期间积累执行经验来填补信息缺口。我们实现了ACRouter,包含编排器、验证器、记忆模块,并构建了CodeRouterBench评估环境,包含约10,000个任务实例及8个前沿大模型的经验证评分,支持在流式任务上进行基于遗憾度的路由器对比。实验表明,ACRouter在分布内任务上达到最低累积遗憾,并可泛化至分布外的智能体编程任务,证明该路由框架能主动缩小信息差距。代码与基准数据已开源。

原文摘要 · Abstract (English)

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.

模型路由智能体代码生成动态决策

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。