← Latest papers
💻 computer science

Do AI Agents Really Improve Code Readability?

This study reveals that while AI agents primarily target logic complexity and documentation when refactoring code for readability, their actions frequently degrade traditional quality metrics such as the Maintainability Index and Cyclomatic Complexity, challenging the assumption that AI-driven refactoring inherently improves code readability.

Original authors: Kyogo Horikawa, Kosei Horikawa, Yutaro Kashiwa, Hidetake Uwano, Hajimu Iida

Published 2026-03-17
📖 5 min read🧠 Deep dive

Original authors: Kyogo Horikawa, Kosei Horikawa, Yutaro Kashiwa, Hidetake Uwano, Hajimu Iida

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a very talented, hyper-fast assistant named "AI Agent." You ask this assistant to tidy up your messy workshop (your computer code) so it's easier for you and your friends to find tools and understand how things work. You expect the workshop to look cleaner, brighter, and more organized.

But what if, after the assistant finishes, the workshop is actually more cluttered, even though the assistant claims it's "cleaner"?

That is exactly what this research paper discovered. The authors, a team of researchers from Japan, investigated whether AI agents are actually making code easier to read, or if they are just making it look different.

Here is the story of their findings, broken down into simple concepts:

1. The Setup: The "Tidy Up" Request

Code readability is like the legibility of a handwritten note. If the handwriting is messy, the note is useless. If the code is messy, it's hard to fix bugs or add new features.

Recently, developers started using AI Agents. Unlike a simple chatbot that gives you one answer, an AI Agent is like a project manager. It can plan a task, break it into steps, do the work, and check its own homework.

The researchers wanted to know: When these AI Agents try to "clean up" code, do they actually make it easier to read?

2. The Investigation: Looking for the "Tidy" Signs

The researchers went through a massive database of over 1.3 million code changes made by AI agents. They looked for "receipts"—specifically, commit messages (the notes developers write when saving changes) that said things like "improving readability," "making it clearer," or "easier to understand."

The First Surprise (RQ1): The Agents Don't Care Much About Reading
They found that out of every 1,000 changes the AI made, only 3 were explicitly trying to make the code easier to read.

  • Analogy: Imagine a chef who is hired to cook a meal. You'd expect them to focus on the food. But this chef is mostly focused on sharpening knives, washing dishes, and rearranging the spice rack. Only 0.3% of their time is actually spent on making the food taste better. The AI agents are mostly busy with other things, not readability.

3. The "What" They Changed: Deep Fixes vs. Surface Polish

When the AI agents did try to improve readability, what did they actually do? The researchers compared the AI's work to how human developers usually clean up code.

  • Humans usually fix the "surface stuff": renaming variables (like changing x to customer_name), fixing indentation, or adding comments. It's like organizing the tools on the wall so they are easy to grab.
  • AI Agents focused on the "deep stuff": simplifying complex logic and fixing documentation.
    • Analogy: If the code was a tangled ball of yarn, humans would untie the knots one by one. The AI Agent, however, decided to cut the whole ball in half and rewrite the instructions on how to use it. They focused on the logic (how the machine thinks) rather than the style (how it looks).

4. The Big Twist: The "Cleaner" Code Was Actually Messier

This is the most shocking part of the study. The researchers measured the code before and after the AI touched it using standard "health metrics" (like a doctor checking blood pressure).

They expected the code to get better. Instead, they found:

  • 56% of the time, the code became harder to maintain (the "Maintainability Index" dropped).
  • 42% of the time, the code became more complex (the "Cyclomatic Complexity" went up).
  • The code actually got longer.

The Analogy:
Imagine you ask a contractor to fix a leaky faucet.

  • You expect: They tighten the valve, and the leak stops.
  • What happened: The contractor replaced the faucet with a high-tech, custom-built machine that has 50 extra pipes, a digital display, and a warning light. It works, and the leak is gone, but now the whole thing is huge, expensive to fix, and confusing to understand.

The AI agents were so focused on making the logic "smart" or adding explanations that they accidentally made the code bloated and complicated. They traded a simple, clean solution for a complex, over-engineered one.

5. The Conclusion: Don't Trust the Agent Blindly

The paper concludes that while AI agents are powerful, they currently lack the "common sense" to know when a code change is actually helpful for a human reader.

  • They are good at: Fixing broken logic and writing long explanations.
  • They are bad at: Knowing when to stop. They tend to over-engineer, making code longer and more complex in the name of "readability."

The Takeaway for Developers:
Don't just let the AI agent hit "Apply" on all its suggestions. You need to be the Quality Control Inspector. You have to look at the changes and ask: "Did this actually make it simpler, or did the AI just build a bigger, more confusing machine?"

In short: AI agents are great at thinking, but they are currently terrible at knowing when to keep things simple.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →