arXiv:2610.21914cs.SEOct 2026

Manuscript Offprint

arXiv:2610.21914

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

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

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: DOI:10.5281/zenodo.22127920

Keywords agentic code review, multi-agent systems, CodeHealth, code quality, large language model cost estimation

1 Introduction

Technical debt research has linked low code quality to higher maintenance costs for over 30 years. Cunningham (1992) coined the term when he described shipping not-quite-right code as going into technical debt on which interest is paid in every subsequent change, and over time this metaphor has turned into a research field with its own systematic maps and syntheses (Li et al. 2015; Ampatzoglou et al. 2015). Researchers have also quantified the cost; for example, Besker et al. (2019), replicating and extending an earlier study of developers' own working time, found that developers waste on average 23% of their time on technical debt. Across this literature, the unit of cost is human: attention, working time, and the effort of rebuilding an understanding that the code itself fails to convey.

That unit of cost is changing as organizations route code review through multi-agent large language model (LLM) pipelines to absorb rising pull request (PR) volumes. He et al. (2026) report that in one enterprise where AI tool adoption roughly doubled per-engineer PR throughput, automated review overtook human code review, while the load on each remaining human reviewer roughly doubled. When the reviewer is an agent, its cost stops being time, attention, and effort and instead becomes metered token cost, which has not yet been related to the quality of the code under review. Storey (2026) argues that generative AI does not remove debt so much as redistribute it, separating technical debt in the code from cognitive debt in a team's shared understanding and intent debt in its externalized rationale. She observes that agents working against poor context may "use more tokens and time than expected". The observation is plausible and, to our knowledge, untested. If it is right, the long-standing case for refactoring extends into workflows with no human reviewer in them; if it is wrong, teams that budget refactoring and maintenance on the strength of human-effort evidence have to justify that spend on other grounds for automated pipelines.

CodeHealth TM^{TM} (CH) is a composite, deterministic score between 1 and 10 that aggregates several source-level quality signals into a single file-level measure. Beyond its links to human maintenance effort, it has been shown to predict how AI tooling behaves on the code: Borg et al. (2026a) report significantly lower break rates when AI refactors healthy code. This study asks whether the same metric predicts the token cost of multi-agent review and fix of a PR. The question cannot be asked without separating quality from size. Token consumption scales mechanically with the size of a diff, which presents more input tokens, more lines to read, and more edits to make, so if unhealthy code tends to arrive in larger PRs, an apparent relationship between CH and token cost may simply reflect PR footprint.

To study this relationship, we conducted a pre-registered observational study investigating whether baseline CodeHealth predicts agentic review and fix costs beyond what PR footprint explains. We treat PR footprint as a mediator candidate, not a covariate, and we designed the study under equipoise so that either outcome is informative. If baseline CH predicts the cost of agentic review and fix after controlling for footprint, the case for refactoring extends to agentic review workflows. If the effect of CH on token cost is instead fully mediated by PR size, the economic argument shifts toward keeping PRs small, possibly at some expense of code quality.

We investigate four pre-registered 1^{1} research questions:

RQ 1_{1} Does baseline CodeHealth predict the token cost of agentic review and fix, controlling for PR footprint, language, and repository?

RQ 2_{2} Is any such relationship direct, or is it mediated by the size of the PR that unhealthy code attracts?

RQ 3_{3} Do specific code smells, rather than the aggregate CodeHealth score, predict the cost of the fix stage in particular?

RQ 4_{4} What happens to CodeHealth itself when a batch fix agent applies a full set of review comments in a single pass?

The registered analysis supports the direct-CodeHealth-effect branch of this equipoise. Fitted separately for each of the three LLMs on the achieved 465-PR sample, the coefficient on baseline CH is negative, with a 95% confidence interval excluding zero, for all three LLMs. This satisfies RQ1's pre-registered conjunctive criterion. One additional CH point is associated with an estimated 3.5% to 6.1% reduction in total review-and-fix tokens, holding footprint, language, and repository constant (Fig. 1a). Footprint itself is essentially unrelated to baseline CodeHealth in this sample (at most +0.014 in log footprint per CH point, with every interval spanning zero), so the effect is direct with respect to PR footprint and not an artifact of unhealthy code attracting larger PRs (Fig. 1b). A quality metric calibrated against human maintainability therefore also shows an association with metered agent inference cost. Even if this is not established as a causal relationship, the result suggests that the code properties the metric penalizes also raise what an agent spends. In an exploratory analysis, the association concentrates in the review stage: agents reviewing unhealthy code take more turns and consume more context without raising more comments. A second exploratory refit shows that the association cannot be separated from the size of the files the agents read, which we interpret as file size, unlike PR footprint, mediating the effect (Section 5.2). Keeping PRs small therefore does not substitute for code quality, and the case for refactoring extends to agent-reviewed code in the form that changes the structure and size of the files an agent reads through, not only the score (Section 5.5).

In addressing these questions, we make four contributions:

  1. A pre-registered, multi-LLM mixed-effects observational study across three independently served LLMs, evaluated with a conjunctive direction-consistency criterion.

  2. A frozen, reproducible review-and-fix harness of four review agents and one fix agent grounded in the ISO/IEC 25010 product quality model (ISO/IEC 2023), with all agent prompts hashed and registered, and unchanged across the whole collection.

  3. A jointly stratified CodeHealth-by-footprint, repository-capped sample of 465 agent-

1^{1}OSF DOI: 10.17605/OSF.IO/FBJCT

Figure

(a) RQ1RQ_{1}: Predicted change in tokens_total from the median unhealthy-tier PR (CH 2.8) to the median healthy-tier PR (CH 9.7). The legend gives the total change across the 6.9-point contrast with its 95% confidence interval. Dashed verticals mark the tier boundaries at CH 4 and CH 9.

Figure

(b) RQ2RQ_{2}: Each LLM’s registered CH-to-footprint correlation as percent change in changed lines per CH point with its 95% confidence interval.

Figure 1: The registered answers to RQ1RQ_{1} and RQ2RQ_{2}, fitted separately per LLM. Takeaway: Token cost falls with CH for all three LLMs, and CH does not predict footprint, so larger PR footprints do not account for the extra cost of unhealthy code.

authored PRs drawn from 246 distinct repositories in the AIDev dataset (Li et al. 2026), accompanied by an audit of its achieved balance.

  1. A documented account of two sampling failure modes specific to AIDev and one pooling artifact in multi-LLM PR studies, together with the decomposition checklist that detected them (Section 3.3 and Section 6.4).

References (56)