Course contentsShow
← AI Engineering
Lesson 919 of 1,88622. Testing and CI/CD for AI SystemsFree lesson

Configuration Management and Feature Flags

Use feature flags to toggle between model versions, prompts, or RAG strategies without code deployments.

Configuration Management and Feature Flags

What You'll Learn

You'll learn how to use feature flags to safely toggle between different model versions, prompts, or RAG strategies in production without redeploying code.

The Core Idea

Imagine you've just refined a prompt or want to test a new model version. Without feature flags, you'd need to deploy new code, wait for pipelines, and hope nothing breaks. Feature flags let you flip a switch and instantly change which prompt, model, or retrieval strategy your system uses—no deployment required.

A feature flag is simply a configuration value (often stored remotely) that your application checks at runtime. If the flag is true, use the new behavior; if false, stick with the old one.

Why This Matters for AI Systems

AI systems have multiple configuration dimensions: model versions (gpt-4 vs. gpt-4-turbo), prompt templates (v1 vs. v2), embedding models, retrieval strategies (semantic search vs. hybrid), and more. Feature flags let you:

  • Toggle instantly between configurations without waiting for CI/CD
  • Test with specific users by enabling flags for a subset
  • Rollback immediately if something goes wrong
  • Run experiments by directing traffic to different configurations

You've already learned about canary releases and blue-green deployments—feature flags are the mechanism that makes those patterns work smoothly.

Simple Pattern

# Configuration checked at runtime
if feature_flags.is_enabled("use_new_prompt_v2"):
    prompt = PROMPT_TEMPLATE_V2
else:
    prompt = PROMPT_TEMPLATE_V1

# Or for model selection
model_name = config.get("model_version", default="gpt-4")

Your configuration might come from environment variables, a remote service like LaunchDarkly, or your model registry.

Key Takeaway: Feature flags decouple configuration changes from code deployments, letting you safely test and toggle AI system behaviors in production without redeploying code.