Simulate warden session data in CompletionsWorker
The following discussion from !157566 (merged) should be addressed:
-
@bdenkovych started a discussion: (+11 comments)
You could consider extending your MR by
diff --git ee/app/workers/llm/completion_worker.rb ee/app/workers/llm/completion_worker.rb index af200dc9e293..3dc54f8fa990 100644 --- ee/app/workers/llm/completion_worker.rb +++ ee/app/workers/llm/completion_worker.rb @@ -38,6 +38,9 @@ def perform_for(message, options = {}) end def perform(prompt_message_hash, options = {}) + # Session is always present for this job as per https://gitlab.com/gitlab-org/gitlab/-/merge_requests/157566 + Gitlab::Session.current['warden.user.user.key'] = User.serialize_into_session(USER-RECORD-WHO-INITIATED-CompletionWorker) + ai_prompt_message = self.class.deserialize_message(prompt_message_hash, options) Gitlab::Llm::Tracking.event_for_ai_message(
as described in !156934 (comment 1973160023) to keep the behavior you want for this job that is scheduled by sessionless activity, but I don't think it is right direction.
Edited by Mark Chao