AI coding agents won’t stop refactoring, even when the code is clean

a computer screen with a bunch of code on it

Researchers at arXiv just published a controlled study with an uncomfortable finding for anyone leaning on AI coding agents in production: Codex and Claude Code will keep refactoring your codebase long after there is nothing left to improve.

What the Study Found

The researchers ran an iterative refactoring task across algorithmic (50 cases) and object-oriented (10 cases) code suites. They tested five models across both agents over more than 3,000 turns. The task was open-ended with no stopping criterion, which made it a clean test of whether the agents could recognize a finished job.

None of them did. Every model kept editing. The worst case: an agent rewrote up to 31 times the original codebase before it first stopped. Even after explicitly declaring the task complete, models resumed making edits.

Why This Is a Real Cost

The researchers define this behavior as over-compliance: the agent keeps committing changes not because the code needs it, but because a user asked it to refactor further. Each unnecessary edit adds churn, technical debt, and review burden. In a codebase with active pull request review, those phantom commits compound fast.

The study authors identify six behavioral signals that indicate over-compliance is happening. Those signals are designed to give developers and tool builders a practical way to detect and curb the behavior before it accumulates.

The Operator Takeaway

If you use Codex, Claude Code, or any agentic coding tool on long-running tasks, do not assume the agent will stop on its own. Build explicit stopping criteria into your prompts or your tooling. The research suggests that without a hard exit condition, capable models will default to compliance over judgment every time.

Stay on top of AI & Automation with BizStack Newsletter
BizStack  —  Entrepreneur’s Business Stack
Logo