Free Intensive Nov 21–22Free 2-day hands-on Vibecoding Intensive on Nov 21–22 at 16:00 MSK (Sat–Sun) · Live Cohort 3 starts Nov 23Join Free →Cohort 3 (Nov 23)
ReleaseInsight · On RadarHabr AI→ original

Why AI agents still produce bad software: they get pointed at features, not refactoring

An agent sends back green pull requests, yet the code still ends up full of junk, such as inconsistent naming. Nikita, a Rust developer, wrote a Habr post explaining why: AI can hunt bugs and refactor, but in practice it's mostly sent to build the next feature. The business wants functionality by Friday, while the payoff from cleaning up code only shows up later. So when working with agents, teams need to plan verification and refactoring explicitly.

AI-processed from Habr AI; edited by Hamidun News
Why AI agents still produce bad software: they get pointed at features, not refactoring
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Metaengineers accepted 73% of tests written by TestGen-LLM into production
Key metric #2In the 2026 Stack Overflow survey, 64% use AI for debugging and refactoring
Agents copy mistakes from old codeasking for "the way we do it here" amplifies the effect

During a livestream, a speaker complained that an agent sends back green pull requests, every check passes, and yet the code is still full of junk. For example, classes are named inconsistently. Nikita, a Rust developer and author of a Habr write-up, heard this and was surprised: he doesn't have these problems with agents. He asks AI to hunt for bugs, review questionable decisions, improve tests, and refactor, and it works reasonably well. So why are people's experiences so different? His answer: the tool is almost beside the point. What matters is the kind of work it's assigned.

What AI does well when asked

An agent does have the capacity to improve quality. It can help catch a bug that reproduces once a month. It can point out which scenarios are missing from the tests. It can split a function that has accumulated mixed logic, and it can mass-edit repetitive code across dozens of files.

There are numbers, too. Meta built TestGen-LLM, which extends tests that already exist. The new tests were compiled and run, then checked for whether coverage improved. Suggestions that passed automatic filtering were reviewed by engineers. According to the authors, 73% of these recommendations went into production. In the 2026 Stack Overflow survey, about 58% of respondents used AI for testing, 64% for debugging and refactoring, and about 69% for generating code in a familiar area.

Why in practice it mostly produces new features

The scenario will be familiar to everyone. The agent wrote the code, you checked the normal path, and it works. You could have checked what happens on a repeated request or when a neighboring service doesn't respond, and also assessed how readable the code is. But the button can already be shown to the client. If after each such success you immediately take the next task, the agent will mostly deliver the next features.

The economics of development make it worse. The client expects the new feature on Friday. The benefit of refactoring an old module has to be explained, and it's hard to estimate: the future tasks that would benefit aren't on the plan yet. Research on technical debt revealed a gap. Managers believed they supported this kind of work more often than developers felt they did. Small fixes were rewarded, while large rework was postponed because there was no clear explanation of the benefit. That research came out before agents became widespread. Refactoring with AI is easier now, but if a feature sits on the plan for Friday, the agent will be busy with the feature.

Nikita compares AI to a supercar: a pro will get there faster, while a novice will crash on the first corner. The novice, however, will reach the corner sooner than expected. The novice can also be a manager who takes the agent's first working version as a finished product.

The agent repeats what it sees in the project

The second source of problems is old code. If one solution has been copied into several places, a request like "look at how we do it and add more" will make the agent reproduce the mistake from the example too. In an experiment on broken windows, 29 developers extended systems with different amounts of legacy problems. In the more neglected code, participants were more likely to add new problems: they duplicated functionality and chose unclear names.

A November 2026 preprint tested the same for vulnerabilities. Agents were shown secure and vulnerable variants of existing code. In the second case, similar vulnerabilities more often appeared in new changes as well. Asking the agent to follow the existing style amplified the effect. The same agent could have found the bug and fixed it in every copy, but nobody asked it to do that.

Why quality gets little coverage and what to do

The author notes one more imbalance. "I rewrote a million lines in 10 days" gets read out of curiosity, while "AI helped refactor the codebase" doesn't catch attention. People who quietly clean up old bugs with an agent publish nothing. From loud stories it's easy to conclude that everyone is just generating yet another service.

The practical conclusions are these:

  • Give the agent separate verification tasks: repeated requests, a neighboring service failing, empty lists. Don't expect it to do this by default.
  • Put refactoring into the plan as a regular task with a clear benefit, for example: "after this, features in the module take a day to add instead of a week."
  • Don't ask the agent to copy code "the way we do it" until you've confirmed the example is good. First ask it to find duplicates and bugs in the example.
  • For managers: a green pull request from an agent shows that the code works, not that it is good.

An honest caveat: this is an opinion column. It backs one developer's experience with separate studies, but it doesn't prove that code quality suffers for one single reason across all teams. Nikita's closing thought is modest: we use AI's capabilities for quality more weakly than its capabilities for speed. In this "investigation" the culprit turns out to be the developer, and that's good news. Changing the process is easier than waiting for a new model.

Story

Key Questions Answered

What AI does well when asked?

An agent does have the capacity to improve quality. It can help catch a bug that reproduces once a month. It can point out which scenarios are missing from the tests. It can split a function that has accumulated mixed logic, and it can mass-edit repetitive code across dozens of files. There are numbers, too. Meta built TestGen-LLM, which extends tests that already exist. The new tests were compiled and run, then checked for whether coverage improved.

Why in practice it mostly produces new features?

The scenario will be familiar to everyone. The agent wrote the code, you checked the normal path, and it works. You could have checked what happens on a repeated request or when a neighboring service doesn't respond, and also assessed how readable the code is. But the button can already be shown to the client. If after each such success you immediately take the next task, the agent will mostly deliver the next features. The economics of development make it worse. The client expects the new feature on Friday.

What are the key details on The agent repeats what it sees in the project?

The second source of problems is old code. If one solution has been copied into several places, a request like "look at how we do it and add more" will make the agent reproduce the mistake from the example too. In an experiment on broken windows, 29 developers extended systems with different amounts of legacy problems. In the more neglected code, participants were more likely to add new problems: they duplicated functionality and chose unclear names. A November 2026 preprint tested the same for vulnerabilities.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…