Fix Duo Agentic Chat for self-manged instances using a relative URL

What does this MR do and why?

Fixes Duo agentic chat failing in the web UI when GitLab is served under a relative URL (eg. https://example.com/gitlab).

On these instances, sending a chat msg fails with Not found "api/graphql". The reason is in Workhorse, when DWS (duo workflow service) uses Workhorse to make a GitLab api call, it sends a bare path like "/api/graphql". But Workhorse feeds that back into its own router which only recognizes paths that include the instance's URL prefix (eg. /gitlab). The prefix is missing, so chat breaks.

This MR prepends relative URL root to the DWS API paths before routing them, so /api/graphql becomes /gitlab/api/graphql. On instances served on the domain root, nothing happens.

Changes:

  • Pass instance's URL prefix into Duo Workflow action handler
  • Prepend it to action paths in buildRequest

References

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. Configure self hosted models and set a self hosted model for agentic chat
    1. https://docs.gitlab.com/development/ai_features/developing_ai_features_for_duo_self_hosted/
  3. Set relative_url_root: /gdk-instance in gdk.yml, then gdk reconfigure && gdk restart.
  4. Rebuild Workhorse: make gitlab-workhorse (after you checkout this MR)
  5. Open up agentic chat and send a msg. It should respond instead of erroring out

See screencast:

screencast_fix_dap_for_relative_url.webm

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.

Related to #588861 (closed)

Related to gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#2071 (closed)

Edited by Newvick Lee

Merge request reports

Loading
Loading