12-04 更新 实时
首页/ 技术栈/ 正文

GitHub Copilot 代码审查:多智能体减少盲区

技术栈 来源:GitHub Blog 2026-12-01 01:30 2 阅读 机器翻译
GitHub Copilot 代码审查:多智能体减少盲区

智能体每天在编写我们越来越多的代码,而每个 pull request 在合并前仍然需要审查。人类审查者无法阅读这不断增长的数量中的每一行,因此团队正在借助 AI 来帮忙。

不过,AI 审查者必须跨过一道很高的门槛。如果它漏掉了真正的 bug,就没人会相信它的沉默。如果它把这些 bug 淹没在误报中,就没人会读它的评论。

要同时做到这两点,意味着要找到可操作的 bug,保持低误报率,并控制住延迟和成本。在固定价格下,我们发现,使用互补模型的多个较小、独立的审查者,往往比由更强模型驱动的单个审查者表现更好。我们利用这一思路重建了 Copilot code review 的 Lite 和 Balanced 层级,并为你们最高风险的 pull request 推出了新的 Max 层级。这篇文章解释了为什么这有效,我们如何将多个审查者的发现整合成一次审查,以及我们如何利用这一思路重建 Copilot code review 的层级。

考虑一个具有固定提示词、模型和工具集的审查智能体。假设它有 60% 的概率标记出 pull request 中的某个特定 bug。它可能在一次运行中捕获该 bug,而在下一次运行中漏掉。

如果我们独立且并行地运行该审查者两次,至少有一次运行发现该 bug 的概率上升到 84%,而成本翻倍。如果独立运行三次,概率上升到 94%,而成本变为三倍。

更一般地,如果每个审查者发现某个特定 bug 的概率为 p,那么 n 个独立审查者中至少有一个发现它的概率是 1 − (1 − p)^n。在我们的例子中,p = 0.6。关键在于,只需要一个审查者发现该 bug。

运行多个审查者也会带来时间成本。审查时间可能会适度增加,因为我们必须等待最慢的审查者完成。

反复运行同一个审查者,能带来的提升终究有限。到第三次运行之后,我们就开始看到收益递减。

每个模型也都有其训练所塑造的偏差。对某个特定模型而言,有些 bug 始终难以被标记出来,无论它审查同一个 pull request 多少次。模型在审查代码时各有强项,也各有特定的盲区。

为了说明这一点,我们用 ReviewBench 测量了分别使用 GPT-6.1 Sol(高推理模式)、Claude Opus 5.5(高推理模式)以及两者组合时,发现关键 bug 的百分比。你可以在我们早前的博客文章中进一步了解 ReviewBench。

在下图中,虚线表示在每个价格点上,反复运行 GPT-6.1 Sol 或 Claude Opus 5.5 其中之一所能发现关键 bug 的最高百分比。实线则表示将这两个模型组合使用所能达到的最高百分比。

实线始终位于虚线之上或与之持平,因为混合方案可以包含单模型方案。真正重要的是两者之间的差距,它体现了混合模型所能带来的提升。在每个 pull request 花费 3 美元时,将这两个模型组合使用,使 ReviewBench 上捕获关键 bug 的比例提升了 4.9 个百分点,从 61.3% 升至 66.2%。

Copilot code review 可以调用来自不同厂商的模型,因此不会局限于某一个模型家族的强项与盲区。这种灵活性让我们能够挑选在特定价格点上表现最佳的互补审查者。

当两个独立的审查者检查同一份代码时,它们可能发现一些相同的 bug,也可能各自发现对方遗漏的问题。为了减少噪声、避免同一问题被重复报告,我们会把它们的发现整合成一份统一的审查结果。这意味着要对发现的问题去重,并剔除误报。

Copilot 代码审查使用两种策略来实现这一点:投票和智能体式聚合。

让我们看一个示例:这个拉取请求修改了 src/catalog/service.py,一个 Python 文件:

from catalog import cache, repository as repo CACHE_TTL_SECONDS = 60 def get_product(product_id): cached = cache.get(product_id) if cached is not None: return cached product = repo.find(product_id) if product is not None: cache.put( product_id, product, ttl_ms=CACHE_TTL_SECONDS, ) return product def rename_product(product_id, name): repo.rename(product_id, name) 三名独立审查者检查这些变更,并得出以下发现:

前两项发现是真阳性。缓存期望的过期时间以毫秒为单位,而重命名产品会更新数据库,却让缓存的快照保持不变。再仔细看看 src/api/products.py——这个拉取请求并未修改的文件——会发现第三项发现的情况不同:

from catalog.service import get_product def product_endpoint(product_id): product = get_product(product_id) if product is None: return 404, {"error": "Not found"} return 200, {"name": product["name"]} 现有防护逻辑已经会对缺失的产品返回 404,因此第三项发现是误报。现在考虑当我们改变投票阈值时会发生什么——阈值是指必须有多少名审查者标记某个问题,我们才会将其展示出来:

阈值为一票时,我们标记出两个真实 bug 和一个误报。把阈值提高到两票会消除误报,只留下真实 bug,从而提高精确率。提高到三票会漏掉其中一个真实 bug,从而降低召回率。

投票为我们提供了一种廉价、快速且简单的发现项筛选方式。难点在于选对阈值,而阈值可能因 pull request 而异。智能体式聚合则让能力更强的模型逐一检查每个发现项,剔除误报,并过滤掉严重度较低的琐碎问题。在这个示例中,一个检查了 src/api/products.py 的聚合器可以丢掉误报并保留两个真实 bug,代价是审查时间更长、成本更高。

投票奖励一致性并控制噪声,因此在成本和延迟紧张时很有用。智能体式聚合成本更高,但在我们的实验中产出的发现项质量更高。

我们使用相互独立、互补的审查者与聚合机制,重建了现有的 Lite 和 Balanced 层级,并推出了新的 Max 层级。概括来说,每个层级都会用以下智能体审查你的 pull request:

为了开发和迭代三个层级的初始配置,我们使用了 ReviewBench——一个基于具有代表性的 GitHub pull request 和与生产环境对齐的指标构建的代码审查智能体基准测试。随后我们在内部和外部流量上进行了多轮在线实验。

以下是最终层级配置在线上环境的表现:

首先,让我们比较各层级每次审查的平均发现项数量,并按严重度拆分:

Max 提供了最大的覆盖范围,尤其是在关键问题上,这正是我们的目标。Lite 和 Balanced 每次审查产出的发现项总数相近,而 Lite 产出的关键和低严重度发现项更多。Balanced 发现的问题比 Lite 少,但其中值得修复的比例更高。

下图展示了各层级中,开发者已处理、已忽略或被判定为误报的关键和中等问题所占的百分比:

三者共同构成三个不同的级别。从 Lite 到 Balanced 再到 Max,开发者可处理的发现项逐级增多。因此 Lite 更适合在你迭代时进行频繁审查,而当你接近最终版本时再切换到 Balanced 和 Max。

每个级别针对特定的价格与质量区间,相邻级别的目标成本大约上升 6 倍。Lite 面向迭代过程中的频繁审查,Max 面向合并前的全面检查。

Balanced 介于两者之间,在快速迭代与最终审查之间提供一个折中选择。

Max 对你的要求也更高。它每次审查会留下约 2 个发现项,而 Lite 和 Balanced 约为 1.1 到 1.2 个,因此需要阅读的内容更多。在漏掉一个 bug 的代价通常高于审查本身成本的场景下,值得使用它。

审查耗时同样重要。有时你在构建过程中需要快速反馈,有时正确性和彻底性比速度更重要。

Lite 和 Balanced 通常约 4 分钟完成。Max 的中位耗时约为 12 分钟,在第 90 百分位可达 20 分钟,因此最适合作为最终检查。

这只是这些级别当前状态的快照。随着新模型可用以及我们的方法不断改进,我们会更新每个级别,以在其价格区间内提供最佳性能。

每个级别使用相同的工具和审查提示词。级别决定 Copilot code review 检查的力度,而你仓库的上下文决定它知道要寻找什么,包括团队的约定、你允许的例外,以及审查者反复发现的错误。

一个 pull request 的不同部分可能也需要不同程度的关注。有些部分可能需要前沿模型,而其他部分用较小的模型可能就足够了。我们正朝着动态代码审查努力:从一组审查角色名单中调度审查者去处理 pull request 的特定部分,并根据其需求定制审查。

目标仍然是提供一次有用的审查:有更多机会发现重要问题,同时不把梳理审查发现的工作又交还给你。

在你下一个高风险的 pull request 上试试 Max 层级吧。

原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(More agents, fewer blind spots: Inside GitHub Copilot code review)

Agents are writing more of our code every day, and every pull request still needs a review before it merges. Human reviewers can’t read every line of that growing volume, so teams are using AI to help.

An AI reviewer has to clear a hard bar, though. If it misses real bugs, nobody trusts its silence. If it buries those bugs in false alarms, nobody reads its comments.

Getting both right means finding actionable bugs, keeping false positives low, and holding latency and cost in check. At a fixed price, we’ve found that several smaller, independent reviewers using complementary models often outperform a single reviewer powered by a stronger model. We used that idea to rebuild Copilot code review’s Lite and Balanced tiers and to launch a new Max tier for your highest-stakes pull requests. This post explains why that works, how we turn many reviewers’ findings into one review, and how we used the idea to rebuild Copilot code review’s tiers.

Why does this work? A simple example

Consider a review agent with a fixed prompt, model, and set of tools. Suppose it has a 60% chance of flagging a particular bug in a pull request. It might catch that bug on one pass and miss it on the next.

If we run that reviewer twice, independently and in parallel, the probability that at least one run finds the bug rises to 84%, while the cost doubles. With three independent runs, the probability rises to 94%, while the cost triples.

More generally, if each reviewer has probability p of finding a particular bug, the probability that at least one of n independent reviewers finds it is 1 − (1 − p)^n. In our example, p = 0.6. The key is that only one reviewer needs to find the bug.

Running several reviewers also has a cost in time. Review time can increase modestly because we have to wait for the slowest reviewer to finish.

Same-model and mixed-model reviews

Repeatedly running the same reviewer only takes us so far. We start to see diminishing returns after the third run.

Each model also has biases shaped by its training. Some bugs remain difficult for a given model to flag, no matter how many times it reviews a pull request. Models have particular strengths when reviewing code, and they also have specific blind spots.

To illustrate this, we used ReviewBench to measure the percentage of critical bugs found using GPT-6.1 Sol (high reasoning), Claude Opus 5.5 (high reasoning), and combinations of the two. You can read more about ReviewBench in our earlier blog post.

In the chart below, the dashed line shows the highest percentage of critical bugs found at each price point by repeatedly running either GPT-6.1 Sol or Claude Opus 5.5. The solid line shows the highest percentage found by combining the two models.

Step chart titled “Critical recall vs. budget.” The x-axis shows average-cost budget per PR from $0 to $3; the y-axis shows critical grounded recall from 45% to 70%. Dashed blue “Same model” and solid green “Mixing allowed” lines rise from about 51% recall at low budgets. At $3 per PR, recall is about 61% for the same model and 66% when mixing is allowed, an estimated gain of 4.70 percentage points.

The solid line is always at or above the dashed line, because a mix can include the single-model option. What matters is the gap between them, which shows the improvement available from mixing models. At $3 per pull request, combining these two models raises the share of critical bugs caught on ReviewBench by 4.9 percentage points, from 61.3% to 66.2%.

Copilot code review can draw on models from different providers, so it isn’t limited to one model family’s strengths and blind spots. That flexibility lets us pick complementary reviewers that perform best at a given price point.

Cohesive reviews

When two independent reviewers examine the same code, they may find some of the same bugs, and each may find issues the other misses. To reduce noise and avoid reporting the same issue several times, we combine their findings into one cohesive review. That means deduplicating findings and removing false positives.

Copilot code review uses two strategies to do this: voting and agentic aggregation.

  • Voting deduplicates the findings from all reviewers and counts how many reviewers flagged each one. Findings with fewer votes than a set threshold are suppressed, on the assumption that fewer votes signals lower confidence. Voting is fast and cost-effective, because deduplication takes only one-shot LLM calls.
  • Agentic aggregation uses an agent to reconcile the findings from all reviewers into one review. The agent can curate and refine findings, resolve disagreements, and double-check that each finding is accurate. In exchange, the review takes longer and costs more.

Let’s look at an example of a pull request that changes src/catalog/service.py, a Python file:

from catalog import cache, repository as repo

CACHE_TTL_SECONDS = 60

def get_product(product_id):
    cached = cache.get(product_id)
    if cached is not None:
        return cached

    product = repo.find(product_id)
    if product is not None:
        cache.put(
            product_id,
            product,
            ttl_ms=CACHE_TTL_SECONDS,
        )

    return product

def rename_product(product_id, name):
    repo.rename(product_id, name)

Three independent reviewers examine the changes and produce these findings:

Candidate findingReviewer AReviewer BReviewer C
Cache expiration uses the wrong unitsXXX
Renaming a product leaves stale cached dataXX
Missing products crash the endpointX

The first two findings are true positives. The cache expects expiration times in milliseconds, and renaming a product updates the database but leaves its cached snapshot unchanged. A closer look at src/api/products.py, a file this pull request didn’t change, tells a different story about the third finding:

from catalog.service import get_product

def product_endpoint(product_id):
    product = get_product(product_id)

    if product is None:
        return 404, {"error": "Not found"}

    return 200, {"name": product["name"]}

An existing guard already returns a 404 for a missing product, so the third finding is a false positive. Now consider what happens as we vary the voting threshold, which is the number of reviewers that must flag an issue before we show it:

Threshold# of True Positives# of False PositivesPrecisionRecall
12167%100%
220100%100%
310100%50%

With a threshold of one vote, we flag two real bugs and one false positive. Raising the threshold to two removes the false positive and leaves only real bugs, which raises precision. Raising it to three drops one of the real bugs, which lowers recall.

Voting gives us a cheap, fast, and simple way to curate findings. The challenge is choosing the right threshold, which can vary between pull requests. Agentic aggregation lets a more capable model check each finding, remove false positives, and filter out low-severity nits. In this example, an aggregator that checked src/api/products.py could drop the false positive and keep both real bugs, at the cost of a longer, more expensive review.

Voting rewards agreement and controls noise, which makes it useful when cost and latency are tight. Agentic aggregation costs more and, in our experiments, produced higher-quality findings.

New review tiers

We used independent, complementary reviewers and aggregation to rebuild our existing Lite and Balanced tiers and to launch a new Max tier. At a high level, each tier reviews your pull request with these agents:

  • Lite: 4× GPT-5.6 Luna reviewers, combined with voting.
  • Balanced: 3× GPT-6.1 Sol reviewers, combined with agentic aggregation by GPT-6 Astra.
  • Max: 4× GPT-6.1 Sol, 2× Claude Opus 5.5, and 2× GPT-6 Astra reviewers, combined with agentic aggregation by GPT-6.1 Sol.

To develop and iterate on the initial configurations for all three tiers, we used ReviewBench, a benchmark for code review agents built on representative GitHub pull requests and production-aligned metrics. We then ran several rounds of online experiments on internal and external traffic.

How we measure

  • Online experiments: In total, 1.4 million pull requests, including external ones, were involved in the online experiments to design the lite and balanced tiers between September 16 and October 7. We used 30K internal reviews within GitHub and Microsoft between October 2 and 7 to design and test the Max tier.
  • Severity: Each finding is labeled critical, moderate, or low by a separate agent using a rubric. A critical comment is a concrete problem that should be fixed before merging; a moderate one is an issue that affects behavior but is unlikely to cause serious harm, while a low severity comment is one that describes a minor improvement that can safely be deferred.
  • Precision: The share of findings that are real issues.
  • Recall: The share of real issues that Copilot code review found. We estimate this at review time by looking at the comments and issues identified by other agents or humans and comparing them to those flagged by Copilot code review.
  • Addressed/Ignored/False positive: Just as we have a separate agent label severity, we also have an agent check whether a comment was addressed or ignored. An addressed comment is one which is fixed when the pull request merges, while an ignored one is one on which a user does not act upon. A false positive is a comment that a user has explicitly indicated is incorrect or invalid.

Here’s how the final tier configurations performed online:

Comparison table for Lite, Balanced, and Max. Online precision is 69%, 75%, and 73%; recall is 57%, 61%, and 67%; F1 is 62, 67, and 69. Findings per review are 1.24, 1.14, and 2.01, with 0.58, 0.41, and 0.75 high-severity findings. Median cost per review is $0.19, $1.18, and $7.90; median time is 4, 4, and 12 minutes.
Note: The F1 score is the harmonic mean of precision and recall and is used in ReviewBench (in an offline setting) to rank review agents.

What is the difference in coverage and quality?

First, let’s compare the average number of findings per review for each tier, broken down by severity:

Stacked bars show average high-, medium-, and low-severity findings per review. Lite: 0.58 high, 0.47 medium, 0.18 low, total 1.24. Balanced: 0.41 high, 0.65 medium, 0.08 low, total 1.14. Max: 0.75 high, 1.09 medium, 0.17 low, total 2.01.

Max provides the greatest coverage, especially of critical issues, which was our goal. Lite and Balanced produce a similar total number of findings per review, and Lite produces more critical and low-severity findings. Balanced finds fewer issues than Lite, but more of them are worth fixing.

The chart below shows the percentage of critical and moderate findings that developers addressed, ignored, or that were classified as false positives, for each tier:

Stacked bars compare addressed, ignored, and false-positive findings for Lite, Balanced, and Max reviews. For critical findings, addressed rates are 59.9%, 70.0%, and 76.3%; for moderate findings, 63.3%, 67.7%, and 74.4%.

Together, these form three distinct tiers. Developers act on more findings as you move from Lite to Balanced to Max. That makes Lite better for frequent review while you’re iterating, and moving to Balanced and Max as you get closer to final.

How much do the tiers cost?

Each tier targets a specific price and quality range, with target costs rising roughly 6× from one tier to the next. Lite is designed for frequent reviews as you iterate. Max is designed for a thorough pass before you merge.

Three overlapping cost distributions on a logarithmic USD axis compare Lite, Balanced, and Max plans. Median costs are $0.19, $1.18, and $7.90; dashed lines mark average costs of $0.27, $1.50, and $9.27.

Balanced sits between them, offering a middle ground between fast iteration and a final review.

Max also asks more of you. It leaves about two findings per review, compared with about 1.1 to 1.2 for Lite and Balanced, so there’s more to read. It’s worth using it where a missed bug would typically cost more than the review.

How long does each tier take?

Review time matters too. Sometimes you need fast feedback while you build. Other times, correctness and thoroughness matter more than speed.

Overlaid duration distributions compare Lite, Balanced, and Max. Median times are 3.8, 3.9, and 12.4 minutes; the 90th-percentile times are 7.3, 7.8, and 20.0 minutes.

Lite and Balanced typically finish in about four minutes. Max takes about 12 minutes at the median and can take 20 minutes at the 90th percentile, so it fits best as a final pass.

Just a starting point

This is a snapshot of where the tiers stand today. As new models become available and our approach improves, we’ll update each tier to deliver the best performance we can within its price range.

Next: Review effort that fits the change

Every tier uses the same tools and review prompt. The tier sets how hard Copilot code review looks. Your repository’s context sets what it knows to look for, including your team’s conventions, the exceptions you allow, and the mistakes your reviewers keep catching.

Different parts of a pull request may also need different levels of attention. Some may require a frontier model, while a smaller model may be sufficient for others. We’re working toward dynamic code review, dispatching reviewers from a roster of review personas to specific parts of a pull request and tailoring the review to its needs.

The goal remains one useful review: more chances to catch important issues, without handing the work of sorting through findings back to you.

Try the Max tier on your next high-stakes pull request.

Acknowledgments

Thank you to the science, engineering, and product teams across GitHub and Microsoft who helped make these new tiers a reality!

The post More agents, fewer blind spots: Inside GitHub Copilot code review appeared first on The GitHub Blog.

正文保留英文原文,标题与摘要由机器翻译。

本文由采集器自动同步

原文发布于 GitHub Blog(More agents, fewer blind spots: Inside GitHub Copilot code review),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗