Loading
Mount an uploader on Duo workflow session files
What does this MR do and why?
Create an endpoint to upload files tied to a workflow.
- Uses the newly added table from !261463 (merged) to store the file metadata.
- Uses direct upload to upload files faster through the websocket connection.
- Allows download of the file metadata with the base64 file contents.
References
Persistent file upload issue: #632837
Frontend MR: !263272 (merged)
AIGW MR: gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7549 (merged)
Out of scope/followups
- Block files from being uploaded to archived sessions.
Database
create_session_file!
create_session_file!In ee/lib/api/ai/duo_workflows/workflows.rb
INSERT INTO "duo_workflows_session_files" ("created_at", "updated_at", "workflow_id", "namespace_id", "size", "file", "content_type")
VALUES ('2026-10-20 09:42:15.329926', '2026-10-20 09:42:15.329926', 719, 1000000, 4772, 'dog_group.jpeg', 'image/jpeg')
RETURNING
"id"
find_session_file!
find_session_file!In ee/lib/api/ai/duo_workflows/workflows.rb
SELECT
"duo_workflows_workflows".*
FROM
"duo_workflows_workflows"
WHERE
"duo_workflows_workflows"."user_id" = 1
AND "duo_workflows_workflows"."id" = 717
LIMIT 1SELECT
"duo_workflows_session_files".*
FROM
"duo_workflows_session_files"
WHERE
"duo_workflows_session_files"."workflow_id" = 717
AND "duo_workflows_session_files"."id" = 22
LIMIT 1How to set up and validate locally
- Checkout !263272 (merged) which contains this code + frontend changes to upload files
- In AIGW checkout gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7549 (merged)
- From the GDK dir, run:
make -C gitlab/workhorse gitlab-workhorsegdk restart duo-workflow-service workhorse rails
- From rails console, enable:
Feature.enable(:dap_web_chat_file_attachments)Feature.enable(:duo_workflow_session_file_persistent_uploads)
- Open Duo Agentic chat and click the
+Icon in the bottom left - Upload a file and confirm
- The file was uploaded
Ai::DuoWorkflows::SessionFile.last
cat log/api_json.log | grep session_files- The last three should have:
- The file was uploaded
"status":200,"method":"POST","path":"/api/v4/ai/duo_workflows/workflows/701/session_files/authorize"
"status":201,"method":"POST","path":"/api/v4/ai/duo_workflows/workflows/701/session_files"
"status":200,"method":"GET","path":"/api/v4/ai/duo_workflows/workflows/701/session_files/6"- Disable
Feature.disable(:duo_workflow_session_file_persistent_uploads) - Reload the page, and send a new file
- No
Ai::DuoWorkflows::SessionFileshould be created, but Duo should still be able to view the file- In the network tab you should see the Base64 instead of the session file url:
Edited by Kaveh Nejad







