feature flag
**Feature flags** (also called feature toggles) are a software engineering technique that allows you to **enable or disable functionality at runtime** without deploying new code. In AI systems, feature flags provide control over model versions, prompt configurations, safety settings, and experimental features.
**How Feature Flags Work**
- **Flag Definition**: Define a boolean or configuration flag (e.g., `use_new_model`, `enable_streaming`, `safety_level`).
- **Runtime Check**: Application code checks the flag value and executes the appropriate code path.
- **Remote Configuration**: Flag values are managed through a central service, allowing instant changes without redeployment.
**Feature Flags in AI Applications**
- **Model Switching**: Toggle between model versions (GPT-4 vs GPT-4o) without code changes.
- **Prompt Variants**: A/B test different system prompts or prompt templates.
- **Safety Controls**: Instantly tighten or relax content filters in response to emerging issues.
- **Feature Rollout**: Gradually enable new capabilities (tool calling, image generation) to subsets of users.
- **Kill Switches**: Immediately disable a misbehaving feature or model without a full deployment.
- **Cost Control**: Switch to cheaper models during high-traffic periods or budget constraints.
**Types of Feature Flags**
- **Release Flags**: Control the rollout of new features (enable for 10% of users, then 50%, then 100%).
- **Experiment Flags**: Support A/B testing and experimentation (which prompt template performs better?).
- **Ops Flags**: Operational controls for managing system behavior (enable rate limiting, switch to fallback model).
- **Permission Flags**: Control access to premium features based on user tier or subscription.
**Feature Flag Services**
- **LaunchDarkly**: Enterprise feature management platform.
- **Unleash**: Open-source feature flag system.
- **Flagsmith**: Open-source with both cloud and self-hosted options.
- **AWS AppConfig**, **GCP Feature Flags**: Cloud-native feature flag services.
**Best Practices**
- **Clean Up Old Flags**: Remove flags for fully rolled-out features to avoid code complexity.
- **Default Safe**: Flag defaults should always be the safe/existing behavior.
- **Monitor Flag Impact**: Track metrics by flag state to measure the impact of changes.
Feature flags are a **must-have for production AI systems** — they provide the control plane for managing model behavior without the risk of full deployments.