GitHub Copilot Code Review 重构:多模型协作与分层策略
More agents, fewer blind spots: Inside GitHub Copilot code review
深入拆解了 GitHub 如何利用多模型并行与聚合策略优化代码审查效果,对做 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 审查者必须达到一个很高的标准。如果它遗漏了真正的错误,没人会信任它的沉默;如果它将这些错误淹没在误报中,没人会阅读它的评论。
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.
要做到这两点,意味着要找到可操作的错误、保持低误报率,并控制延迟和成本。在固定价格下,我们发现多个使用互补模型的小型独立审查者通常比由更强模型驱动的单一审查者表现更好。我们利用这一理念重建了 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.
考虑一个具有固定提示词、模型和工具集的审查代理。假设它在拉取请求中标记特定错误的概率为 60%。它可能在一次运行中发现该错误,而在下一次运行中遗漏它。
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.
如果我们独立且并行地运行该审查者两次,至少有一次运行发现该错误的概率将上升到 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.
更一般地说,如果每位审查者发现特定错误的概率为 p,那么 n 位独立审查者中至少有一位发现该错误的概率为 1 − (1 − p)^n。在我们的例子中,p = 0.6。关键在于,只需一位审查者发现该错误即可。
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.
为了说明这一点,我们使用 ReviewBench 测量了使用 GPT-6.1 Sol(高推理能力)、Claude Opus 5.5(高推理能力)以及两者组合所发现的严重错误百分比。您可以在我们之前的博客文章中了解更多关于 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 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 文件)的拉取请求示例:
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 finding | Reviewer A | Reviewer B | Reviewer C |
|---|---|---|---|
| Cache expiration uses the wrong units | X | X | X |
| Renaming a product leaves stale cached data | X | X | |
| Missing products crash the endpoint | X |
| 候选发现 | 审查者 A | 审查者 B | 审查者 C |
|---|---|---|---|
| 缓存过期使用了错误的单位 | X | X | X |
| 重命名产品会留下过期的缓存数据 | X | X | |
| 缺失的产品会导致端点崩溃 | 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:
前两个发现是真阳性。缓存期望以毫秒为单位指定过期时间,而重命名产品会更新数据库,但使其缓存快照保持不变。仔细查看 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"]}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 Positives | Precision | Recall |
|---|---|---|---|---|
| 1 | 2 | 1 | 67% | 100% |
| 2 | 2 | 0 | 100% | 100% |
| 3 | 1 | 0 | 100% | 50% |
| 阈值 | 真正例数 | 假正例数 | 精确率 | 召回率 |
|---|---|---|---|---|
| 1 | 2 | 1 | 67% | 100% |
| 2 | 2 | 0 | 100% | 100% |
| 3 | 1 | 0 | 100% | 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
我们的衡量方式
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力