Fix custom agents being unselectable

What does this MR do and why?

This MR fixes the issue where custom agents are not able to be selected in Duo Agentic Chat.

Note, this solution fixes the problem directly, but the real solution should be to refactor new_chat_button.vue to use the agents that have been mapped in duo_agentic_chat.vue. The bug is due to a disconnect between the agents that are mapped in duo_agentic_chat.vue and the new_chat_button.vue component. So when the agent was passed into prepareAgentSelection it did not have the pinnedItemVersionId attribute.

References

Screenshots or screen recordings

Problem from @fsieverding in Slack:

GMT20251126-135722_Recording_1920x1050

Fix in this MR:

qa-demo

How to set up and validate locally

Enable the following feature flag.

Feature.enable(:global_ai_catalog)

If you don't have a project and group that are set up to work with Duo, you can apply this patch locally to use any project or group for these QA steps.

diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb
index 6646ac352bea..8e14694226ae 100644
--- a/ee/app/models/ee/project.rb
+++ b/ee/app/models/ee/project.rb
@@ -630,6 +630,7 @@ def suggested_reviewers_available?
       end

       def ai_catalog_available?
+        return true
         duo_features_enabled && ::Gitlab::Llm::StageCheck.available?(self, :ai_catalog)
       end
       strong_memoize_attr :ai_catalog_available?
diff --git a/ee/app/policies/ee/group_policy.rb b/ee/app/policies/ee/group_policy.rb
index d246f3ddecf5..5ae37ea97eae 100644
--- a/ee/app/policies/ee/group_policy.rb
+++ b/ee/app/policies/ee/group_policy.rb
@@ -353,6 +353,7 @@ module GroupPolicy
       end

       condition(:ai_catalog_available, scope: :subject) do
+        next true
         @subject.duo_features_enabled && ::Gitlab::Llm::StageCheck.available?(@subject, :ai_catalog)
       end

Visit http://gdk.test:3000/explore/ai-catalog/agents/ and create a new agent if you don't have one alread.

Enable the agent for your project.

You should be able to select the agent in Duo Agentic Chat.

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.

Edited by Luke Duncalfe

Merge request reports

Loading