← Latest papers
💻 computer science

Using Mutation-Analysis to Examine an LLM's Ability to Summarize Code

This paper introduces a mutation-based evaluation methodology to assess LLMs' ability to generate code summaries that accurately reflect actual program behavior rather than just intent, revealing that while performance improves with model size, accuracy significantly declines with code complexity and models often fail to detect subtle logic changes.

Original authors: Lara Khatib, Michael Pu, Bogdan Vasilescu, Meiyappan Nagappan

Published 2026-06-29
📖 5 min read🧠 Deep dive

Original authors: Lara Khatib, Michael Pu, Bogdan Vasilescu, Meiyappan Nagappan

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 smart, confident robot assistant whose job is to read computer code and write a simple summary of what that code does. You might ask it, "What does this program do?" and it replies, "It sorts a list of numbers from smallest to largest."

This sounds helpful, right? But what if the code actually has a tiny mistake and sorts the numbers from largest to smallest? If the robot assistant ignores that tiny mistake and just writes the summary it expects to see based on its training, it's lying to you. It's describing what the code should do, not what it actually does.

This paper is about building a "lie detector" for these AI assistants to see if they are actually reading the code or just guessing based on patterns.

The "Mutation" Test: A Recipe Analogy

To test the AI, the researchers used a technique called Mutation Analysis. Think of it like a cooking test:

  1. The Original Dish: You have a perfect recipe for a cake (the original code).
  2. The Mutation: You secretly change one tiny ingredient. Maybe you swap "1 cup of sugar" for "1 cup of salt," or you forget to turn on the oven. This is the "mutation."
  3. The Taste Test: You ask the AI to describe the dish.
    • If the AI is paying attention: It should say, "This cake tastes salty because you used salt instead of sugar," or "This cake is raw because the oven was off."
    • If the AI is just guessing: It will ignore your change and say, "This is a delicious vanilla cake," because that's what a cake usually tastes like.

The researchers did this with computer code. They took 624 different pieces of code, made tiny, specific changes to them (like changing a number, flipping a "yes/no" switch, or removing a line), and asked the AI to summarize the new version.

What They Found

The researchers tested this on two different generations of AI models (GPT-4 and a newer GPT-5.2) using two types of code: simple, made-up code and real code written by humans.

1. The "Big Picture" Problem (Complexity)
The AI gets much worse at spotting changes when the code gets complicated.

  • Simple Code: If the code is just one small function (like a single recipe), the AI is pretty good at noticing changes (about 76% accurate).
  • Complex Code: If the code is a massive system with many parts working together (like a whole restaurant kitchen with multiple chefs), the AI's accuracy crashes. For complex, multi-threaded systems, it only got the changes right about 17% of the time. It's like the AI gets overwhelmed by the noise and just guesses the "standard" outcome.

2. The "Pattern" Trap
The AI often fails because it relies on what it thinks should happen rather than what is happening.

  • The "Intent" vs. "Reality" Trap: If the code is a famous algorithm (like a "Merge Sort"), the AI knows the standard steps. If you change a tiny step in the code, the AI often ignores it and describes the standard steps anyway. It's like a tour guide who knows the script so well that if you take a wrong turn, they keep describing the path they thought you were on.
  • The "Word" Trap: Sometimes, the code has a text label that says "Wallet," but the code actually prints "Cart." The AI sees the word "Wallet" and describes the wallet, ignoring the fact that the code is doing something else.

3. The Newer Model is Better (But Not Perfect)
The researchers compared the older model (GPT-4) with a newer one (GPT-5.2).

  • The Leap: The newer model got much better, catching about 85% of the changes compared to the older model's 49%.
  • The Catch: Even the newer model still misses about 1 out of every 7 changes. It also started acting more like a critic; when it did spot a change, it often correctly identified it as a "bug" or a mistake. However, it still sometimes described the "intended" behavior rather than the "actual" broken behavior.

Why This Matters

The paper argues that we can't just trust an AI's summary because it sounds confident. If a developer relies on a summary that misses a tiny logic error, they might build a feature on top of a broken foundation.

The researchers' main contribution is this "Mutation Test." Instead of just asking "Does this summary sound good?" (which is hard to measure), they ask: "If we break the code slightly, does the summary change to match the break?"

If the summary stays the same while the code changes, the AI isn't really understanding the code; it's just reciting a script. This test gives developers a way to stress-test their AI tools to see if they are actually reliable or just confident guessers.

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 →