跳到主内容
@wquguru
精选88GitHub 博客(RSS)产品发布/更新

GitHub Copilot Code Review 重构:多模型协作与聚合策略

More agents, fewer blind spots: Inside GitHub Copilot code review

原文
发到 X
推荐理由

深入拆解了 Copilot Code Review 的多模型协作与聚合工程实践,对做 Agent 编排和评测的同学极具参考价值,建议收藏研究其权衡取舍。

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.

每天,AI 代理都在编写我们更多的代码,而每一个拉取请求在合并前仍需经过人工审查。面对日益增长的代码量,人类审查者无法逐行阅读,因此团队开始借助 AI 来提供帮助。

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.

然而,AI 审查者必须达到一个很高的标准。如果它漏掉了真实的 bug,没人会信任它的沉默;如果它用误报掩盖了这些 bug,也没人会阅读它的评论。

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.

要做到两者兼顾,意味着要找到可操作的 bug,将误报率保持在较低水平,并控制延迟和成本。在固定价格下,我们发现使用互补模型的几个较小、独立的审查者通常比由更强模型驱动的单一审查者表现更好。我们利用这一理念重构了 Copilot 代码审查的 Lite 和 Balanced 层级,并为最高风险的拉取请求推出了新的 Max 层级。本文解释了为何这种做法有效、如何将多位审查者的发现整合为一份审查报告,以及我们如何利用这一理念重构 Copilot 代码审查的各个层级。

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.

考虑一个具有固定提示词、模型和工具集的审查代理。假设它在某个拉取请求中标记特定 bug 的概率为 60%。它可能在一次运行中捕获该 bug,而在下一次运行中遗漏。

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.

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

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.

更一般地说,如果每位审查者发现特定 bug 的概率为 p,那么 n 位独立审查者中至少有一位发现该 bug 的概率为 1 − (1 − p)^n。在我们的例子中,p = 0.6。关键在于,只需一位审查者发现该 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.

每个模型都受到其训练数据塑造的偏见影响。无论对同一个拉取请求审查多少次,某些 bug 对于给定模型来说仍然难以标记。模型在审查代码时各有优势,同时也存在特定的盲区。

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.

为了说明这一点,我们使用 ReviewBench 测量了使用 GPT-6.1 Sol(高推理能力)、Claude Opus 5.5(高推理能力)以及两者组合所发现的严重 bug 百分比。您可以在我们之前的博客文章中了解更多关于 ReviewBench 的信息。

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.

在下图中,虚线显示了通过反复运行 GPT-6.1 Sol 或 Claude Opus 5.5,在各个价格点上发现的严重 bug 的最高百分比。实线显示了结合这两个模型后发现的最高百分比。

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%.

实线始终位于虚线之上或与之持平,因为混合方案可以包含单模型选项。关键在于两者之间的差距,它展示了混合模型所带来的改进。在每次拉取请求(pull request)3 美元的价格点上,结合这两个模型使 ReviewBench 上捕获的严重 bug 比例提高了 4.9 个百分点,从 61.3% 提升至 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.

Copilot 代码审查可以利用来自不同提供商的模型,因此不受限于单一模型家族的优势和盲区。这种灵活性使我们能够选择互补的审查者,从而在给定价格点上实现最佳表现。

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.

当两个独立的审查者检查同一份代码时,他们可能会发现一些相同的 bug,并且各自可能发现对方遗漏的问题。为了减少噪音并避免多次报告同一个问题,我们将他们的发现合并为一份连贯一致的审查报告。这意味着对发现进行去重并排除误报。

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

Copilot 代码审查使用两种策略来实现这一目标:投票(voting)和智能体聚合(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.
  • 投票机制对所有审查者的发现进行去重,并统计每个发现被标记的次数。得票低于设定阈值的发现会被抑制,其假设是较少的票数意味着较低的置信度。投票速度快且成本效益高,因为去重仅需一次性的 LLM 调用。
  • 智能体聚合使用一个智能体将所有审查者的发现整合成一份审查报告。该智能体可以筛选和优化发现、解决分歧,并逐一核实每项发现的准确性。作为交换,审查过程耗时更长且成本更高。

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

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

代码 · 16 行
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
候选发现审查者 A审查者 B审查者 C
缓存过期使用了错误的单位XXX
重命名产品会留下过期的缓存数据XX
缺失的产品会导致端点崩溃X

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:

前两项发现是真阳性(true positives)。缓存期望以毫秒为单位指定过期时间,而重命名产品会更新数据库,但保留其缓存快照不变。仔细查看 src/api/products.py(此拉取请求未更改的文件),会对第三项发现呈现出不同的故事:

代码 · 6 行
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:

现有的守卫机制在找不到产品时已经返回 404,因此第三个发现是一个误报。现在考虑当我们改变投票阈值(即在显示问题之前必须标记问题的审查者数量)时会发生什么:

Threshold# of True Positives# of False PositivesPrecisionRecall
12167%100%
220100%100%
310100%50%
阈值真正例数量假正例数量精确率召回率
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.

投票为我们提供了一种廉价、快速且简单的筛选发现结果的方法。挑战在于选择合适的阈值,该阈值在不同拉取请求之间可能会有所不同。智能体聚合允许更强大的模型检查每个发现结果,移除误报,并过滤掉低严重性的细微问题。在这个例子中,一个检查 src/api/products.py 的聚合器可以丢弃误报并保留两个真实错误,代价是更长、更昂贵的审查过程。

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 和 Balanced 层级,并推出了新的 Max 层级。从宏观层面来看,每个层级通过以下智能体来审查你的拉取请求:

  • 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.
  • Lite:4 个 GPT-5.6 Luna 审查者,结合投票机制。
  • Balanced:3 个 GPT-6.1 Sol 审查者,结合由 GPT-6 Astra 执行的智能体聚合。
  • Max:4 个 GPT-6.1 Sol、2 个 Claude Opus 5.5 和 2 个 GPT-6 Astra 审查者,结合由 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.

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

How we measure

我们的衡量方式

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件