Add credit limitation support for GitLab Duo Agentic Chat

What does this MR do and why?

Will resolve: https://gitlab.com/gitlab-org/gitlab/-/work_items/581700

Implements credit limitation support for GitLab Duo Agentic Chat. This enables the chat to gracefully handle and display appropriate messaging when GitLab credits are exhausted.

Early Demo: https://gitlab.com/gitlab-org/gitlab/-/issues/581064#note_2918469425

empty thread active thread
Screenshot_2025-12-04_at_21.47.14 Screenshot_2025-12-04_at_21.47.29

How to test

Scenario 1: No credits available on page load

Apply the following patch to simulate zero credits:

  diff --git a/ee/app/views/layouts/_duo_chat_panel.html.haml b/ee/app/views/layouts/_duo_chat_panel.html.haml
  index d117b45378d6..8ee0da999cea 100644
  --- a/ee/app/views/layouts/_duo_chat_panel.html.haml
  +++ b/ee/app/views/layouts/_duo_chat_panel.html.haml
  @@ -5,5 +5,6 @@
     - duo_scope_hash = ::Gitlab::Llm::TanukiBot.duo_scope_hash(current_user, @project, @group, controller_name)
     - project = duo_scope_hash[:project]
     - group = duo_scope_hash[:namespace]
  +  - credits_available = false
     .paneled-view.ai-panels.-gl-mb-3.lg:gl-mb-0
  -    #duo-chat-panel.duo-chat-panel{ data: duo_chat_panel_data(current_user, project, group) }
  +    #duo-chat-panel.duo-chat-panel{ data: duo_chat_panel_data(current_user, project, group).merge(credits_available:
  credits_available.to_s) }
  • Opening GitLab Duo Agentic Chat displays a custom empty state with the Tanuki icon and "No GitLab Credits remain" message. Input is disabled, Threads from History display no credits available banner.

Scenario 2: User runs out of credits mid-conversation

  • Revert the patch from Scenario 1
  • Cherry-pick the commits from !214713 (merged)
  • Follow the instructions provided in: !214713 (merged) to trigger the websocket error
  • Send a prompt

The chat goes into the same blocked state as described above.

Edited by Jannik Lehmann

Merge request reports

Loading