Agent Platform Model Selection
Agent Platform Model Selection
What This MR Does
Implements dynamic model configuration for GitLab Duo Agent Platform, enabling instance-level AI model selection with self-hosted model support.
Key Changes
-
Model Metadata Service: New
ModelMetadata
service retrieves and formats model configuration from instance-level feature settings -
Feature Flag Integration: Added
agent_platform_model_selection
development flag with global enablement -
Instance Feature Settings: Extended
Ai::FeatureSetting
to supportduo_agent_platform
feature -
Agent Platform Integration: Injects model metadata via
x-gitlab-self-hosted-models-metadata
header to agent platform endpoints
Model Support
-
GitLab Models: Instance-level selection (e.g.,
claude-3-7-sonnet-20250219
) - Self-Hosted Models: Custom OpenAI-compatible endpoints with API key protection
- Amazon Q: Global role ARN configuration support
Instance-Level Architecture
Instance-level feature settings provide centralized model configuration for all agent platform operations. This architecture allows administrators to:
- Configure self-hosted models globally
- Set default model providers for all users
- Manage API keys and endpoints centrally
- Future Enhancement: Add user-level overrides when needed
Technical Flow
graph TD
A[Agent Platform Request] --> B[Feature Flag Check]
B --> C{Flag Enabled?}
C -->|No| D[Return nil]
C -->|Yes| E[Instance Feature Setting Lookup]
E --> F[duo_agent_platform Setting]
F --> G[Model Metadata Generation]
G --> H{Metadata Present?}
H -->|No| I[Return nil]
H -->|Yes| J[Header Injection]
J --> K[Agent Platform Service]
I --> L[Standard Operation]
K --> M[Model-Aware Operation]
- Global feature flag validation (
agent_platform_model_selection
) - Instance-level
duo_agent_platform
feature setting lookup - Model metadata extraction from feature setting
- JSON header injection to Agent Platform Service
Feature Configuration
-
Feature:
duo_agent_platform
(ID: 15) inSTABLE_FEATURES
-
Flag:
agent_platform_model_selection
- Development flag (default disabled) - Scope: Instance-level configuration applies to all agent platform operations
Self-Hosted Models
Self-hosted models are configured at the instance level through Ai::FeatureSetting
records. Administrators can:
- Set custom OpenAI-compatible endpoints
- Configure API keys securely
- Define model identifiers
- Enable/disable specific features
Related to: #556159 (closed) and #556185 (closed)
Edited by Mohamed Hamda