CodeHealth Predicts the Token Cost of Agentic Code Review: A Pre-Registered Study of 465 Agent-Authored Pull Requests
作者: Lo Gullstrand Heander, Markus Borg, Emma Söderberg, Christofer Rydenfält
分类: cs.SE, cs.AI
发布日期: 2026-10-15
备注: 32 pages, 6 figures, 16 tables
💡 一句话要点
CodeHealth预测代理代码审查的令牌成本
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码审查 多代理系统 大型语言模型 代码质量 维护成本 预注册研究 混合模型
📋 核心要点
- 现有方法未能量化低代码质量对多代理代码审查成本的影响,导致维护效率低下。
- 本研究通过分析465个代理作者的拉取请求,验证了CodeHealth与代理审查令牌成本之间的关系。
- 实验结果表明,CodeHealth每增加一个点,令牌成本降低3.5%至6.1%,且与PR规模无关。
📝 摘要(中文)
背景:组织越来越多地将代码审查委托给按令牌计费的多代理大型语言模型(LLM)管道。低代码质量增加了人类维护的工作量,但其对代理审查成本的影响尚未测量。目标:我们测试基础的CodeHealth是否能预测代理审查和修复的令牌成本。方法:在一项预注册的观察性研究中,我们从AIDev中抽取了465个代理作者的拉取请求(PR),并根据CodeHealth和PR规模进行分层。每个PR由一个冻结的五代理审查和修复管道处理,使用三种不同的LLM。结果:所有三种LLM的CodeHealth系数均为负,95%置信区间不包含零;每个CodeHealth点与3.5%至6.1%的令牌成本降低相关。结论:一个针对人类可维护性的质量指标也能预测多代理审查和修复的推理成本。
🔬 方法详解
问题定义:本研究旨在解决低代码质量对多代理代码审查成本的影响未被量化的问题。现有方法未能有效评估代码质量与审查成本之间的关系,导致维护工作量增加。
核心思路:论文提出通过分析CodeHealth指标来预测代理审查的令牌成本,重点关注代码质量对审查效率的影响。设计上,研究通过对比不同LLM的表现来验证CodeHealth的有效性。
技术框架:研究采用预注册的观察性研究设计,从AIDev中抽取465个代理作者的PR,使用五代理审查和修复管道处理每个PR,并应用三种不同的LLM进行分析。
关键创新:最重要的创新点在于首次将CodeHealth作为预测代理审查成本的指标,揭示了代码质量与审查效率之间的直接关联,超越了传统的PR规模分析。
关键设计:研究中使用了混合模型来拟合CodeHealth与令牌成本之间的关系,设置了随机截距以控制不同仓库的影响,确保结果的可靠性。
🖼️ 关键图片
📊 实验亮点
实验结果显示,所有三种LLM的CodeHealth系数均为负,且95%置信区间不包含零,表明每个CodeHealth点与3.5%至6.1%的令牌成本降低相关。这一发现强调了代码质量在多代理审查中的重要性。
🎯 应用场景
该研究的潜在应用领域包括软件开发和维护,尤其是在使用多代理系统进行代码审查的场景。通过量化代码质量对审查成本的影响,组织可以优化其代码审查流程,降低维护成本,提高开发效率。
📄 摘要(原文)
Context: Organizations increasingly delegate code review to multi-agent large language model (LLM) pipelines billed per token. Low code quality raises human maintenance effort, but its effect on agent review cost has not been measured. Objective: We test whether baseline CodeHealth predicts the token cost of agentic review and fix beyond pull request (PR) footprint. Method: In a pre-registered observational study, we sampled 465 agent-authored PRs from 246 repositories in AIDev, jointly stratified by CodeHealth and footprint under repository caps. A frozen five-agent review-and-fix pipeline processed every PR with three different LLMs. Per LLM, we fitted a mixed model of log tokens on CodeHealth and log PR footprint, with a repository random intercept. Results: For all three LLMs the CodeHealth coefficient was negative, with 95% CI excluding zero; each CodeHealth point was associated with 3.5% to 6.1% lower token cost. CodeHealth was unrelated to PR footprint, so PR size does not explain the association. Two of three registered smells predicted fix cost; batch fixing left median CodeHealth unchanged. Exploratory analyses located the association in the review stage, where agents iterated more on unhealthy code without writing more comments. Adjusting for the size of the scored files absorbed the association, which we interpret as mediation by file size. Conclusions: A quality metric calibrated against human maintainability also predicts the inference cost of multi-agent review and fix. The effect is modest per point and not carried by PR size, so the refactoring case extends to agent-reviewed code when it changes structure and file size, not only the score. Data Availability: https://doi.org/10.5281/zenodo.22127920