Classify "GitLabDuo" MR mention intent to route code review requests

What does this MR do and why?

When a user mentions @GitLabDuo in an MR comment, this MR classifies the intent of the message and routes code_review_request intents to the existing code review flow. All other intents (duo_developer, agentic_chat, or unknown) continue to use the existing Duo Chat flow unchanged.

This is behind the classify_code_review_mention_intent (gitlab_com_derisk) feature flag.

AIGW counterpart is already merged: feat: add classify_code_review_mention_intent p... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!5198 - merged)

How it works

  1. In DuoCodeReviewChatWorker#perform, before starting the chat flow, we call code_review_intent?(note)
  2. This strips @mentions from the note, then calls the ClassifyCodeReviewMentionIntent AI Gateway completion with the message text
  3. If the intent is code_review_request:
    • If a review is already in progress → reply with an in-progress message and return
    • If @GitLabDuo is already a reviewer → call RequestReviewService to re-request
    • Otherwise → call UpdateReviewersService to assign @GitLabDuo as reviewer
  4. Both services route to DAP or classic via request_duo_code_review in the EE override — no manual branching needed
  5. If classification fails for any reason → fall back to the chat flow (existing behaviour preserved)

Screenshots

Intent: code_review_request (GitLabDuo already added as a reviewer) Intent: code_review_request (GitLabDuo not already added as a reviewer yet)
review_-_bot_already_added review_-_bot_not_added
Intent: duo_developer (just uses the current classic chat for now) Intent: agentic_chat (just uses the current classic chat for now)
duo_developer chat
Intent: code_review_request (multiple reviews)
multiple_reviews

How to set up and validate locally

  1. Enable the feature flag:

    Feature.enable(:classify_code_review_mention_intent)
  2. Test scenarios on any MR:

    Scenario Comment Expected Result
    Code review request @GitLabDuo please review this MR Adds GitLabDuo as reviewer (or re-requests if already added)
    Review already in progress Same as above while review is running Replies "I'm already reviewing this merge request..."
    Duo Developer intent @GitLabDuo fix the failing test Falls back to chat flow
    Agentic chat intent @GitLabDuo what does this code do? Falls back to chat flow
  3. Disable the flag to verify fallback:

    Feature.disable(:classify_code_review_mention_intent)

    All @GitLabDuo mentions should use the existing chat flow.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to:

Edited by Kinshuk Singh

Merge request reports

Loading