From 00b79c09a4c02a7dcfc49026dd2e16edbc7edfb7 Mon Sep 17 00:00:00 2001
From: Jan Provaznik <jprovaznik@gitlab.com>
Date: Tue, 29 Aug 2023 10:35:55 +0200
Subject: [PATCH] Remove ai_chat_history_context feature flag

Previous chat conversation is added to chat AI requests by default.

Changelog: added
EE: true
---
 .../development/ai_chat_history_context.yml         |  8 --------
 ee/lib/ee/gitlab/gon_helper.rb                      |  2 --
 .../gitlab/llm/chain/agents/zero_shot/executor.rb   |  2 --
 .../frontend/ai/components/ai_genie_chat_spec.js    |  2 +-
 .../llm/chain/agents/zero_shot/executor_spec.rb     | 13 -------------
 5 files changed, 1 insertion(+), 26 deletions(-)
 delete mode 100644 ee/config/feature_flags/development/ai_chat_history_context.yml

diff --git a/ee/config/feature_flags/development/ai_chat_history_context.yml b/ee/config/feature_flags/development/ai_chat_history_context.yml
deleted file mode 100644
index f53a256fc8c52..0000000000000
--- a/ee/config/feature_flags/development/ai_chat_history_context.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-name: ai_chat_history_context
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122920
-rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/414606
-milestone: '16.1'
-type: development
-group: group::ai-enablement
-default_enabled: true
diff --git a/ee/lib/ee/gitlab/gon_helper.rb b/ee/lib/ee/gitlab/gon_helper.rb
index 3903a44a39861..5237ede69f2bc 100644
--- a/ee/lib/ee/gitlab/gon_helper.rb
+++ b/ee/lib/ee/gitlab/gon_helper.rb
@@ -27,8 +27,6 @@ def add_gon_variables
           gon.payment_form_url                 = ::Gitlab::Routing.url_helpers.subscription_portal_payment_form_url
           gon.payment_validation_form_id       = ::Gitlab::SubscriptionPortal::PAYMENT_VALIDATION_FORM_ID
         end
-
-        push_frontend_feature_flag(:ai_chat_history_context, current_user)
       end
 
       # Exposes if a licensed feature is available.
diff --git a/ee/lib/gitlab/llm/chain/agents/zero_shot/executor.rb b/ee/lib/gitlab/llm/chain/agents/zero_shot/executor.rb
index 937b462b00dd1..b6708fe8efdc9 100644
--- a/ee/lib/gitlab/llm/chain/agents/zero_shot/executor.rb
+++ b/ee/lib/gitlab/llm/chain/agents/zero_shot/executor.rb
@@ -120,8 +120,6 @@ def last_conversation
             strong_memoize_attr :last_conversation
 
             def conversation
-              return [] unless Feature.enabled?(:ai_chat_history_context, context.current_user)
-
               # include only messages with successful response and reorder
               # messages so each question is followed by its answer
               by_request = last_conversation
diff --git a/ee/spec/frontend/ai/components/ai_genie_chat_spec.js b/ee/spec/frontend/ai/components/ai_genie_chat_spec.js
index c610f479b8fab..3675e7899de24 100644
--- a/ee/spec/frontend/ai/components/ai_genie_chat_spec.js
+++ b/ee/spec/frontend/ai/components/ai_genie_chat_spec.js
@@ -16,7 +16,7 @@ describe('AiGenieChat', () => {
     data = {},
     scopedSlots = {},
     slots = {},
-    glFeatures = { aiChatHistoryContext: true },
+    glFeatures = {},
   } = {}) => {
     jest.spyOn(AiGenieLoader.methods, 'computeTransitionWidth').mockImplementation();
 
diff --git a/ee/spec/lib/gitlab/llm/chain/agents/zero_shot/executor_spec.rb b/ee/spec/lib/gitlab/llm/chain/agents/zero_shot/executor_spec.rb
index f96efa95fcb89..1e4b9e4e5df5a 100644
--- a/ee/spec/lib/gitlab/llm/chain/agents/zero_shot/executor_spec.rb
+++ b/ee/spec/lib/gitlab/llm/chain/agents/zero_shot/executor_spec.rb
@@ -167,19 +167,6 @@
       agent.prompt
     end
 
-    context 'when ai_chat_history_context is disabled' do
-      before do
-        stub_feature_flags(ai_chat_history_context: false)
-      end
-
-      it 'includes an empty chat' do
-        expect(Gitlab::Llm::Chain::Agents::ZeroShot::Prompts::Anthropic)
-          .to receive(:prompt).once.with(a_hash_including(conversation: []))
-
-        agent.prompt
-      end
-    end
-
     it 'includes the prompt' do
       expect(Gitlab::Llm::Chain::Agents::ZeroShot::Prompts::Anthropic)
         .to receive(:prompt).once.with(a_hash_including(prompt_version:
-- 
GitLab