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
- 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
- Type:
- Feature flag propagation via
x-gitlab-enabled-feature-flagsheader:ee/lib/api/code_suggestions.rb— code completions and generationsee/lib/api/helpers/duo_workflow_helpers.rb— Duo Workflow requestsee/lib/gitlab/llm/completions/chat.rb— Duo Chat requests
- 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_modelsis not pushed (consistent withexpanded_ai_loggingbehavior)
- Extended the self-managed cloud-connected test to also verify
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
- Issue: #598607 (closed)
- Epic: gitlab-org/modelops/applied-ml/code-suggestions&39
- Rollout Issue: #601113
Screenshots or screen recordings
N/A — backend-only change
How to set up and validate locally
-
Enable the feature flag in rails console:
Feature.enable(:ai_gateway_multi_default_models) -
Make a code suggestion or Duo Chat request and verify the
x-gitlab-enabled-feature-flagsheader sent to AI Gateway includesai_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.