Enable DCR interactions in non-diff threads & include MR context
What does this MR do and why?
Currently, Duo Code Review will only respond to @mentions in diff notes (aka comments) that DCR created as part of its review.
In this MR, we enable DCR to respond to mentions on non-diff notes. Details:
- For diff notes: We include diffs data as context to Duo Chat. This behaviour is unchanged.
- 
For non-diff notes: We include the full MR context by leveraging Duo Chat's merge_request_reader tool.
- We provide the MR's iid in a string format recognized by MergeRequestReader::Executor::SYSTEM_PROMPT, which helps to coerce the LLM into using the MR reader tool when necessary.
 
- We provide the MR's iid in a string format recognized by 
Further notes
In this iteration, we pass in the MR identifier via additional_context only for non-diff notes. In a future iteration, we could consider including the MR context for both diff and non-diff notes, and perhaps take a different approach (e.g. pass the MR request object as a resource per #510161 (comment 2328846020)). But this is currently out of scope for this issue.
References
- Resolves #510161 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
The following lists different places that you can mention @GitLabDuo in a comment on an MR.
How to set up and validate locally
- Follow these instructions to set up Duo features in your local environment. Additionally:
- DCR requires Duo Enterpriseadd-on.
- Enable FFs :ai_review_merge_requestand:duo_code_review_chat.
- Currently, DCR is only available in SaaS mode, but it's possible to test this on self-managed too bypassing the stage check:
See diff
--- a/ee/lib/gitlab/llm/stage_check.rb
+++ b/ee/lib/gitlab/llm/stage_check.rb
@@ -5,6 +5,7 @@ module Llm
     class StageCheck
       class << self
         def available?(container, feature)
+          return true
           root_ancestor = container.root_ancestor
 
           return false if personal_namespace?(root_ancestor)- 
Create a new project and open an MR request with code changes. 
- 
Mention @GitLabDuoin any MR comment and it should respond (usually within 20 seconds). You can do this before or after assigning@GitLabDuoto do the code review. Observe thatGitLabDuohas context about the MR.
Related to #510161 (closed)






