The problem is not always insufficient quality

When I use AI coding agents for implementation, testing, code review, and bug fixes, I encounter a problem that is different from poor code quality: agents sometimes continue improving code after the original requirements have been satisfied.

A small bug fix can become a broad refactoring. A simple feature can acquire abstractions for hypothetical future requirements. Review and correction cycles can continue long after the blocking issues have been resolved.

AI makes improvements easier to initiate, but that does not make every improvement worth doing.

We need to teach agents not only how to improve software, but also when to stop.

The cost of unnecessary quality work

Writing code is only one part of software development.

Every additional change can introduce costs:

  • Model usage and token consumption
  • Code exploration and review
  • CPU time, memory, and disk I/O
  • Regression testing
  • Merge conflicts between parallel agents
  • Human supervision and integration decisions

In an earlier article, I described the additional model usage associated with difficult-to-maintain software as token debt.

Unnecessary improvement work can also consume model usage without delivering enough value in return. This is particularly noticeable when several agents share a development environment and compete for expensive test resources.

High quality is not the problem. The problem is spending resources on additional improvements whose expected benefits do not justify their costs.

This distinction matters: mandatory safety, correctness, and security requirements are not optional just because they are expensive to verify.

Define the scope before implementation

An agent should know what it is expected to change and what it should leave alone.

For example:

## Scope  - Fix the reported display defect. - Preserve existing behavior outside the issue. - Add regression coverage for the defect. ## Out of scope  - Repository-wide refactoring - Unrelated naming changes - Speculative abstractions - New dependencies without a demonstrated need 

I prefer to keep independent changes in separate issues and branches.

If an agent discovers an unrelated improvement, it can report the finding for later evaluation instead of silently expanding the current task.

A newly discovered security vulnerability or other serious risk still needs to be evaluated before integration. Scope control must not become an excuse to ignore blocking problems.

A Definition of Done is a stopping criterion

Telling an agent to keep improving the code is not enough. It also needs an explicit definition of completion.

## Definition of Done  - Acceptance criteria are satisfied. - Required tests have passed. - Independent review is complete. - No unresolved merge blockers remain. - Required documentation is updated. - Validation evidence matches the final candidate. Stop when all required conditions are satisfied. 

Once these conditions are met, additional work should require a clear justification.

The objective is not to eliminate every conceivable imperfection. It is to satisfy the agreed requirements and quality gates.

Review findings are not all equal

AI-generated reviews can produce new findings on each iteration.

A policy that requires every review to return zero findings can lead to repeated changes, especially when reviewers disagree about style or architectural preferences.

One approach is to classify findings by severity:

Severity Example Typical action
CRITICAL Data corruption or severe security risk Must resolve
MAJOR Significant functional defect Must resolve
MEDIUM Meaningful quality or reliability issue Normally resolve
MINOR Limited-impact improvement Evaluate
INFO Suggestion or observation Optional

I also distinguish severity from whether a finding blocks integration. Even a seemingly small issue can be a merge blocker if it violates an explicit acceptance criterion.

Severity must be justified by evidence, not downgraded simply to make a change mergeable.

For review loops, a practical policy is to re-review the corrected areas and their affected dependencies, expand the scope when necessary, and stop once required review conditions are satisfied.

An iteration limit is also useful. However, reaching that limit does not mean the code is approved. If blockers remain, the correct outcome is to report them and stop without integration.

Use staged tests instead of testing everything after every edit

AI agents frequently repeat an implementation, test, correction, and review cycle.

Running a full regression suite after each small edit can consume considerable resources.

I prefer to distinguish the following verification categories:

Category Purpose
Static Static checks and structural validation
Build Compilation and build verification
Fast Quick basic tests
Related Tests relevant to the change
Integration Component integration tests
Full Full regression suite
GuiTargeted Targeted GUI verification
GuiFull Full GUI verification

These categories describe a design approach, not a universal set of commands.

During implementation, agents can use fast and related tests to obtain feedback. Broader verification is selected according to the change and the required integration or release gates.

Automatic test selection should fall back to broader verification when the impact is uncertain.

The goal is not to remove regression tests. It is to execute the necessary tests at the appropriate time.

Expensive GUI tests should be risk-based

GUI tests may depend on desktop sessions, shared databases, and other limited resources.

Not every code change requires the same GUI coverage.

An example policy could be:

Change GUI verification
Internal calculation Usually unnecessary
Data access logic Evaluate affected workflows
Minor text change Optional, depending on risk
High-risk save or navigation behavior Required targeted verification
Complex GUI interaction Normally required
Formal release Required GUI regression according to release policy

If a GUI test is optional under an established policy, an agent can complete the task without running it. But the status must remain NOT_RUN, not PASSED.

If the GUI test is required and the environment prevents it from running, integration remains blocked.

Asynchronous test queues can help agents continue independent work while expensive tests run. A queued test is still not a successful test.

Stop retrying failures that cannot be fixed by another attempt

A failed test does not always indicate a product defect.

The environment may lack database credentials, a usable desktop session, or another required resource.

Repeatedly running the same test under unchanged conditions may waste time and model usage.

I prefer explicit outcomes:

  • PASSED: verification succeeded.
  • FAILED: investigate the failure and correct the cause.
  • QUEUED: execution is pending.
  • NOT_RUN: verification has not been executed.
  • BLOCKED_ENVIRONMENT: a required environmental condition is missing.
  • BLOCKED_REQUIREMENT: a specification decision is required.

Bounded retries can make sense for transient errors. Persistent failures require investigation and a change in conditions, rather than an unlimited retry loop.

A blocked task is not a completed task. Report the missing conditions, preserve the evidence, and continue only when appropriate.

Put the policy in AGENTS.md

An example repository-level policy might look like this:

## Quality and Scope Policy  - Implement only approved requirements. - Prefer minimal, localized changes. - Preserve behavior outside the approved scope. - Avoid speculative features and abstractions. - Report unrelated improvements separately. - Use staged tests during implementation. - Run all required integration gates. - Resolve all merge-blocking findings. - Never downgrade findings to bypass a gate. - Use bounded retries for transient failures. - Do not repeatedly retry unchanged environmental failures. - Stop when the Definition of Done is satisfied. - Report residual risks and unexecuted checks. 

The exact policy depends on the project. High-risk systems will require stricter verification than small experimental projects.

Measure the outcome, not just the amount of work

To evaluate whether these policies help, I would track:

Metric What it tells us
Task completion time End-to-end development cost
Token consumption Model usage per task
Review iterations Correction and review overhead
Full regression runs Expensive verification frequency
Change scope Unnecessary expansion of modifications
Completed issues Development throughput
Escaped defects Quality after integration

Reducing test counts or review iterations alone is not evidence of success. The objective is to reduce avoidable costs while maintaining the required quality.

These are proposed evaluation metrics based on my development experience, not controlled benchmark results.

Conclusion

AI-driven development requires more than capable coding agents.

It requires a development process that distinguishes mandatory quality requirements from optional improvements, defines when a task is complete, and handles blocked work honestly.

The goal is not lower quality. It is to allocate development resources where they deliver meaningful value.

Teach AI agents what to do, what not to do, and when to stop.

How do you define stopping criteria for your AI coding agents? Have you encountered review loops or unnecessary refactoring that continued after the original task was effectively complete?