Skip to content

Allow DCR Interactions in non-diff threads

Background

In this comment it was identified that @GitLabDuo didn't respond to a thread because it was not a conversation on a diff. Currently this is intentional as we only want interactions to respond to diffs.

Ask

What is the behavior we want for interactions with DCR?

Interact with anything?

  • Should you be able to just generically ask it anything in a merge request?
  • How would you constrain that? Would you constrain that?

Interact only with review/diff comments?

  • How do you communicate that to users?
  • Should we return a comment/message?

Proposal

From the discussion below in #510161 (comment 2278432205):

Open the chat up and allow tagging GitLab Duo anywhere in a thread in MR page. We should also include all notes in the thread.

If thread is not a diff note, we shouldn't send the diff file as part of context we include during Duo Chat request.

Implementation

For non-diff notes, we will include the whole MR context by leveraging Duo Chat's Merge Request reader tool (ref: #510161 (comment 2324589687)). This is done by providing:

  • The merge request object as the context resource (see !180422 (diffs)).
  • The MR iid identifier in additional context as a fallback in case the LLM decides not to use a "current" identifier type (see !180422 (diffs)).

Possible next iteration ideas

  1. Consider passing in the MR object for diff notes as well. (See discussion in #510279 (comment 2333453086)).
  • Rationale: Sometimes Duo Chat decides it wants to use the MR Reader tool on a diff note, which currently results in an error message as explained in #510279 (comment 2332935508).
  1. Programatically "force" Duo Chat to always use the MR Reader tool for non-diff notes.
  • Rationale: Currently, we're influencing the LLM to use the tool, which is highly probable but not technically guaranteed.
  1. If latency becomes a concern, or we want another way to guarantee that the MR context is included, we could consider bypassing the MR Reader tool and injecting the MR context directly as part of additional_context.
  • Rationale: The LLM is not guaranteed to use the tool as mentioned in (2) above. Moreover, utilizing any reader tool makes Duo Chat execute another 1-2 round trips between the AI Gateway and client, which delays response time.
Edited by Leaminn Ma