Model selection requires undocumented ai_model_switching feature flag on self-managed instances

Issue Description

Bug: Model selection requires ai_model_switching feature flag on self-managed instances despite documentation stating only instance_level_model_selection is needed

Summary

On GitLab self-managed instances, model selection functionality fails with the error "Model selection is not enabled" even when the documented instance_level_model_selection feature flag is enabled. The functionality only works after enabling the ai_model_switching feature flag, which according to documentation is specific to GitLab.com SaaS top-level groups.

Steps to Reproduce

  1. On a GitLab self-managed instance (18.4+)

  2. Verify instance_level_model_selection feature flag is enabled:

    Feature.enabled?(:instance_level_model_selection, :instance)
    # => true
  3. Attempt to use model selection functionality

  4. Observe error: "Model selection is not enabled"

  5. Enable ai_model_switching feature flag:

    Feature.enable(:ai_model_switching)
  6. Model selection now works

Expected Behavior

According to the documentation:

  • Self-managed: "Introduced in GitLab 18.4 with a flag named instance_level_model_selection. Enabled by default."
  • SaaS: "Introduced for top-level groups in GitLab 18.1 with a flag named ai_model_switching. Disabled by default."

Model selection should work on self-managed instances with only the instance_level_model_selection flag enabled.

Actual Behavior

Model selection requires both feature flags to be enabled on self-managed instances, despite ai_model_switching being documented as SaaS-specific.

Root Cause

The validation logic in ee/app/models/concerns/ai/model_selection/features_configurable.rb line 174-176 checks for ai_model_switching regardless of deployment type:

def model_selection_enabled?
  ::Feature.enabled?(:ai_model_switching, model_selection_scope)
end

This validation runs for all model selection operations and doesn't differentiate between SaaS and self-managed deployments.

Impact

  • Self-managed administrators cannot use model selection without enabling an undocumented feature flag
  • Documentation is misleading about required configuration
  • Feature flag separation between SaaS and self-managed is not properly implemented

Suggested Fix

The validation logic should check the appropriate feature flag based on deployment type:

  • Self-managed: Check instance_level_model_selection
  • SaaS: Check ai_model_switching for namespace scope
Edited by 🤖 GitLab Bot 🤖