# US 2026/0099326 A1 · Multi-agent code review comment generation

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2026/0099326 A1
- Document ID: US20260099326A1
- Status: Published application
- Kind: A1
- Application number: 19/064,362
- Filed: 2025-02-26
- Published: 2026-04-09
- Earliest claimed: 2024-10-08
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC.
- Inventors: SHENGYU FU; BIRGIT HINDMAN; MAOLIANG HUANG; XIAOYU LIU; SNEHA BHUPINDERSINGH TULI; DONGJIANG YOU; SHUO ZHANG
- Web page: https://patentgrep.com/patent/US20260099326A1

## CPC

- G06F 8/73: Program documentation
- G06F 8/71: Version control (security arrangements therefor G06F21/57); Configuration management
- G06F 8/75: Structural analysis for program understanding
- G06F 21/577: {Assessing vulnerabilities and evaluating computer system security}
- G06F 2221/033: Test or assess software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A code review comment is automatically generated using multiple agents that perform a dedicated task using a particular language model. A code quality estimator agent uses a code quality encoder model to determine whether a code change to a file of a repository presents a risk to the repository if merged. For those code changes classified as presenting a risk, a comment generator agent uses a generative language model to generate an initial code review comment for the code change and determines a severity of the issue with the code change. A comment critic agent uses a reasoning language model to critique the initial code review comment generated by the generative language model. A final code review comment is output by the comment critic agent when the comment critic agent determines that the initial code review comment is satisfactory.

## Claims

### Claim 1

A system for generating a code review comment, comprising:
a processor; and
a memory that stores a program to be executed by the processor, wherein the program comprises a plurality of agents having executable instructions to perform acts that:
obtain, by a first agent of the plurality of agents, a code change made to a file of a repository;
cause, by the first agent of the plurality of agents, a neural encoder model to classify the code change with a risk level for when the code change is merged into the repository, wherein the neural encoder model is given input comprising the code change;
cause, by a second agent of the plurality of agents, a first language model to generate a code review comment for the code change when the neural encoder model classifies the code change with a risk level of high, wherein the code review comment comprises a severity score for an issue of the code change, wherein the first language model is given original source code of the code change, the code change and a context of the code change;
cause, by a third agent of the plurality of agents, a second language model to review the code review comment for compliance with quality criteria when the severity score of the first language model comprises a high value, wherein the second language model is given the code review comment and the quality criteria, wherein the first language model and the second language model differ; and
output, by the third agent of the plurality of agents, the code review comment when the second language model indicates that the code review comment complies with the quality criteria.

### Claim 2 (depends on 1)

The system of claim 1, wherein the code change is formatted as a code diff hunk.

### Claim 3 (depends on 1)

The system of claim 1, wherein the context of the code change comprises a file-level context and a repo-level context.

### Claim 4 (depends on 3)

The system of claim 3, wherein the file-level context comprises an import statement, a global attribute, a signature of a class where the code change occurs, a method adjacent to or directly invoked in an area of the code change, and/or a method signature of another method in the file.

### Claim 5 (depends on 3)

The system of claim 3, wherein the repo-level context comprises a method signature in the file that is defined in another file of the repository.

### Claim 6 (depends on 1)

The system of claim 1, wherein the quality criteria ensures that the code review comment does not include a suggestion existing in the code change.

### Claim 7 (depends on 1)

The system of claim 1, wherein the quality criteria ensures that the code review comment does not include a suggestion of identifying a code element not defined in the context.

### Claim 8

A computer-implemented method for generating a code review comment, comprising:
obtaining a code change to a file of a repository;
causing, by a first agent, a neural encoder model to determine if the code change represents a risk to the repository if merged into the file, wherein the neural encoder model is given the code change and a context of the code change;
causing, by a second agent, a first language model to generate a code review comment for the code change when the neural encoder model determines that the code change represents a risk to the repository if merged into the file, wherein the first language model is given original source code of the code change, the code change and a context of the code change, wherein the code review comment for the code change comprises an issue with the code change and a suggestion for remedying the issue with the code change;
causing, by the second agent, the first language model to generate a severity score of the issue with the code change;
causing, by a third agent, a second language model to determine if the code review comment generated by the first language model having a high severity score of the issue with the code change includes a wrong suggestion, wherein the first language model and the second language model differ; and
outputting, by the third agent, the code review comment upon the second language model determining that the code review comment does not include the wrong suggestion,
wherein the first agent, the second agent, and the third agent are separate executable components invoked by a distinct Application Programming Interface (API).

### Claim 9 (depends on 8)

The computer-implemented method of claim 8, wherein the code change is formatted as a code diff hunk.

### Claim 10 (depends on 8)

The computer-implemented method of claim 8, wherein the context of the code change comprises a file-level context and a repo-level context.

### Claim 11 (depends on 8)

The computer-implemented method of claim 8, wherein the file-level context comprises an import statement, a global attribute, a signature of a class where the code change occurs, a method adjacent to or directly invoked in an area of the code change, and/or a method signature of another method in the file.

### Claim 12 (depends on 8)

The computer-implemented method of claim 8, wherein the repo-level context comprises a method signature in the file that is defined in another file of the repository.

### Claim 13 (depends on 8)

The computer-implemented method of claim 8, wherein the wrong suggestion indicates a modification already existing in the code change.

### Claim 14 (depends on 8)

The computer-implemented method of claim 8, wherein the wrong suggestion indicates that a code element is not defined in the original source code of the code change.

### Claim 15 (depends on 8)

The computer-implemented method of claim 8, wherein a wrong suggestion indicates that a code element is not used in the original source code of the code change.

### Claim 16

A hardware storage device having stored thereon computer executable instructions that are structured to be executable by a processor of a computing device to thereby cause the computing device to generate a code review comment by performing actions that:
obtain a code change to a file of a repository;
cause, by a first agent, a neural encoder model to determine if the code change represents a risk to the repository if merged into the file, wherein the neural encoder model is given the code change and a context of the code change;
cause, by a second agent, a first language model to generate a code review comment for the code change when the neural encoder model determines that the code change represents a risk to the repository if merged into the file, wherein the first language model is given original source code of the code change, the code change and a context of the code change, wherein the code review comment for the code change comprises an issue with the code change and a suggestion for remedying the issue with the code change;
cause, by the second agent, the first language model to generate a severity score of the issue with the code change;
cause, by a third agent, a second language model to determine if the code review comment generated by the first language model having a high severity score of the issue with the code change includes a wrong suggestion, wherein the first language model and the second language model differ; and
output, by the third agent, the code review comment upon the second language model determining that the code review comment does not include the wrong suggestion,
wherein the first agent, the second agent, and the third agent are separate executable software components invoked by a distinct Application Programming Interface (API).

### Claim 17 (depends on 16)

The hardware storage device of claim 16 having stored thereon computer executable instructions that are structured to be executable by a processor of a computing device to thereby cause the computing device to perform actions that:
transform the code change into a code diff format.

### Claim 18 (depends on 16)

The hardware storage device of claim 16, wherein the context of the code change comprises a file-level context and a repo-level context.

### Claim 19 (depends on 18)

The hardware storage device of claim 18, wherein the file-level context comprises an import statement, a global attribute, a signature of a class where the code change occurs, a method adjacent to or directly invoked in an area of the code change, and/or a method signature of another method in the file.

### Claim 20 (depends on 18)

The hardware storage device of claim 18, wherein the repo-level context comprises a method signature in the file that is defined in another file of the repository.
