Skip to content
All writing

Agentic delivery · Part 3 of 5

Reviewing and Testing Agent-Written Code

How review and testing change when agents write the code, from adversarial agent reviews to protecting the tests.

AIAgentic deliveryTesting

Agent-written code fails differently from human-written code. It is rarely careless in the small: the syntax is clean, the names are sensible, the obvious cases are handled. Where it goes wrong is in the large. It solves a slightly different problem, misses a constraint that was never written down, or makes a change that is correct in isolation and wrong for the system.

That shifts what review and testing are for. This is the third of five notes on agentic delivery in the software development lifecycle.

Review for what is missing

A human reviewer reading a tidy agent diff is tempted to check what is there and approve. The more useful questions are about what is not there:

  • Which acceptance criteria does this change not cover?
  • Which callers of the code it changed were not updated?
  • Which error paths, empty states or permission checks are absent?
  • Which existing behaviour changed that the spec did not ask to change?

Reading the spec next to the diff, rather than the diff alone, is what surfaces these.

Use a second agent as an adversary

A useful pattern is to have a separate agent review the change with explicit instructions to find problems. Give it the diff and the spec, not the first agent's reasoning, so that it is not anchored on the same assumptions. Ask it for concrete findings, each with a location and a failure scenario, and ask it to say plainly when it finds nothing that matters.

An adversarial review like this is not a replacement for a person. It is a filter that catches a class of issue cheaply, so the person's attention goes to the judgment calls. It works best as a standing rule on every pull request rather than something reached for when a change feels risky, because the risky changes are the ones that do not feel risky.

Every finding gets an answer: either a fix, or a short explanation of why the finding is wrong. Leaving review comments unanswered teaches everyone, people and agents alike, that the review is decoration.

Tests are the contract, so protect them

When agents write most of the code, tests become the main way a team states what the system must do. That makes the tests themselves the thing to guard.

  • Contract tests for anything other systems depend on. If an API is consumed by other services or other companies, lock its routes, payload shapes and auth behaviour in tests that must pass before anyone changes it.
  • Tests written from the spec, not from the code. A test generated by reading the implementation will happily confirm a bug. Tests derived from the acceptance criteria will not.
  • Test changes get the strictest review. A change to an existing test deserves more scrutiny than a change to code, and a deleted or loosened assertion deserves a reason in the pull request description.

Guard the things that are easy to forget

Some rules are hard to see in a diff but easy to check automatically: APIs that must not be called, licence headers that must be present, secrets that must not be committed, dependencies that must not be added, folders that must not be edited by hand. Turn those into checks that run in CI. An agent will not remember every rule in every task; a failing build will remind it every time.

Preview environments make review real

For anything with a user interface, a preview environment per pull request changes the quality of review. A reviewer who can click through the change on a real URL finds problems that no reading of the diff will show: a broken route, a layout that collapses on a phone, a form that cannot be submitted with the keyboard.

The fourth note in this series looks at what happens next: how agents fit into CI/CD, and the guardrails that keep deployment safe when more of the work is automated.

Responsible for a business-critical system?

If it is an inventory or build-out system that has become hard to change, the Inventory Data Health Check turns it into a plan with a switch-off date.