Is Agent Code Less Maintainable Than Human Code?

Shaswat P Patel, Betty Li Hou, Arun Purohit, Kai Xu, Jane Pan, He He, Valerie Chen

TL;DR

While AI coding agents are increasingly capable of solving isolated bugs, this paper reveals that their code is significantly harder to maintain than human-written code. Using a new framework called CodeThread, researchers found that agents are up to 13.1% less effective at completing tasks when building on top of previous agent-generated code compared to building on human code.

What Problem Does This Paper Address?

Most current AI evaluations focus on "one-and-done" tasks: can the agent fix this specific bug or implement this single feature? However, software engineering is an iterative process where code is written, reviewed, and modified over years.

The authors identify a looming concern: compounding technical debt. If an agent produces a patch that passes functional tests but introduces subtle structural brittleness or confusing logic, it might make the next task—whether performed by a human or another AI—much harder. This paper seeks to quantify this "maintainability gap" and identify exactly what makes agent code more difficult to work with.

Methods

The authors introduce CodeThread, a framework designed to transform standard, single-issue benchmarks into two-step "pull-request chains."

  1. Skeletonization: They take an existing code solution and "hollow out" the target functions, leaving only the signatures.
  2. Step 1 (Implementation Task): An agent (or a human baseline) is asked to re-implement the missing logic based on docstrings. This creates two versions of the codebase: one with an agent-authored patch and one with a human-authored patch.
  3. Step 2 (Follow-On Issue): A second, dependent task (the original benchmark issue) is then given to an agent to solve on top of both versions.

By holding the "Follow-On" author (the agent) and the evaluation tests constant, the researchers can isolate how the authorship of the initial code (Agent vs. Human) affects downstream success. They then used logistic regression to analyze which features—ranging from static complexity metrics to subtle behavioral shifts—predicted failure.

Datasets

The study utilized a total of 1,377 instances across four diverse software engineering benchmarks:

  • SWE-Bench Verified: High-quality bug fixes.
  • SWE-Bench Multilingual: Bug fixes across multiple programming languages.
  • SWE-Bench Pro: Complex, multi-file edits from professional repositories.
  • FeatBench: A benchmark focused on feature implementation rather than just bug fixing.

Key Insights and Ideas

  • The Failure of Traditional Metrics: Surprisingly, standard maintainability metrics like Cyclomatic Complexity (path counts) and Halstead Volume (verbosity) failed to explain the performance gap. Agent code often looks "clean" by these traditional standards but remains harder to maintain.
  • "Input/Error Contract" (IEC) Drift: The most significant predictor of failure was subtle behavioral changes. Agents often silently alter how a function handles edge cases—for example, returning None instead of raising a specific error, or adding an extra input check that wasn't there before. This "drift" creates a mismatch with the expectations of downstream code.
  • Compounding Difficulty: The maintainability penalty is most severe in refactoring and feature implementation tasks. These require a deeper understanding of existing abstractions, which agent-generated code often muddies.
  • Localization Issues: When building on agent code, the second agent often struggled with "localization"—identifying exactly which files and functions needed to change—suggesting that agent code makes the codebase's intent harder to navigate.

Key Results

  • The Performance Gap: Across almost all models and benchmarks, agents performed worse when building on agent code (the "AA" condition) than on human code ("HA"). The drop in "resolve rate" reached as high as 13.1% (for the GLM 4.7 model on SWE-Bench Pro).
  • Predictive Power of IEC: If an agent's initial code altered the input/error handling behavior (IEC drift), the odds of the downstream task failing increased by 1.83x.
  • Code Size Matters: When the agent's second-step patch was significantly larger than the human-baseline patch (measured by Logical Lines of Code), it was a strong signal that the agent was struggling to integrate with the existing (agent-authored) code.

Limitations and Future Work

  • Short Horizons: The study only looked at two-step chains. In real-world software, code might go through dozens of iterations. The authors suspect that maintainability costs likely compound even further over longer horizons.
  • The Human Element: The study focused on how agents build on agent code. It did not measure how much harder it is for human developers to maintain agent-generated code, which would require expensive, large-scale human studies.
  • Selection Bias: To ensure the two-step task was valid, the authors had to filter out cases where the agent accidentally solved the second task while doing the first. This might exclude some of the most "clever" or efficient agent behaviors.

The authors conclude that as AI agents become standard teammates in software development, we must move beyond measuring "immediate success" and start evaluating the long-term health of the codebases they help create.

Summary updated

BibTeX
@inproceedings{patel2026is,
  author = {Shaswat P Patel and Betty Li Hou and Arun Purohit and Kai Xu and Jane Pan and He He and Valerie Chen},
  title = {{Is Agent Code Less Maintainable Than Human Code?}},
  booktitle = {SCALE @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=muNtkMS4qQ},
}
Figure