AI Agents for Code Review: From Pull Request to Rule-Based Approval

    When code generation speeds up, review, fixes, and approval become the new delivery bottleneck. This article explains a three-agent workflow for reviewing diffs, applying fixes, and approving pull requests only when explicit team rules are met, plus a gradual rollout path.

    1. The Bottleneck Moves from Writing Code to Reviewing It

    Over the past year, code models have made a clear leap—from autocomplete assistance to implementing a complete feature module on their own. Many teams are already in a state where most new code in an iteration is model-generated, while engineers mainly break down tasks and accept the results.

    An interesting side effect follows: code is produced much faster, but delivery does not speed up by the same amount. The bottleneck has moved.

    Anyone who works in collaborative development knows the pattern. You open a pull request and switch to the next task. Halfway through, review comments arrive, so you stop, reload the old context, change the code, push an update, and wait for another review. After approval is granted in principle, you still need a colleague with the right permissions to click the approve button. The work is repeatedly interrupted and repeatedly waiting.

    When people wrote all the code, that process was fine. Writing was the slow step, and review wait time was a small remainder. Once models raise code-generation speed by an order of magnitude, the path after submission becomes the new constraint.

    The response is straightforward: if agents can write the code, why not also review it and fix it?

    2. Three Agents for the Last Mile

    A maturing practice uses three agents with clear roles to take a pull request from submission to a mergeable state:

    1. Code review agent: scans the diff and surrounding code and locates potential defects.
    2. Fix agent: applies changes based on review comments and pushes updates.
    3. Approval agent: decides whether the pull request meets approval conditions written in advance by the team.

    They stay separate but hand work to one another. In a typical pull request, the review agent finds two issues. The fix agent updates the code and triggers another review. The re-review finds one remaining issue. After another fix, the review passes. The approval agent then checks the rules and, if they are satisfied, the pull request enters the merge queue.

    Two engineering points matter:

    • Use them together or separately. A team that only wants automated review can turn off fixes and approval.
    • Configure them per repository. Core services can enable all three. Experimental repositories can start with review only.

    3. Making Automated Review Trustworthy Instead of Noisy

    The biggest risk of automated review is not missing problems. It is reporting too many things that are not problems. Once false positives pile up, developers ignore the agent the same way they ignore some static scanners.

    3.1 Parallel checks, verification, deduplication, and ranking

    A reliable review pipeline usually has four steps:

    1. Parallel checks (diff + surrounding code)
    2. ↓
    3. Collect suspected issues
    4. ↓
    5. Verification step filters false positives
    6. ↓
    7. Deduplicate + rank by severity → publish as inline comments

    Running several review perspectives in parallel covers blind spots that a single path tends to miss. The verification step is a self-check: it re-reasons about each suspected issue, drops conclusions that do not hold, and avoids handing guesses to developers as findings.

    3.2 Severity levels that focus attention

    Review findings are usually split into three levels, and the meaning of each level must be explicit:

    • Important: a defect that should be fixed before merge because it can affect correctness or production behavior.
    • Nit: a small issue that may or may not be worth changing.
    • Pre-existing: a problem already in the codebase and not introduced by this pull request. Marking this class separately matters. Otherwise historical issues bury the review, and ownership becomes unclear.

    A typical example is a discount check that uses “less than” where it should use “greater than or equal to.” Customers above the spending threshold receive the discount, while customers below it do not. A one-line logic error like this is easy to miss in a quick human scan. The review agent can mark that exact line and classify it as Important.

    3.3 Adjustable review depth

    Review depth usually has three settings: fast, standard, and deep, and each repository can choose its own. Fast mode fits small changes and low-risk repositories. Deep mode analyzes surrounding call chains more thoroughly.

    3.4 Agreed review boundaries

    To avoid commenting on everything, the default policy usually focuses on real defects that could affect production, not formatting preferences or test-coverage conventions. If a team has its own emphasis—security first, for example, or extra checks on test cases—it can place an agreement file in the repository, such as a review guide, that states the team’s review standard. That makes “what we look for in a human review” an explicit configuration.

    3.5 Every comment should explain itself

    A useful automated review comment has four parts: what the problem is, when it is triggered, how to fix it, and why the judgment was made. The last part is especially important. A good automated review explains both the reasoning and how the conclusion was checked, so developers can verify it quickly instead of trusting it blindly.

    4. Fixes and Approval: Put the Rules First

    The fix agent’s job is relatively direct: change the code in response to review comments, add tests, and push a new commit. The hard part is that a fix can introduce a new problem. Each fix should therefore trigger a full re-review, forming a review–fix–re-review loop until the issues are cleared or a configured round limit is reached.

    The approval agent answers a more sensitive question: can a machine click the approve button for a person?

    The safer approach is not to let the model decide freely. Write the approval conditions as explicit rules—for example, all Important issues are resolved, CI is green, the change scope matches expectations, and certain sensitive directories are not involved. The approval agent only performs a mechanical check of those rules. Anything outside them still goes to a person. That removes the wait for someone to approve while keeping approval serious.

    5. Roll It Out Gradually

    Engineering managers introducing this pattern should take three steps:

    1. Start with read-only automated review. Publish inline comments and let developers decide what to accept. Watch the false-positive rate and adoption rate for one or two iterations.
    2. Then allow automatic fixes. Once review quality is good enough, let the agent fix Nit-level issues directly. Important issues should still ask for human confirmation.
    3. Enable rule-based approval last, starting with low-risk repositories and strict rules.

    At the infrastructure level, this kind of capability fits naturally with cloud code hosting, continuous integration, and container platforms. A development pipeline hosted on Baidu AI Cloud, for example, can connect review-agent output with build and deployment steps, forming an automated path from code change to release.

    6. Summary

    When the cost of writing code approaches zero, engineering efficiency shifts to the less visible pipeline of review, fixes, and approval. Four foundations carry that path: agents with distinct roles, clear defect levels, review conclusions that can be checked, and approval driven by rules written in advance. This does not replace an engineer’s judgment. It frees engineers from endless context switching so they can do the work that still needs a person.