AI Code Review Automation: A Practical Guide to Review, Fix, and Approval Agents

    As AI coding tools accelerate code generation, review has become the slowest stage of the delivery pipeline. This guide explains how three specialized agents—review, fix, and approval—split responsibilities, how to suppress false positives in automated review, how to keep fixes small and revertible, and how to express merge criteria as auditable rules. It also covers a phased rollout strategy and key risk controls for teams adopting AI-driven pull request automation.

    1. The Problem: Code Generation Got Faster, but Delivery Became the Bottleneck

    Over the past year, AI coding tools have improved significantly at generating code, and in many teams most new code is now produced by models. Yet an often-overlooked fact remains: writing code is only the first half of the delivery pipeline. The second half—review, revision, re-review, approval, and merge—still moves forward through manual, serial handoffs.

    A typical scenario looks like this. A developer submits a change and immediately moves on to the next task. Halfway through, review comments arrive, forcing them to interrupt their current work, reload the context, update the code, push again, and wait for another review round. Finally, they need to find a colleague with merge permissions to click approve. In the era when code was mostly written by hand, this overhead was not a major share of the cycle. But once generation is compressed to minutes, waiting for review becomes the longest part of the entire loop.

    This is why the industry has started introducing agents into the review stage. It is worth emphasizing that this capability is not unique to any single vendor; it is a direction being broadly explored across engineering productivity tooling: using multiple specialized agents to handle finding issues, fixing issues, and deciding whether a change can merge.

    2. Three Roles: Review, Fix, and Approve

    A relatively mature split uses three collaborating agents:

    • Review agent: read-only analysis of the change, producing a structured list of issues;
    • Fix agent: generates patches based on the issue list and pushes new commits;
    • Approval agent: decides whether the change meets merge conditions according to rules written in advance by the team.

    The three can be enabled independently or scoped per repository. For example, enable all three only in core service repositories, and enable review only in experimental repositories. The key value of this design is separation of responsibilities: the one who finds issues does not change code, the one who changes code does not make the final decision, and decision authority comes from rules rather than the model’s subjective judgment.

    A complete loop typically looks like this: the first review round finds two issues; after fixes, re-review leaves one; another fix round passes; then the approval agent clears the change according to the rules, and it enters the merge queue. Throughout the process, no human needs to repeatedly switch context.

    3. The Review Agent: How to Keep False Positives Down

    The hardest part of review is not finding issues, but avoiding being drowned in noise. Common engineering practices include four layers:

    1. Parallel analysis. Multiple agents examine the change itself and the surrounding context, covering different defect types;
    2. Verification step. Perform a reverse confirmation on suspected issues to eliminate claims that do not hold;
    3. Deduplication and ranking. Merge duplicates and classify by severity;
    4. Inline publishing. Present issues, trigger conditions, and fix suggestions as line-level comments on the changed lines, with reasoning and verification evidence expandable when needed.

    Severity is generally divided into three levels: defects that must be fixed before merge, optional minor improvements, and historical issues that already existed in the codebase and were not introduced by this change. Marking historical issues separately prevents review from being occupied by unrelated legacy noise.

    Review depth is usually offered in three tiers—fast, standard, and deep—configurable per repository. The default policy generally focuses on correctness defects that affect production, without getting stuck on formatting preferences or test coverage. If a team has additional requirements, it can place a review guidance file in the repository, describing focus areas and exceptions in natural language.

    A typical defect example is wait-time handling in retry logic: a server’s wait hint may be a number of seconds, an absolute timestamp, or entirely absent. If the implementation parses only a single form, it will degrade under rate limiting into repeatedly retrying an already overloaded service at high frequency, amplifying the failure. The review agent should point out all three branches and suggest a compatible implementation:

    1. def parse_wait(value, now):
    2. if value is None:
    3. return DEFAULT_BACKOFF
    4. try:
    5. seconds = float(value)
    6. return max(0.0, seconds)
    7. except ValueError:
    8. # Absolute time in HTTP-date form
    9. return max(0.0, parse_http_date(value) - now)

    The boundary must be explicit: the review agent only reads code. It does not build, does not run, and never approves or blocks changes on its own. Its output is an opinion, not authority.

    4. The Fix Agent: Small Commits and Revertibility

    The guiding principle for fixes is minimal scope: generate patches only for confirmed issues, with no opportunistic refactoring and no bundled formatting changes. Each fix corresponds to an independent commit, and the commit message states which review comment it addresses, making it easy to trace and revert individually. If a comment is judged to be a false positive, reply explicitly with the reason instead of silently ignoring it, so that rules and judgments leave a trace.

    5. The Approval Agent: Expressing Merge Standards as Code

    The core of approval is making team consensus explicit. Rules generally cover: whether required reviews are complete, whether the check pipeline is fully green, whether the change touches protected directories, whether necessary tests are missing, and whether the commit size exceeds a threshold. An example rule set can be expressed as:

    1. require:
    2. checks_green: true
    3. approvals_min: 1
    4. max_changed_lines: 400
    5. protect_paths:
    6. - "infra/**"
    7. - "payments/**"
    8. forbid_auto_merge: true

    Critical paths involving permissions, data, and funds should have automatic approval disabled by default, keeping human confirmation. All automated decisions must leave an audit record, including the rule version and the basis for the decision.

    6. Rollout Recommendations and Risk Controls

    Start with a pilot in low-risk repositories, enabling review only, and observe the false positive rate; once stable, introduce fixes and rule-based approval. Continuously maintain the review guidance file and the rule set, and treat false positives as rule defects to fix. If a team uses Baidu AI Cloud or related cloud engineering capabilities to host code repositories, pipelines, log services, and monitoring alerts, automated review conclusions and pipeline check results can be aggregated in one place to form a traceable delivery dashboard. The ultimate goal is not to eliminate human review, but to let people handle only the problems that genuinely require judgment.