← Field notes
AI Engineering4 min readJuly 14, 2026

Passing the test suite is one part of earning a maintainer’s trust

How to Review AI-Generated Code Before It Merges

A coding agent can produce a patch that compiles, passes the tests it wrote, and still makes the repository harder to own. Production teams inherit the scope choices, abstractions, failure handling, and maintenance cost after the benchmark ends.

How to Review AI-Generated Code Before It Merges

Code that runs can still leave bad tests, stray edits, weak architecture, and more cleanup than progress. Teams need supervision, real scenarios, scope checks, and a standard a maintainer would accept.

01

Correctness is necessary and incomplete

A benchmark can check whether code produces the expected output. A maintainer asks more questions. Did the patch stay inside scope? Do the tests cover the failure that matters? Does the design fit the repository? Can another engineer understand the change next month?

Cognition’s FrontierCode benchmark focuses on mergeability, including scope, tests, design, and whether maintainers would approve the pull request. That standard resembles the cost teams face after an agent declares success.

02

Give agents a clear task boundary

Define the requested behavior, allowed files, constraints, test expectations, and excluded cleanup. An agent that refactors nearby code may improve one metric and create a review burden nobody requested.

Require the agent to report changed files and explain any scope expansion. If new work becomes necessary, pause and ask rather than hiding it inside the patch.

  • 01State the behavior and acceptance criteria.
  • 02Name allowed and excluded areas of the repository.
  • 03Require tests for failure paths and regressions.
  • 04Report scope changes before editing unrelated code.
03

Test real scenarios before trusting generated tests

An agent can write tests that confirm its own misunderstanding. Start with user flows, production incidents, and invariants the business cannot violate. Ask whether the test would fail before the fix and whether it covers the consequence behind the bug.

Use another tool to generate additional cases if helpful, then let an engineer decide which failures matter. Delegation gets cheaper faster than verification. The testing plan belongs in the task from the beginning.

04

Use a supervision surface for parallel work

Several agents working at once create a dispatch problem. The operator needs to see task state, branch or worktree, changed files, blockers, test results, and pending review. A chat list does not provide enough operational control.

Products such as Devin Desktop and Arena Agent Mode point toward command-center interfaces where people assign work and inspect execution. The interface should surface uncertainty and stalled runs instead of rewarding output volume.

05

Review maintainability and repository fit

Check naming, abstractions, error handling, dependencies, documentation, and alignment with local patterns. A patch that introduces a second architecture for a small feature carries a future cost even if the current test passes.

Ask the agent to explain the tradeoff in plain language. Reviewers should distrust elaborate justification for a change that the codebase does not need.

06

Measure accepted work and cleanup

Track review cycles, rejected patches, escaped defects, revert rate, and maintainer time. Lines generated and tasks completed reward activity. Merge rate alone can also mislead if reviewers lower standards to keep the queue moving.

Compare agent-assisted work with similar human work over enough tasks to see a pattern. The goal is dependable engineering leverage with the same or better ownership quality.

What to keep

  • 01Define scope and acceptance criteria before the agent edits code.
  • 02Test business failures, production scenarios, and generated expectations.
  • 03Use a supervision surface for parallel agent work.
  • 04Measure review and cleanup effort alongside completed tasks.

Frequently asked

01

How should a team evaluate an AI coding agent?

Evaluate correctness, scope discipline, tests, architecture fit, maintainability, review time, escaped defects, and cleanup. A useful standard asks whether a maintainer would approve and own the patch.

02

Can an AI agent test its own code?

It can generate and run tests, but those tests may reflect the same misunderstanding as the code. Engineers should anchor tests in real user flows, production failures, and business invariants.

Sources and further reading

  1. 01FrontierCode benchmark Cognition
  2. 02Arena Agent Mode Arena
  3. 03Devin Desktop FAQ Cognition

Share

Take this to your AI