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
- In
DuoCodeReviewChatWorker#perform, before starting the chat flow, we callcode_review_intent?(note) - This strips
@mentionsfrom the note, then calls theClassifyCodeReviewMentionIntentAI Gateway completion with the message text - If the intent is
code_review_request:- If a review is already in progress → reply with an in-progress message and return
- If
@GitLabDuois already a reviewer → callRequestReviewServiceto re-request - Otherwise → call
UpdateReviewersServiceto assign@GitLabDuoas reviewer
- Both services route to DAP or classic via
request_duo_code_reviewin the EE override — no manual branching needed - 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) |
|---|---|
![]() |
![]() |
Intent: duo_developer (just uses the current classic chat for now) |
Intent: agentic_chat (just uses the current classic chat for now) |
|---|---|
![]() |
![]() |
Intent: code_review_request (multiple reviews) |
|---|
![]() |
How to set up and validate locally
-
Enable the feature flag:
Feature.enable(:classify_code_review_mention_intent) -
Test scenarios on any MR:
Scenario Comment Expected Result Code review request @GitLabDuo please review this MRAdds 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 testFalls back to chat flow Agentic chat intent @GitLabDuo what does this code do?Falls back to chat flow -
Disable the flag to verify fallback:
Feature.disable(:classify_code_review_mention_intent)All
@GitLabDuomentions 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:




