Back to Gitlabhq

GitLab Duo in merge requests

doc/user/project/merge_requests/duo_in_merge_requests.md

19.2.016.1 KB
Original Source

[!disclaimer]

GitLab Duo is designed to provide contextually relevant information during the lifecycle of a merge request.

Generate a description by summarizing code changes

{{< details >}}

  • Tier: Premium, Ultimate
  • Add-on: GitLab Duo Enterprise
  • Offering: GitLab.com, GitLab Self-Managed
  • Status: Beta

{{< /details >}}

{{< collapsible title="Model information" >}}

{{< /collapsible >}}

{{< history >}}

  • Introduced in GitLab 16.2 as an experiment.
  • Changed to beta in GitLab 16.10.
  • Changed to require GitLab Duo add-on in GitLab 17.6 and later.
  • LLM updated to Claude 3.7 Sonnet in GitLab 17.10
  • Feature flag add_ai_summary_for_new_mr enabled by default in GitLab 17.11.
  • Changed to include Premium in GitLab 18.0.
  • LLM updated to Claude 4.0 Sonnet in GitLab 18.1.

{{< /history >}}

When you create or edit a merge request, use GitLab Duo Merge Request Summary to create a merge request description.

  1. Create a new merge request.

  2. In the Description field, put your cursor where you want to insert the description.

  3. On the toolbar above the text area, select Summarize code changes ({{< icon name="tanuki-ai" >}}).

The description is inserted where your cursor was.

<i class="fa-youtube-play" aria-hidden="true"></i> Watch an overview

Provide feedback on this feature in issue 443236.

Data usage: The diff of changes between the source branch's head and the target branch is sent to the large language model.

Use GitLab Duo to review your code

GitLab Duo can review your merge request for potential errors and provide feedback on alignment to standards.

When you request a review from GitLab Duo, it automatically runs one of two code review features based on your add-on. Users with the Owner role for the group can configure which feature runs for all users.

DetailCode Review FlowGitLab Duo Code Review
Reviewer@GitLabDuo@GitLabDuo
TypeAgenticNon-agentic
Required add-onNone. Uses GitLab Credits.GitLab Duo Enterprise
Context awarenessEnhanced understanding of repository structure and cross-file dependenciesFocused on the merge request and the file diffs within it
AnalysisMulti-step agentic reasoningSingle-pass
Session creation{{< yes >}}{{< no >}}
Automatic reviews{{< yes >}}{{< yes >}}
Custom instructions{{< yes >}}{{< yes >}}
Custom comments{{< yes >}}{{< yes >}}

Determine which review feature runs

By default, the code review feature that GitLab runs depends on the user that initiates the review.

Review triggerInitiating user
Review requested manuallyThe user who requests the review.
Merge request created (not a draft)The merge request author.
Draft merge request marked as readyThe merge request author.

If the initiating user has a GitLab Duo Enterprise seat, GitLab Duo Code Review runs. If not, Code Review Flow runs. Both features can run in the same project.

Users with the Owner role for the group can configure all reviews to use Code Review Flow, regardless of seat type. When Code Review Flow runs, credit usage is attributed to the initiating user.

To determine which feature runs a review, check the merge request's activity feed. Code Review Flow starts a review session when it runs. If no review session appears, GitLab Duo Code Review runs the review.

After the review completes, you can also look for a Code Review Flow session in sessions for your project.

Turn on Code Review Flow for GitLab Duo Enterprise seats

{{< history >}}

{{< /history >}}

[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.

To prevent GitLab Duo Enterprise seat holders from using a feature that consumes GitLab Credits, all code reviews they initiate use GitLab Duo Code Review by default. This behavior occurs even if a user with the Owner role turns on Code Review Flow for the group.

You can change this default and configure all code reviews to use Code Review Flow instead, regardless of the user's seat.

To override the default code review feature for GitLab Duo Enterprise seats:

{{< tabs >}}

{{< tab title="GitLab.com" >}}

Prerequisites:

  • The Owner role for the top-level group.
  • Code Review Flow turned on and configured correctly for your top-level group.
  1. In the top bar, select Search or go to and find your top-level group.
  2. Select Settings > GitLab Duo.
  3. Select Change configuration.
  4. Under Flow execution > Allow foundational flows, clear the Code Review Flow checkbox and then select it again.
  5. In the confirmation dialog, select Enable Code Review Flow.

{{< /tab >}}

{{< tab title="GitLab Self-Managed and GitLab Dedicated" >}}

Prerequisites:

  • The Maintainer or Owner role for the group.
  • Code Review Flow turned on and configured correctly for the instance.
  1. In the top bar, select Search or go to and find your group or subgroup.
  2. Select Settings > General.
  3. Expand GitLab Duo features.
  4. Under Flow execution, clear the Code Review Flow checkbox, and select Save changes.
  5. Expand GitLab Duo features again and, under Flow execution, select the Code Review Flow checkbox.
  6. In the confirmation dialog, select Enable Code Review Flow.
  7. Select Save changes.

{{< /tab >}}

{{< /tabs >}}

Code Review Flow now runs for all code reviews in the group and consumes GitLab Credits. To switch all reviews back to GitLab Duo Code Review, turn off Code Review Flow.

Resolve a discussion with GitLab Duo

{{< details >}}

  • Tier: Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
  • Status: Beta

{{< /details >}}

{{< history >}}

{{< /history >}}

Use GitLab Duo to resolve review discussions on merge requests.

When you ask GitLab Duo to resolve a discussion, it reads the review comment and the surrounding code, makes the requested change on the source branch, then commits and pushes the change. GitLab Duo then replies to the discussion with a summary of the change and resolves the thread.

This feature uses the Developer Flow on the GitLab Duo Agent Platform.

Prerequisites:

To resolve a discussion with GitLab Duo:

  1. In the merge request, go to an unresolved discussion.
  2. Next to Resolve thread, select More resolve options ({{< icon name="chevron-down" >}}).
  3. Select Resolve with GitLab Duo.

GitLab Duo starts a session you can track in the sessions for your project.

Summarize a code review

{{< details >}}

  • Tier: Premium, Ultimate
  • Add-on: GitLab Duo Enterprise
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
  • Status: Experiment

{{< /details >}}

{{< collapsible title="Model information" >}}

{{< /collapsible >}}

{{< history >}}

  • Introduced in GitLab 16.0 as an experiment.
  • Feature flag summarize_my_code_review enabled by default in GitLab 17.10.
  • LLM updated to Claude 3.7 Sonnet in GitLab 17.11.
  • Changed to include Premium in GitLab 18.0.
  • LLM updated to Claude 4.0 Sonnet in GitLab 18.1.

{{< /history >}}

When you've completed your review of a merge request and are ready to submit your review, use GitLab Duo Code Review Summary to generate a summary of your comments.

  1. In the top bar, select Search or go to and find your project.
  2. In the left sidebar, select Code > Merge requests and find the merge request you want to review.
  3. When you are ready to submit your review, select Finish review.
  4. Select Add Summary.

The summary is displayed in the comment box. You can edit and refine the summary before you submit your review.

<i class="fa-youtube-play" aria-hidden="true"></i> Watch an overview

Provide feedback on this experimental feature in issue 408991.

Data usage: When you use this feature, the following data is sent to the large language model:

  • Draft comment's text

Generate a merge commit message

{{< details >}}

  • Tier: Premium, Ultimate
  • Add-on: GitLab Duo Enterprise, GitLab Duo with Amazon Q
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

{{< /details >}}

{{< collapsible title="Model information" >}}

{{< /collapsible >}}

{{< history >}}

  • Introduced in GitLab 16.2 as an experiment with a feature flag named generate_commit_message_flag. Disabled by default.
  • Feature flag generate_commit_message_flag enabled by default in GitLab 17.2.
  • Feature flag generate_commit_message_flag removed in GitLab 17.7.
  • Changed to include Premium in GitLab 18.0.
  • LLM updated to Claude 4.0 Sonnet in GitLab 18.1.
  • Changed to support Amazon Q in GitLab 18.3.

{{< /history >}}

When preparing to merge your merge request, edit the proposed merge commit message by using GitLab Duo Merge Commit Message Generation.

  1. In the top bar, select Search or go to and find your project.
  2. In the left sidebar, select Code > Merge requests and find your merge request.
  3. Select the Edit commit message checkbox on the merge widget.
  4. Select Generate commit message.
  5. Review the commit message provided and choose Insert to add it to the commit.

<i class="fa-youtube-play" aria-hidden="true"></i> Watch an overview

Data usage: When you use this feature, the following data is sent to the large language model:

  • Contents of the file
  • The filename

Troubleshooting

When working with GitLab Duo in Merge Requests, you might encounter the following issues.

Response not received

If you ask GitLab Duo for a review by mentioning or replying to @GitLabDuo, and do not receive a response, this might be because you do not have the appropriate GitLab Duo add-on.

To check your GitLab Duo add-on, ask your group Owner to check the group's GitLab Duo seat assignments.

To change your GitLab Duo add-on, contact your administrator.

Unable to assign GitLab Duo to review

If you cannot assign GitLab Duo as a reviewer, it might be because you do not have the appropriate GitLab Duo add-on.

To check your GitLab Duo add-on, ask your group Owner to check the group's GitLab Duo seat assignments.

To change your GitLab Duo add-on, contact your administrator.

Error: GitLab Duo Code Review was not automatically added...

If you try to create a merge request with automatic reviews from GitLab Duo turned on, you might get the following error message:

plaintext
GitLab Duo Code Review was not automatically added because your account requires
GitLab Duo Enterprise. Contact your administrator to upgrade your account.

Contact your administrator to ask them to purchase a GitLab Duo Enterprise seat and assign it to you.