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)

Screencast

How to set up and validate locally

  1. Start up GDK in self hosted mode with DAP: https://gitlab-org.gitlab.io/gitlab-development-kit/howto/ai/duo_agent_platform/
  2. Set relative_url_root: /gdk-instance in gdk.yml, then gdk reconfigure && gdk restart.
  3. Rebuild Workhorse: make gitlab-workhorse (after you checkout this MR)
  4. Configure self hosted models and set a self hosted model for agentic flows
    1. https://docs.gitlab.com/development/ai_features/developing_ai_features_for_duo_self_hosted/
    2. https://docs.gitlab.com/user/duo_agent_platform/agents/foundational_agents/?tab=For+GitLab.com
  5. Setup Developer flow foundational agent for project gitlab-duo/test
  6. Go to the group/project gitlab-duo/test
  7. Go to an open issue and write this commnt: @duo-developer-gitlab-duo create an mr to implement this
  8. 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)

Edited by Newvick Lee

Merge request reports

Loading
Loading