arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.21914cs.SEcs.AI
收藏

CodeHealth 预测智能体代码审查的 Token 成本:一项针对 465 个智能体生成的 Pull Request 的预注册研究

CodeHealth Predicts the Token Cost of Agentic Code Review: A Pre-Registered Study of 465 Agent-Authored Pull Requests

Lund University(隆德大学);CodeScene AB(CodeScene公司)

Lo Gullstrand Heander, Markus Borg, Emma Söderberg, Christofer Rydenfält

AI总结:

本研究通过预注册观察性研究,发现质量指标 CodeHealth 可预测多智能体代码审查与修复的 Token 成本,该关联与 PR 大小无关,中介效应为文件大小。

摘要:

背景:组织越来越多地将代码审查委托给按 Token 计费的多智能体大语言模型(LLM)流水线。低代码质量会增加人工维护工作量,但其对智能体审查成本的影响尚未被测量。目标:我们测试基线 CodeHealth 是否能预测超出 Pull Request(PR) footprint 的智能体审查与修复的 Token 成本。方法:在一项预注册观察性研究中,我们从 AIDev 的 246 个代码库中抽样了 465 个智能体生成的 PR,在代码库上限下按 CodeHealth 和 footprint 联合分层。一个冻结的五智能体审查与修复流水线使用三种不同的 LLM 处理每个 PR。针对每种 LLM,我们拟合了一个混合模型,以对数 Token 数为因变量,CodeHealth 和对数 PR footprint 为自变量,并加入代码库随机截距。结果:对于所有三种 LLM,CodeHealth 系数均为负,95% 置信区间不包含零;每个 CodeHealth 点与 3.5% 至 6.1% 的 Token 成本降低相关。CodeHealth 与 PR footprint 无关,因此 PR 大小无法解释该关联。三种注册的代码异味中,有两种可预测修复成本;批量修复使中位 CodeHealth 保持不变。探索性分析发现该关联存在于审查阶段,智能体在该阶段对不健康代码进行了更多迭代,且未编写更多注释。调整评分文件的大小后,该关联被吸收,我们将其解释为文件大小的中介效应。结论:针对人工可维护性校准的质量指标也可预测多智能体审查与修复的推理成本。每个点的影响较小,且不由 PR 大小决定,因此重构案例适用于智能体审查的代码,当代码改变结构和文件大小(而非仅分数)时。数据可用性:this https URL

英文摘要:

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

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑