Fix Duo agent developer flow on relative-URL instances
What does this MR do and why?
Fixes the Duo agent developer flow failing on GitLab instances served under a relative URL (e.g. https://example.com/gitlab instead of a bare domain). Two independent relative-URL bugs blocked the flow end-to-end.
Bugs fixed
1. WebSocket upgrade rejected with 403
The ai_workflows scope check for the Duo Workflow WebSocket endpoint used an exact path comparison (request.path.eql?('/api/v4/ai/duo_workflows/ws')). On a relative-URL instance request.path includes the URL root (/gitlab/api/v4/ai/duo_workflows/ws), so the match failed, the scope wasn't granted, and the upgrade returned 403, the workflow could never connect.
Switched to using URI
2. glab CLI configured without the URL root
The generated glab config used only host+port for api_host, dropping the relative URL root. Every glab API call (MR creation, issue reads, threaded replies) hit the wrong base URL and failed, so the flow ran but never produced an MR.
Now sets glab's first-class subfolder field to the relative URL root while keeping api_host/the hosts: key host-only (so it still matches the git remote). The field is omitted entirely on root-path instances, leaving their config unchanged.
References
Depends on !244021 (merged)
- RFH that kicked off the work streams https://gitlab.com/gitlab-com/request-for-help/-/work_items/4857#note_3431715421
- Duo Chat (Agentic) WebSocket connection fails w... (#588861 - closed)
Screencast
How to set up and validate locally
- Start up GDK in self hosted mode with DAP: https://gitlab-org.gitlab.io/gitlab-development-kit/howto/ai/duo_agent_platform/
- Set
relative_url_root: /gdk-instanceingdk.yml, thengdk reconfigure && gdk restart. - Rebuild Workhorse:
make gitlab-workhorse(after you checkout this MR) - Configure self hosted models and set a self hosted model for agentic flows
- Setup Developer flow foundational agent for project
gitlab-duo/test - Go to the group/project
gitlab-duo/test - Go to an open issue and write this commnt: @duo-developer-gitlab-duo
create an mr to implement this - See that it creates an MR properly
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.
Closes #588861 (closed) and gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#2071 (closed)