Add ai_gateway_multi_default_models feature flag and propagate to AI Gateway

What does this MR do and why?

Implements the gitlab-rails side of the feature flag mechanism to control multi-default_models selection in the AI Gateway (issue #598607 (closed)).

Changes

  1. New feature flag (config/feature_flags/ops/ai_gateway_multi_default_models.yml):
    • Type: gitlab_com_derisk
    • Default: false (disabled — safe rollout)
    • Group: group::ai framework
  2. Feature flag propagation via x-gitlab-enabled-feature-flags header:
    • ee/lib/api/code_suggestions.rb — code completions and generations
    • ee/lib/api/helpers/duo_workflow_helpers.rb — Duo Workflow requests
    • ee/lib/gitlab/llm/completions/chat.rb — Duo Chat requests
  3. Test update (ee/spec/lib/gitlab/llm/completions/chat_spec.rb):
    • Extended the self-managed cloud-connected test to also verify ai_gateway_multi_default_models is not pushed (consistent with expanded_ai_logging behavior)

Rationale

The AI Gateway already has a mechanism to receive feature flags from gitlab-rails via the x-gitlab-enabled-feature-flags header. This MR adds the new flag to all three AI request paths so the AI Gateway can gate multi-model load balancing behind it.

The companion MR in the ai-assist repo reads this flag and uses it to decide whether to call random.choice(default_models) (flag enabled) or always use default_models[0] (flag disabled).

References

Screenshots or screen recordings

N/A — backend-only change

How to set up and validate locally

  1. Enable the feature flag in rails console:

    Feature.enable(:ai_gateway_multi_default_models)
  2. Make a code suggestion or Duo Chat request and verify the x-gitlab-enabled-feature-flags header sent to AI Gateway includes ai_gateway_multi_default_models.

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.

Edited by KG Gadgil

Merge request reports

Loading