Consistent or Sensitive? Automated Code Revision Tools Against Semantics-Preserving Perturbations
This paper evaluates the consistency of state-of-the-art automated code revision tools against semantics-preserving perturbations, revealing that their ability to generate correct revisions can drop by up to 45.3% on semantically equivalent code variants and that current mitigation strategies offer only marginal improvements.
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
The Picky Chef: Why Code-Editing AI Struggles with Small Changes
Imagine you have a very talented, super-fast robot chef. This robot's job is to read a recipe (the code) and a note from a food critic (the reviewer's comment), then instantly fix the recipe to match the critic's wishes.
For example, if the critic says, "This soup might be too salty, add a pinch of sugar to balance it," the robot chef should look at the recipe, find the salt, and add the sugar.
This paper asks a simple but crucial question: Is this robot chef consistent?
If you give the chef the exact same recipe but write it in a slightly different way—say, you swap the order of the ingredients or rename "sugar" to "sweetener" (but the taste and the result are exactly the same)—will the robot still add the sugar in the right place? Or will it get confused and mess up the soup?
The Experiment: The "Same Soup, Different Bowl" Test
The researchers took 2,000 real-world recipes (Java code from GitHub) that the robot chefs had already fixed perfectly. Then, they created over 10,000 new versions of these recipes.
They didn't change the flavor (the logic) of the recipes. They only changed the presentation (the structure). They did this in nine different ways, like:
- The "Try-Catch" Wrapper: Putting the whole recipe inside a fancy glass dome (a
try-catchblock) that doesn't change the cooking, just the container. - The "Dead End" Insert: Adding a step that says, "If the sky is green, burn the toast," but since the sky is never green, that step is never taken. It's invisible to the eater but changes the text.
- The "Name Swap": Changing "sugar" to "sweetener" everywhere.
Then, they asked five different AI Chef models (like T5, LLaMA, GPT-3.5, and DeepSeek) to fix these new versions.
The Big Discovery: The AI is "Sensitive," Not "Consistent"
The results were surprising. Even though the recipes were logically identical, the AI chefs got confused.
- The Drop: In the worst cases, the AI's ability to fix the recipe correctly dropped by 45%. That's like a chef who can make a perfect cake 100% of the time suddenly failing nearly half the time just because you wrote "flour" instead of "wheat powder."
- The "Eye of the Storm": The AI got most confused when the changes happened right next to the part the critic was talking about.
- Analogy: Imagine the critic points at the salt shaker. If you move the salt shaker two inches to the left (but it's still the salt shaker), the robot chef panics and forgets to add the sugar. It seems the AI relies on the exact position of words rather than understanding the meaning of the sentence.
Why Does This Happen?
The researchers found that these AI models are like pattern matchers, not true understanders.
- They memorize that "salt" usually appears in a specific spot.
- When you shuffle the deck or rename the ingredients, the pattern breaks, and the AI loses its way.
- It's like a student who memorized the answer key for a math test but doesn't understand algebra. If you change the numbers slightly, they can't solve it anymore.
Did They Try to Fix It? (The "Hint" Strategy)
The researchers tried to help the AI by giving it hints:
- Repeating the Code: Telling the AI, "Hey, look at this specific part of the code again!"
- Inline Comments: Writing the critic's note directly inside the recipe code.
- Thinking Aloud: Asking the AI to explain its steps before fixing the code (Chain-of-Thought).
The Result? It didn't really work. In fact, these hints often made things worse.
- Analogy: It's like trying to help a driver who is lost by shouting extra directions. Instead of helping, the extra noise just confuses them more, and they drive off the road. The AI got distracted by the extra text and forgot the main task.
What Does This Mean for Us?
- Don't Trust the AI Blindly: Just because an AI tool works great on a test doesn't mean it will work in the real world, where code is messy and changes often.
- The "Fragile" Problem: Current AI tools are "fragile." They break easily when the input looks slightly different, even if the meaning is the same.
- Future Work: We need to build AI that understands the logic of the code, not just the shape of the text. Until then, developers need to be careful and double-check the AI's work, especially when the code structure is complex.
The Bottom Line
The paper concludes that while these AI tools are impressive, they are currently too sensitive to small changes. They are like a chef who can cook a perfect meal only if the ingredients are arranged in a specific order. If you rearrange the kitchen, they might burn the dinner. We need to teach them to understand the recipe, not just the layout.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.