Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(experiments): copy deprecated flag config to feature_flag object (#69457)

Anders13f4f1f9455e
diff --git a/ee/clickhouse/views/test/test_experiments_action_names.py b/ee/clickhouse/views/test/test_experiments_action_names.py
index 1409a97b4c71..4385c7eeb1e6 100644
--- a/ee/clickhouse/views/test/test_experiments_action_names.py
+++ b/ee/clickhouse/views/test/test_experiments_action_names.py
@@ -25,11 +25,15 @@ class TestExperimentActionNameRefresh(APILicensedTest):
"description": "Test experiment with action metric",
"type": "web",
"feature_flag_key": f"test-flag-{metrics_field}",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "Control", "rollout_percentage": 50},
- {"key": "test", "name": "Test", "rollout_percentage": 50},
- ]
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ }
+ }
},
metrics_field: [
{
@@ -81,11 +85,15 @@ class TestExperimentActionNameRefresh(APILicensedTest):
"description": "Test experiment with action ID type",
"type": "web",
"feature_flag_key": f"test-flag-{_name}",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "Control", "rollout_percentage": 50},
- {"key": "test", "name": "Test", "rollout_percentage": 50},
- ]
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ }
+ }
},
"metrics": [
{
@@ -130,11 +138,15 @@ class TestExperimentActionNameRefresh(APILicensedTest):
"description": "Test experiment with deleted action",
"type": "web",
"feature_flag_key": "test-flag-deleted",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "Control", "rollout_percentage": 50},
- {"key": "test", "name": "Test", "rollout_percentage": 50},
- ]
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ }
+ }
},
"metrics": [
{
@@ -187,11 +199,15 @@ class TestExperimentActionNameRefresh(APILicensedTest):
"description": "Test experiment with funnel action metrics",
"type": "web",
"feature_flag_key": f"test-flag-funnel-{metrics_field}",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "Control", "rollout_percentage": 50},
- {"key": "test", "name": "Test", "rollout_percentage": 50},
- ]
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ }
+ }
},
metrics_field: [
{
@@ -253,11 +269,15 @@ class TestExperimentActionNameRefresh(APILicensedTest):
"description": "Test experiment with ratio action metrics",
"type": "web",
"feature_flag_key": f"test-flag-ratio-{metrics_field}",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "Control", "rollout_percentage": 50},
- {"key": "test", "name": "Test", "rollout_percentage": 50},
- ]
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ }
+ }
},
metrics_field: [
{
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 5a7f616d0d83..ca348e76eccc 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -20763,21 +20763,10 @@
"ExperimentParameters": {
"additionalProperties": false,
"properties": {
- "feature_flag_variants": {
- "description": "Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20.",
- "items": {
- "$ref": "#/definitions/ExperimentVariant"
- },
- "type": "array"
- },
"minimum_detectable_effect": {
"description": "Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments.",
"type": "number"
},
- "rollout_percentage": {
- "description": "Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100.",
- "type": "number"
- },
"variant_notes": {
"additionalProperties": {
"type": "string"
@@ -21401,29 +21390,6 @@
],
"type": "object"
},
- "ExperimentVariant": {
- "additionalProperties": false,
- "properties": {
- "key": {
- "description": "Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'.",
- "type": "string"
- },
- "name": {
- "description": "Human-readable variant name.",
- "type": "string"
- },
- "rollout_percentage": {
- "deprecated": "Use split_percent instead. Accepted for backward compatibility.",
- "type": "number"
- },
- "split_percent": {
- "description": "Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided.",
- "type": "number"
- }
- },
- "required": ["key"],
- "type": "object"
- },
"ExperimentVariantFunnelsBaseStats": {
"additionalProperties": false,
"properties": {
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index ec010156c5ba..846902e669fc 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -4243,24 +4243,9 @@ export interface ExperimentApiMetric {
start_handling?: 'first_seen' | 'last_seen'
}
-export interface ExperimentVariant {
- /** Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'. */
- key: string
- /** Human-readable variant name. */
- name?: string
- /** @deprecated Use split_percent instead. Accepted for backward compatibility. */
- rollout_percentage?: number
- /** Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided. */
- split_percent?: number
-}
-
export interface ExperimentParameters {
- /** Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20. */
- feature_flag_variants?: ExperimentVariant[]
/** Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments. */
minimum_detectable_effect?: number
- /** Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100. */
- rollout_percentage?: number
/** Free-text notes per variant, keyed by variant key. Use to document what each variant does or its reroute URL. */
variant_notes?: Record<string, string>
}
diff --git a/posthog/schema.py b/posthog/schema.py
index 4a1be412d4c7..075e284a8f5c 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -1246,6 +1246,26 @@ class ExperimentMetricOutlierHandling(BaseModel):
)
+class ExperimentParameters(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ minimum_detectable_effect: float | None = Field(
+ default=None,
+ description=(
+ "Minimum detectable effect as a percentage. Lower values need more users"
+ " but catch smaller changes. Suggest 20–30% for most experiments."
+ ),
+ )
+ variant_notes: dict[str, str] | None = Field(
+ default=None,
+ description=(
+ "Free-text notes per variant, keyed by variant key. Use to document what"
+ " each variant does or its reroute URL."
+ ),
+ )
+
+
class ExperimentRunningTimeCalculation(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -1273,32 +1293,6 @@ class ExperimentRunningTimeCalculation(BaseModel):
)
-class ExperimentVariant(BaseModel):
- model_config = ConfigDict(
- extra="forbid",
- )
- key: str = Field(
- ...,
- description=(
- "Variant key. Exactly one variant in feature_flag_variants must use key"
- " 'control' (lowercase, exactly) — that is the baseline used for analysis"
- " and the special key the experiment runtime expects. Other variants use"
- " keys like 'test', 'variant_a', 'variant_b'. Map natural-language names"
- " ('original', 'A', 'baseline') to 'control'."
- ),
- )
- name: str | None = Field(default=None, description="Human-readable variant name.")
- rollout_percentage: float | None = None
- split_percent: float | None = Field(
- default=None,
- description=(
- "Percentage of users assigned to this variant (0–100). All variants must"
- " sum to 100. One of split_percent (recommended) or rollout_percentage must"
- " be provided."
- ),
- )
-
-
class ExperimentVariantFunnelsBaseStats(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -4581,42 +4575,6 @@ class ExperimentMetricBaseProperties(BaseModel):
version: float | None = Field(default=None, description="version of the node, used for schema migrations")
-class ExperimentParameters(BaseModel):
- model_config = ConfigDict(
- extra="forbid",
- )
- feature_flag_variants: list[ExperimentVariant] | None = Field(
- default=None,
- description=(
- "Experiment variants. If specified, must include a variant with key"
- " 'control' (lowercase). Defaults to a 50/50 control/test split when"
- " omitted. Minimum 2, maximum 20."
- ),
- )
- minimum_detectable_effect: float | None = Field(
- default=None,
- description=(
- "Minimum detectable effect as a percentage. Lower values need more users"
- " but catch smaller changes. Suggest 20–30% for most experiments."
- ),
- )
- rollout_percentage: float | None = Field(
- default=None,
- description=(
- "Overall rollout percentage (0-100). Controls what fraction of all users"
- " enter the experiment. Users outside the rollout never see any variant and"
- " are excluded from analysis. Default: 100."
- ),
- )
- variant_notes: dict[str, str] | None = Field(
- default=None,
- description=(
- "Free-text notes per variant, keyed by variant key. Use to document what"
- " each variant does or its reroute URL."
- ),
- )
-
-
class ExperimentStatsBase(BaseModel):
model_config = ConfigDict(
extra="forbid",
diff --git a/products/experiments/backend/experiment_service.py b/products/experiments/backend/experiment_service.py
index 7923846cac2b..edb11d9f4b28 100644
--- a/products/experiments/backend/experiment_service.py
+++ b/products/experiments/backend/experiment_service.py
@@ -273,9 +273,9 @@ class ExperimentService:
keys = [variant["key"] for variant in variants]
if "control" not in keys:
# Surface the keys we did receive so LLM callers can self-correct without a
- # second roundtrip. Capitalized 'Control' is auto-normalized in
- # ExperimentParametersField.to_internal_value, so anything reaching this
- # branch genuinely lacks a baseline variant.
+ # second roundtrip. Capitalized 'Control' is auto-normalized on the feature_flag
+ # input path (_normalized_flag_variants), so anything reaching this branch
+ # genuinely lacks a baseline variant.
raise ValidationError(
"Feature flag variants must contain a variant with key 'control' "
f"(lowercase, exactly). Got keys: {keys}. Rename the baseline variant's "
@@ -3196,7 +3196,11 @@ class ExperimentService:
if "holdout" in update_data:
holdout = update_data["holdout"]
- if update_data.get("parameters"):
+ # Only resync the flag from ``parameters`` when it actually carries flag-config keys.
+ # A read-modify-write PATCH that echoes non-flag params (e.g. variant_notes) alongside
+ # a stripped parameters dict must not reset the flag's variants to DEFAULT_VARIANTS.
+ params = update_data.get("parameters")
+ if params and any(key in params for key in self.FEATURE_FLAG_CONFIG_KEYS):
variants = update_data["parameters"].get("feature_flag_variants", [])
aggregation_group_type_index = update_data["parameters"].get("aggregation_group_type_index")
diff --git a/products/experiments/backend/presentation/serializers.py b/products/experiments/backend/presentation/serializers.py
index bbbcb734b64c..e88a1b376fab 100644
--- a/products/experiments/backend/presentation/serializers.py
+++ b/products/experiments/backend/presentation/serializers.py
@@ -7,7 +7,7 @@ ViewSet remains in experiments.py.
"""
from copy import deepcopy
-from typing import Any
+from typing import Any, TypeGuard
from drf_spectacular.utils import extend_schema_field
from opentelemetry import trace
@@ -106,11 +106,6 @@ class ExperimentParametersField(serializers.JSONField):
data = {**data, "feature_flag_variants": _with_split_percent(data["feature_flag_variants"])}
return data
- def to_internal_value(self, data: Any) -> Any:
- if isinstance(data, dict) and isinstance(data.get("feature_flag_variants"), list):
- data = {**data, "feature_flag_variants": _normalized_flag_variants(data["feature_flag_variants"])}
- return super().to_internal_value(data)
-
@extend_schema_field(ExperimentApiExposureCriteria) # type: ignore[arg-type]
class ExperimentExposureCriteriaField(serializers.JSONField):
@@ -161,9 +156,10 @@ class ExperimentBaseSerializer(UserAccessControlSerializerMixin, serializers.Mod
"Experiment parameters JSON. Supported keys include "
"`custom_exposure_filter` and `variant_notes` "
"(free-text notes per variant, keyed by variant key). "
- "Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated "
- "input surface kept for compatibility — the linked feature flag is the source of "
- "truth, and reads project its current config into this field. "
+ "Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs "
+ "on the `feature_flag` object; send it there. For backward compatibility, config still "
+ "sent through these deprecated keys is copied onto the linked flag rather than rejected, "
+ "and reads project the flag's current config back into this field. "
"Excluded variants live on the top-level `excluded_variants` field, not here."
),
)
@@ -360,9 +356,8 @@ class ExperimentSerializer(ExperimentBaseSerializer):
write_only=True,
help_text=(
"When true, sync the flag config sent in this request (via the "
- "`feature_flag` object, or the deprecated `parameters` keys) to "
- "the linked feature flag. Draft experiments always sync "
- "regardless. On a running experiment, `feature_flag` config "
+ "`feature_flag` object) to the linked feature flag. Draft experiments "
+ "always sync regardless. On a running experiment, `feature_flag` config "
"without this flag is rejected."
),
)
@@ -513,12 +508,17 @@ class ExperimentSerializer(ExperimentBaseSerializer):
read-only field. An object with no config keys at all (e.g. a ``{"key": ...}`` stub) is
likewise ignored rather than rejected, so clients that have always included such stubs in
write bodies keep working.
+
+ When no such object is present, a legacy caller may still be sending flag config through the
+ deprecated ``parameters`` keys. Rather than reject it, we copy it into the ``feature_flag``
+ object shape here so it flows through this same build/sync path (see
+ ``_deprecated_parameters_as_feature_flag_config``).
"""
feature_flag_input = (getattr(self, "initial_data", None) or {}).get("feature_flag")
- if not isinstance(feature_flag_input, dict) or feature_flag_input.get("id") is not None:
- return data
- if not any(key in feature_flag_input for key in ("filters", "ensure_experience_continuity")):
- return data
+ if not self._is_feature_flag_config_input(feature_flag_input):
+ feature_flag_input = self._deprecated_parameters_as_feature_flag_config()
+ if feature_flag_input is None:
+ return data
if self.instance is None:
# The service links an existing flag as-is (it may already serve traffic), so explicit
# config here would be applied nowhere — reject instead of silently dropping it.
@@ -564,9 +564,86 @@ class ExperimentSerializer(ExperimentBaseSerializer):
return data
def validate_parameters(self, value):
+ # Flag config is no longer a persisted `parameters` key; it is sourced from the linked flag
+ # (see ExperimentBaseSerializer._project_feature_flag_config). Strip any flag-config keys sent
+ # through `parameters` so they never reach the stored column; a legacy caller sending them is
+ # copied into the `feature_flag` path in _normalize_feature_flag_input instead of rejected.
+ value = ExperimentService._strip_feature_flag_config(value)
ExperimentService.validate_experiment_parameters(value)
return value
+ @staticmethod
+ def _is_feature_flag_config_input(feature_flag_input: Any) -> TypeGuard[dict]:
+ """Whether the request carries a genuine ``feature_flag`` config object (write intent), as
+ opposed to nothing, a read-only echo of the linked flag (non-null ``id``), or a bare stub
+ with no config keys."""
+ return (
+ isinstance(feature_flag_input, dict)
+ and feature_flag_input.get("id") is None
+ and any(key in feature_flag_input for key in ("filters", "ensure_experience_continuity"))
+ )
+
+ def _deprecated_parameters_as_feature_flag_config(self) -> dict | None:
+ """Copy flag config still sent through the deprecated ``parameters`` keys into a
+ ``feature_flag`` config object, so legacy callers flow through the same build/sync path as
+ the ``feature_flag`` object rather than being rejected. Read from ``initial_data`` because
+ ``validate_parameters`` has already stripped these keys from the validated parameters.
+
+ Returns ``None`` when ``parameters`` carries no flag config, or when every key merely echoes
+ the linked flag's current projected config — a read-modify-write no-op that must stay a
+ no-op (not resync the flag, not trip the running-experiment guard)."""
+ raw_parameters = (getattr(self, "initial_data", None) or {}).get("parameters")
+ if not isinstance(raw_parameters, dict):
+ return None
+ present = [key for key in ExperimentService.FEATURE_FLAG_CONFIG_KEYS if key in raw_parameters]
+ if not present:
+ return None
+
+ flag = self.instance.feature_flag if self.instance is not None else None
+ projected: dict[str, Any] = {}
+ if flag is not None:
+ projection: dict[str, Any] = {}
+ self._project_feature_flag_config(projection, flag)
+ projected = projection.get("parameters") or {}
+
+ changed = {
+ key: raw_parameters[key]
+ for key in present
+ if not self._flag_config_echo_matches(key, raw_parameters[key], projected.get(key))
+ }
+ if not changed:
+ return None
+ return self._feature_flag_config_object(changed) or None
+
+ @staticmethod
+ def _feature_flag_config_object(flag_config: dict[str, Any]) -> dict[str, Any]:
+ """Assemble a ``feature_flag`` config object (the flag's native write shape) from deprecated
+ ``parameters`` flag-config keys, so the shared feature_flag input path can consume them.
+ Mirrors the read projection's translation in reverse."""
+ filters: dict[str, Any] = {}
+ if "feature_flag_variants" in flag_config:
+ filters["multivariate"] = {"variants": flag_config["feature_flag_variants"]}
+ if flag_config.get("rollout_percentage") is not None:
+ filters["groups"] = [{"properties": [], "rollout_percentage": flag_config["rollout_percentage"]}]
+ if "aggregation_group_type_index" in flag_config:
+ filters["aggregation_group_type_index"] = flag_config["aggregation_group_type_index"]
+ if "feature_flag_payloads" in flag_config:
+ filters["payloads"] = flag_config["feature_flag_payloads"]
+ feature_flag_input: dict[str, Any] = {}
+ if filters:
+ feature_flag_input["filters"] = filters
+ if "ensure_experience_continuity" in flag_config:
+ feature_flag_input["ensure_experience_continuity"] = flag_config["ensure_experience_continuity"]
+ return feature_flag_input
+
+ @staticmethod
+ def _flag_config_echo_matches(key: str, sent: Any, projected: Any) -> bool:
+ if key == "feature_flag_variants":
+ # The read projection adds split_percent; normalize both sides to the flag's native
+ # shape (split_percent -> rollout_percentage) so a faithful echo compares equal.
+ return _normalized_flag_variants(sent or []) == _normalized_flag_variants(projected or [])
+ return sent == projected
+
def validate_running_time_calculation(self, value):
ExperimentService.validate_running_time_calculation(value)
return value
diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.py
index 0a06f1920ca7..8f69bb51286c 100644
--- a/products/experiments/backend/test/test_presentation_api.py
+++ b/products/experiments/backend/test/test_presentation_api.py
@@ -53,7 +53,72 @@ def _make(cls, **attrs):
return instance
-class TestExperimentCRUD(APILicensedTest):
+_FLAG_CONFIG_KEYS = (
+ "feature_flag_variants",
+ "rollout_percentage",
+ "aggregation_group_type_index",
+ "feature_flag_payloads",
+ "ensure_experience_continuity",
+)
+
+
+def _hoist_flag_config(payload: dict[str, Any]) -> dict[str, Any]:
+ """Test helper: rewrite an experiment write payload that sets up flag config through the
+ deprecated `parameters` keys into the `feature_flag` object the write API now requires. Non-flag
+ `parameters` keys are preserved, and any `feature_flag` already on the payload is merged into."""
+ parameters = payload.get("parameters")
+ if not isinstance(parameters, dict) or not any(key in parameters for key in _FLAG_CONFIG_KEYS):
+ return payload
+ payload = {**payload}
+ parameters = {**parameters}
+ feature_flag: dict[str, Any] = {**(payload.get("feature_flag") or {})}
+ filters: dict[str, Any] = {**(feature_flag.get("filters") or {})}
+ if "feature_flag_variants" in parameters:
+ filters["multivariate"] = {"variants": parameters.pop("feature_flag_variants")}
+ if "rollout_percentage" in parameters:
+ filters["groups"] = [{"properties": [], "rollout_percentage": parameters.pop("rollout_percentage")}]
+ if "aggregation_group_type_index" in parameters:
+ filters["aggregation_group_type_index"] = parameters.pop("aggregation_group_type_index")
+ if "feature_flag_payloads" in parameters:
+ filters["payloads"] = parameters.pop("feature_flag_payloads")
+ if "ensure_experience_continuity" in parameters:
+ feature_flag["ensure_experience_continuity"] = parameters.pop("ensure_experience_continuity")
+ if filters:
+ feature_flag["filters"] = filters
+ payload["feature_flag"] = feature_flag
+ payload["parameters"] = parameters
+ return payload
+
+
+class _HoistFlagConfigClientMixin:
+ """Flag config now belongs on the `feature_flag` object. The API still accepts it through the
+ deprecated `parameters` keys (copying it onto the object for backward compatibility), but many
+ fixtures in this file set it up via `parameters` as a convenience. This mixin transparently
+ relocates those keys on experiment create/update requests so setup exercises the explicit
+ `feature_flag` object path. Requests that already send a `feature_flag` object (or carry no flag
+ config) pass through untouched.
+
+ Tests that assert the deprecated-`parameters` copy behavior itself must NOT use this mixin — they
+ send the deprecated keys directly (see TestExperimentParametersFlagConfigCompatibility)."""
+
+ def setUp(self) -> None:
+ super().setUp() # type: ignore[misc]
+ real_post = self.client.post # type: ignore[attr-defined]
+ real_patch = self.client.patch # type: ignore[attr-defined]
+
+ def _wrap(method: Any) -> Any:
+ def wrapper(path: str, data: Any = None, *args: Any, **kwargs: Any) -> Any:
+ if isinstance(data, dict) and "/experiments/" in path.rstrip("/") + "/":
+ data = _hoist_flag_config(data)
+ return method(path, data, *args, **kwargs)
+
+ return wrapper
+
+ self.client.post = _wrap(real_post) # type: ignore[attr-defined]
+ self.client.patch = _wrap(real_patch) # type: ignore[attr-defined]
+
+
+class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):
# List experiments
def test_can_list_experiments(self):
response = self.client.get(f"/api/projects/{self.team.id}/experiments/")
@@ -2161,115 +2226,57 @@ class TestExperimentCRUD(APILicensedTest):
experiment = Experiment.objects.get(id=response.json()["id"])
self.assertFalse(experiment.is_draft)
- # Now try updating FF with a different variant count (original has 3, this has 2)
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{id}",
- {
- "description": "Bazinga",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "X", "rollout_percentage": 50},
- {"key": "test", "name": "Y", "rollout_percentage": 50},
- ]
+
+ def _patch_flag_variants(variants: list, extra: dict | None = None) -> Any:
+ return self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{id}",
+ {
+ "description": "Bazinga",
+ "update_feature_flag_params": True,
+ "feature_flag": {"filters": {"multivariate": {"variants": variants}}},
+ **(extra or {}),
},
- },
+ )
+
+ # Changing the variant count on a running experiment is rejected even with the opt-in.
+ response = _patch_flag_variants(
+ [
+ {"key": "control", "name": "X", "rollout_percentage": 50},
+ {"key": "test", "name": "Y", "rollout_percentage": 50},
+ ]
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- self.assertEqual(
- response.json()["detail"],
- "Can't update feature_flag_variants on Experiment",
- )
+ self.assertEqual(response.json()["detail"], "Can't update feature_flag_variants on Experiment")
- # Allow changing FF rollout %s
- created_ff = FeatureFlag.objects.get(key=ff_key)
- created_ff.filters = {
- **created_ff.filters,
- "multivariate": {
- "variants": [
- {
- "key": "control",
- "name": "Control Group",
- "rollout_percentage": 35,
- },
- {"key": "test_1", "name": "Test Variant", "rollout_percentage": 33},
- {"key": "test_2", "name": "Test Variant", "rollout_percentage": 32},
- ]
- },
- }
- created_ff.save()
-
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{id}",
- {
- "description": "Bazinga 222",
- "parameters": {
- "feature_flag_variants": [
- {
- "key": "control",
- "name": "Control Group",
- "rollout_percentage": 33,
- },
- {
- "key": "test_1",
- "name": "Test Variant",
- "rollout_percentage": 33,
- },
- {
- "key": "test_2",
- "name": "Test Variant",
- "rollout_percentage": 34,
- },
- ]
- },
- },
+ # Changing only the rollout percentages of the same variants is allowed with the opt-in.
+ response = _patch_flag_variants(
+ [
+ {"key": "control", "name": "Control Group", "rollout_percentage": 35},
+ {"key": "test_1", "name": "Test Variant", "rollout_percentage": 33},
+ {"key": "test_2", "name": "Test Variant", "rollout_percentage": 32},
+ ],
+ extra={"description": "Bazinga 222"},
)
- self.assertEqual(response.status_code, status.HTTP_200_OK)
- self.assertEqual(response.json()["parameters"]["feature_flag_variants"][0]["key"], "control")
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
self.assertEqual(response.json()["description"], "Bazinga 222")
created_ff = FeatureFlag.objects.get(key=ff_key)
-
- self.assertEqual(created_ff.key, ff_key)
self.assertEqual(created_ff.active, True)
- self.assertEqual(created_ff.filters["multivariate"]["variants"][0]["key"], "control")
self.assertEqual(created_ff.filters["multivariate"]["variants"][0]["rollout_percentage"], 35)
- self.assertEqual(created_ff.filters["multivariate"]["variants"][1]["key"], "test_1")
self.assertEqual(created_ff.filters["multivariate"]["variants"][1]["rollout_percentage"], 33)
- self.assertEqual(created_ff.filters["multivariate"]["variants"][2]["key"], "test_2")
self.assertEqual(created_ff.filters["multivariate"]["variants"][2]["rollout_percentage"], 32)
- # Now try changing FF keys
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{id}",
- {
- "description": "Bazinga",
- "parameters": {
- "feature_flag_variants": [
- {
- "key": "control",
- "name": "Control Group",
- "rollout_percentage": 33,
- },
- {
- "key": "test",
- "name": "Test Variant",
- "rollout_percentage": 33,
- },
- {
- "key": "test2",
- "name": "Test Variant",
- "rollout_percentage": 34,
- },
- ]
- },
- },
+ # Renaming variant keys on a running experiment is rejected even with the opt-in.
+ response = _patch_flag_variants(
+ [
+ {"key": "control", "name": "Control Group", "rollout_percentage": 33},
+ {"key": "test", "name": "Test Variant", "rollout_percentage": 33},
+ {"key": "test2", "name": "Test Variant", "rollout_percentage": 34},
+ ]
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- self.assertEqual(
- response.json()["detail"],
- "Can't update feature_flag_variants on Experiment",
- )
+ self.assertEqual(response.json()["detail"], "Can't update feature_flag_variants on Experiment")
- # Now try updating other parameter keys
+ # Non-flag parameter keys update independently of the flag.
response = self.client.patch(
f"/api/projects/{self.team.id}/experiments/{id}",
{"description": "Bazinga", "parameters": {"recommended_sample_size": 1500}},
@@ -2469,74 +2476,60 @@ class TestExperimentCRUD(APILicensedTest):
experiment = Experiment.objects.get(id=experiment_id)
self.assertEqual((experiment.parameters or {})["minimum_detectable_effect"], 30)
- def test_feature_flag_object_takes_precedence_over_parameters(self):
- # When both inputs are sent, the explicit feature_flag object wins over the legacy
- # parameters.feature_flag_variants.
- response = self.client.post(
+ def test_echoed_feature_flag_object_is_ignored_on_round_trip(self):
+ create = self.client.post(
f"/api/projects/{self.team.id}/experiments/",
{
- "name": "FF precedence",
- "feature_flag_key": "ff-precedence",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "rollout_percentage": 50},
- {"key": "ignored", "rollout_percentage": 50},
- ]
- },
+ "name": "FF echo",
+ "feature_flag_key": "ff-echo",
"feature_flag": {
"filters": {
"multivariate": {
"variants": [
{"key": "control", "rollout_percentage": 50},
- {"key": "winner", "rollout_percentage": 50},
+ {"key": "test", "rollout_percentage": 50},
]
}
}
},
},
)
- self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
- flag = FeatureFlag.objects.get(key="ff-precedence", team_id=self.team.id)
- self.assertEqual([v["key"] for v in flag.variants], ["control", "winner"])
-
- def test_echoed_feature_flag_object_is_ignored_on_round_trip(self):
- create = self.client.post(
- f"/api/projects/{self.team.id}/experiments/",
- {
- "name": "FF echo",
- "feature_flag_key": "ff-echo",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "rollout_percentage": 50},
- {"key": "test", "rollout_percentage": 50},
- ]
- },
- },
- )
self.assertEqual(create.status_code, status.HTTP_201_CREATED, create.json())
experiment_id = create.json()["id"]
# Read-modify-write client: the frontend spreads the whole GET response into the save,
- # including the serialized read-only flag (which carries `id`). The stale echo must not
- # override the edited `parameters` variants.
+ # including the serialized read-only flag (which carries `id`). That echo carries no write
+ # intent and must be ignored rather than reapplied.
echoed_flag = self.client.get(f"/api/projects/{self.team.id}/experiments/{experiment_id}").json()[
"feature_flag"
]
self.assertIn("id", echoed_flag)
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{experiment_id}",
+ {"description": "unrelated edit", "feature_flag": echoed_flag},
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ flag = FeatureFlag.objects.get(key="ff-echo", team_id=self.team.id)
+ self.assertEqual([v["rollout_percentage"] for v in flag.variants], [50, 50])
+
+ # A genuine edit through a config-only object (no `id`) is applied.
response = self.client.patch(
f"/api/projects/{self.team.id}/experiments/{experiment_id}",
{
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "rollout_percentage": 60},
- {"key": "test", "rollout_percentage": 40},
- ]
- },
- "feature_flag": echoed_flag,
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "rollout_percentage": 60},
+ {"key": "test", "rollout_percentage": 40},
+ ]
+ }
+ }
+ }
},
)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
- flag = FeatureFlag.objects.get(key="ff-echo", team_id=self.team.id)
+ flag.refresh_from_db()
self.assertEqual([v["rollout_percentage"] for v in flag.variants], [60, 40])
def test_partial_feature_flag_object_preserves_omitted_flag_config(self):
@@ -3441,132 +3434,44 @@ class TestExperimentCRUD(APILicensedTest):
},
)
- # Now try updating FF with a different variant count (original has 3, this has 2)
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{id}",
- {
- "description": "Bazinga",
- "parameters": {
- "feature_flag_variants": [
- {"key": "control", "name": "X", "rollout_percentage": 50},
- {"key": "test", "name": "Y", "rollout_percentage": 50},
- ]
- },
- },
- )
- self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- self.assertEqual(
- response.json()["detail"],
- "Can't update feature_flag_variants on Experiment",
- )
-
- # ensure cache doesn't change either
- cached_flags = get_feature_flags_for_team_in_cache(self.team.pk)
- assert cached_flags is not None
- self.assertEqual(1, len(cached_flags))
- self.assertEqual(cached_flags[0].key, ff_key)
- self.assertEqual(
- cached_flags[0].filters,
- {
- "groups": [
- {
- "properties": [],
- "rollout_percentage": 100,
- "aggregation_group_type_index": None,
- }
- ],
- "multivariate": {
- "variants": [
- {
- "key": "control",
- "name": "Control Group",
- "rollout_percentage": 33,
- },
- {
- "key": "test_1",
- "name": "Test Variant",
- "rollout_percentage": 33,
- },
- {
- "key": "test_2",
- "name": "Test Variant",
- "rollout_percentage": 34,
- },
- ]
- },
- "holdout": None,
- "aggregation_group_type_index": None,
+ # On a running experiment, a flag-config change without the opt-in is rejected and must not
+ # touch the cached flag.
+ unchanged_filters: dict[str, Any] = {
+ "groups": [{"properties": [], "rollout_percentage": 100, "aggregation_group_type_index": None}],
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "Control Group", "rollout_percentage": 33},
+ {"key": "test_1", "name": "Test Variant", "rollout_percentage": 33},
+ {"key": "test_2", "name": "Test Variant", "rollout_percentage": 34},
+ ]
},
- )
-
- # Now try changing FF rollout %s
+ "holdout": None,
+ "aggregation_group_type_index": None,
+ }
response = self.client.patch(
f"/api/projects/{self.team.id}/experiments/{id}",
{
"description": "Bazinga",
- "parameters": {
- "feature_flag_variants": [
- {
- "key": "control",
- "name": "Control Group",
- "rollout_percentage": 34,
- },
- {
- "key": "test_1",
- "name": "Test Variant",
- "rollout_percentage": 33,
- },
- {
- "key": "test_2",
- "name": "Test Variant",
- "rollout_percentage": 32,
- },
- ]
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": [
+ {"key": "control", "name": "X", "rollout_percentage": 50},
+ {"key": "test", "name": "Y", "rollout_percentage": 50},
+ ]
+ }
+ }
},
},
)
- # changing variants isn't really supported by experiments anymore, need to do it directly
- # on the FF
- self.assertEqual(response.status_code, status.HTTP_200_OK)
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+ self.assertIn("update_feature_flag_params", str(response.json()))
- # ensure cache doesn't change either
cached_flags = get_feature_flags_for_team_in_cache(self.team.pk)
assert cached_flags is not None
self.assertEqual(1, len(cached_flags))
self.assertEqual(cached_flags[0].key, ff_key)
- self.assertEqual(
- cached_flags[0].filters,
- {
- "groups": [
- {
- "properties": [],
- "rollout_percentage": 100,
- "aggregation_group_type_index": None,
- }
- ],
- "multivariate": {
- "variants": [
- {
- "key": "control",
- "name": "Control Group",
- "rollout_percentage": 33,
- },
- {
- "key": "test_1",
- "name": "Test Variant",
- "rollout_percentage": 33,
- },
- {
- "key": "test_2",
- "name": "Test Variant",
- "rollout_percentage": 34,
- },
- ]
- },
- "holdout": None,
- "aggregation_group_type_index": None,
- },
- )
+ self.assertEqual(cached_flags[0].filters, unchanged_filters)
def test_create_draft_experiment_with_filters(self) -> None:
ff_key = "a-b-tests"
@@ -6068,7 +5973,185 @@ class TestExperimentCRUD(APILicensedTest):
self.assertEqual(update_response.status_code, status.HTTP_400_BAD_REQUEST)
-class TestExperimentAuxiliaryEndpoints(ClickhouseTestMixin, APILicensedTest):
+class TestExperimentParametersFlagConfigCompatibility(APILicensedTest):
+ """Flag config belongs on the `feature_flag` object now, but many external clients still send it
+ through the deprecated `parameters` keys. Rather than reject those requests, the API copies that
+ config into the `feature_flag` object so legacy callers keep working. This class sends the
+ deprecated keys directly (it deliberately does NOT use _HoistFlagConfigClientMixin) to lock in
+ the copy behavior, the read-modify-write echo tolerance, and the running-experiment guard."""
+
+ @parameterized.expand(
+ [
+ (
+ "variants",
+ {
+ "feature_flag_variants": [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ },
+ lambda p: [v["key"] for v in p["feature_flag_variants"]] == ["control", "test"],
+ ),
+ ("rollout", {"rollout_percentage": 50}, lambda p: p["rollout_percentage"] == 50),
+ ("aggregation", {"aggregation_group_type_index": 0}, lambda p: p["aggregation_group_type_index"] == 0),
+ (
+ "payloads",
+ {"feature_flag_payloads": {"control": '"x"'}},
+ lambda p: p["feature_flag_payloads"] == {"control": '"x"'},
+ ),
+ ("continuity", {"ensure_experience_continuity": True}, lambda p: p["ensure_experience_continuity"] is True),
+ ]
+ )
+ def test_create_copies_deprecated_flag_config_to_flag(self, name: str, parameters: dict, check) -> None:
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/experiments/",
+ {"name": f"copy {name}", "feature_flag_key": f"copy-{name}", "parameters": parameters},
+ )
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
+ self.assertTrue(FeatureFlag.objects.filter(key=f"copy-{name}", team_id=self.team.id).exists())
+ # The read response projects the linked flag's config back into `parameters`, so it reflects
+ # the config the deprecated keys were copied onto the flag.
+ self.assertTrue(check(response.json()["parameters"]), response.json()["parameters"])
+
+ def _create_via_flag_object(
+ self, key: str = "echo-source", start_date: str | None = None, variants: list[dict] | None = None
+ ) -> int:
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/experiments/",
+ {
+ "name": key,
+ "feature_flag_key": key,
+ "start_date": start_date,
+ "feature_flag": {
+ "filters": {
+ "multivariate": {
+ "variants": variants
+ or [
+ {"key": "control", "name": "Control", "rollout_percentage": 50},
+ {"key": "test", "name": "Test", "rollout_percentage": 50},
+ ]
+ }
+ }
+ },
+ },
+ )
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
+ return response.json()["id"]
+
+ def test_update_tolerates_unchanged_parameters_echo(self) -> None:
+ experiment_id = self._create_via_flag_object()
+ # A read-modify-write client spreads the GET response's `parameters` (which carries the
+ # projected flag config, split_percent and all) straight back into the save. That unchanged
+ # echo must be stripped and tolerated, not resynced — else every UI save breaks.
+ echoed_parameters = self.client.get(f"/api/projects/{self.team.id}/experiments/{experiment_id}").json()[
+ "parameters"
+ ]
+ self.assertIn("feature_flag_variants", echoed_parameters)
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{experiment_id}",
+ {"description": "unrelated edit", "parameters": echoed_parameters},
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ # The echoed flag config never lands in the stored column.
+ experiment = Experiment.objects.get(id=experiment_id)
+ self.assertNotIn("feature_flag_variants", experiment.parameters or {})
+
+ @parameterized.expand(
+ [
+ (
+ "variants",
+ {
+ "feature_flag_variants": [
+ {"key": "control", "rollout_percentage": 30},
+ {"key": "test", "rollout_percentage": 70},
+ ]
+ },
+ lambda flag: [v["rollout_percentage"] for v in flag.variants] == [30, 70],
+ ),
+ ("rollout", {"rollout_percentage": 25}, lambda flag: flag.filters["groups"][0]["rollout_percentage"] == 25),
+ ]
+ )
+ def test_draft_update_copies_differing_parameters_flag_config_to_flag(
+ self, name: str, override: dict, check
+ ) -> None:
+ experiment_id = self._create_via_flag_object()
+ echoed_parameters = self.client.get(f"/api/projects/{self.team.id}/experiments/{experiment_id}").json()[
+ "parameters"
+ ]
+ # A genuine change through the deprecated surface on a draft is copied into the feature_flag
+ # object and applied to the linked flag, not silently dropped.
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{experiment_id}",
+ {"parameters": {**echoed_parameters, **override}},
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ flag = FeatureFlag.objects.get(key="echo-source", team_id=self.team.id)
+ self.assertTrue(check(flag), flag.filters)
+
+ def test_running_update_requires_opt_in_for_differing_parameters_flag_config(self) -> None:
+ experiment_id = self._create_via_flag_object(key="running-echo-source", start_date="2021-12-01T10:23")
+ echoed_parameters = self.client.get(f"/api/projects/{self.team.id}/experiments/{experiment_id}").json()[
+ "parameters"
+ ]
+ differing = {
+ **echoed_parameters,
+ "feature_flag_variants": [
+ {"key": "control", "rollout_percentage": 60},
+ {"key": "test", "rollout_percentage": 40},
+ ],
+ }
+ # Routing through the feature_flag path means the deprecated surface can't bypass the
+ # running-experiment guard: a differing change without the opt-in is rejected, not applied.
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{experiment_id}",
+ {"parameters": differing},
+ )
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.json())
+ self.assertIn("update_feature_flag_params", str(response.json()))
+ flag = FeatureFlag.objects.get(key="running-echo-source", team_id=self.team.id)
+ self.assertEqual([v["rollout_percentage"] for v in flag.variants], [50, 50])
+
+ # With the opt-in the change applies.
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{experiment_id}",
+ {"parameters": differing, "update_feature_flag_params": True},
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ flag.refresh_from_db()
+ self.assertEqual([v["rollout_percentage"] for v in flag.variants], [60, 40])
+
+ @parameterized.expand(
+ [
+ # Read-modify-write: echo the full flag-config projection GET returns, plus a non-flag key.
+ ("echo_plus_non_flag_key", lambda echoed: {**echoed, "variant_notes": {"control": "n"}}),
+ # Bare non-flag PATCH carrying no flag-config keys at all.
+ ("non_flag_key_only", lambda _echoed: {"variant_notes": {"control": "n"}}),
+ ]
+ )
+ def test_draft_non_flag_parameters_patch_preserves_flag_variants(self, name: str, build_parameters) -> None:
+ key = f"preserve-{name}"
+ experiment_id = self._create_via_flag_object(
+ key=key,
+ variants=[
+ {"key": "control", "name": "Control", "rollout_percentage": 30},
+ {"key": "test", "name": "Test", "rollout_percentage": 70},
+ ],
+ )
+ echoed_parameters = self.client.get(f"/api/projects/{self.team.id}/experiments/{experiment_id}").json()[
+ "parameters"
+ ]
+ # A PATCH that carries no genuine flag-config change must never resync the linked flag: its
+ # non-default variants must survive, not reset to DEFAULT_VARIANTS (50/50).
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/experiments/{experiment_id}",
+ {"parameters": build_parameters(echoed_parameters)},
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ flag = FeatureFlag.objects.get(key=key, team_id=self.team.id)
+ self.assertEqual([v["rollout_percentage"] for v in flag.variants], [30, 70], flag.filters)
+
+
+class TestExperimentAuxiliaryEndpoints(_HoistFlagConfigClientMixin, ClickhouseTestMixin, APILicensedTest):
def _generate_experiment(self, start_date="2024-01-01T10:23", extra_parameters=None):
ff_key = "a-b-test"
response = self.client.post(
@@ -8045,7 +8128,7 @@ class TestExperimentParametersFieldMutation(APILicensedTest):
}
-class TestExperimentRunningTimeCalculation(APILicensedTest):
+class TestExperimentRunningTimeCalculation(_HoistFlagConfigClientMixin, APILicensedTest):
EXPOSURE_ESTIMATE_CONFIG = {
"conversionRateInputType": "manual",
"manualMetricType": "funnel",
@@ -8201,7 +8284,7 @@ class TestExperimentRunningTimeCalculation(APILicensedTest):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
-class TestExperimentExcludedVariants(APILicensedTest):
+class TestExperimentExcludedVariants(_HoistFlagConfigClientMixin, APILicensedTest):
THREE_VARIANTS = [
{"key": "control", "rollout_percentage": 34},
{"key": "test-1", "rollout_percentage": 33},
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index 4729a097c13e..72e0c0d20c29 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -629,28 +629,14 @@ export interface MinimalFeatureFlagApi {
readonly evaluation_contexts: readonly string[]
}
-export interface ExperimentVariantApi {
- /** Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'. */
- key: string
- /** Human-readable variant name. */
- name?: string | null
- rollout_percentage?: number | null
- /** Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided. */
- split_percent?: number | null
-}
-
/**
* Free-text notes per variant, keyed by variant key. Use to document what each variant does or its reroute URL.
*/
export type ExperimentParametersApiVariantNotes = { [key: string]: string } | null
export interface ExperimentParametersApi {
- /** Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20. */
- feature_flag_variants?: ExperimentVariantApi[] | null
/** Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments. */
minimum_detectable_effect?: number | null
- /** Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100. */
- rollout_percentage?: number | null
/** Free-text notes per variant, keyed by variant key. Use to document what each variant does or its reroute URL. */
variant_notes?: ExperimentParametersApiVariantNotes
}
@@ -769,7 +755,7 @@ export interface ExperimentBasicApi {
readonly holdout: ExperimentHoldoutApi
/** @nullable */
readonly exposure_cohort: number | null
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParametersApi | null
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculationApi | null
@@ -1385,7 +1371,7 @@ export interface ExperimentWriteApi {
holdout_id?: number | null
/** @nullable */
readonly exposure_cohort: number | null
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParametersApi | null
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculationApi | null
@@ -1442,7 +1428,7 @@ export interface ExperimentWriteApi {
primary_metrics_ordered_uuids?: unknown
secondary_metrics_ordered_uuids?: unknown
only_count_matured_users?: boolean
- /** When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
+ /** When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
update_feature_flag_params?: boolean
/** Experiment lifecycle state: 'draft' (not yet launched), 'running' (launched with active feature flag), 'paused' (running with feature flag deactivated — virtual state derived from feature_flag.active, not stored), 'exposure_frozen' (running with enrollment frozen to the already-exposed cohort while metrics keep flowing — virtual state derived from the flag's release groups, not stored), 'stopped' (ended). */
readonly status: ExperimentStatusEnumApi
@@ -1491,7 +1477,7 @@ export interface ExperimentApi {
holdout_id?: number | null
/** @nullable */
readonly exposure_cohort: number | null
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParametersApi | null
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculationApi | null
@@ -1548,7 +1534,7 @@ export interface ExperimentApi {
primary_metrics_ordered_uuids?: unknown
secondary_metrics_ordered_uuids?: unknown
only_count_matured_users?: boolean
- /** When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
+ /** When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
update_feature_flag_params?: boolean
/** Experiment lifecycle state: 'draft' (not yet launched), 'running' (launched with active feature flag), 'paused' (running with feature flag deactivated — virtual state derived from feature_flag.active, not stored), 'exposure_frozen' (running with enrollment frozen to the already-exposed cohort while metrics keep flowing — virtual state derived from the flag's release groups, not stored), 'stopped' (ended). */
readonly status: ExperimentStatusEnumApi
@@ -1593,7 +1579,7 @@ export interface PatchedExperimentWriteApi {
holdout_id?: number | null
/** @nullable */
readonly exposure_cohort?: number | null
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParametersApi | null
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculationApi | null
@@ -1650,7 +1636,7 @@ export interface PatchedExperimentWriteApi {
primary_metrics_ordered_uuids?: unknown
secondary_metrics_ordered_uuids?: unknown
only_count_matured_users?: boolean
- /** When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
+ /** When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
update_feature_flag_params?: boolean
/** Experiment lifecycle state: 'draft' (not yet launched), 'running' (launched with active feature flag), 'paused' (running with feature flag deactivated — virtual state derived from feature_flag.active, not stored), 'exposure_frozen' (running with enrollment frozen to the already-exposed cohort while metrics keep flowing — virtual state derived from the flag's release groups, not stored), 'stopped' (ended). */
readonly status?: ExperimentStatusEnumApi
diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yaml
index 760d6a059d75..09caa7eff419 100644
--- a/products/experiments/mcp/tools.yaml
+++ b/products/experiments/mcp/tools.yaml
@@ -202,8 +202,7 @@ tools:
feature_flag:
description: >
Variant split, rollout scope, payloads, and experience continuity for the auto-created feature flag,
- in the flag's own filters shape. This is the canonical input, do not send flag config via the
- deprecated parameters keys (feature_flag_variants, rollout_percentage). If the user mentions a
+ in the flag's own filters shape. This is the canonical input for flag config. If the user mentions a
specific percentage, load the configuring-experiment-rollout skill and clarify before setting these
values. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must
sum to 100) to customize the variant split. Set filters.groups to a single group [{"properties": [],
@@ -990,8 +989,7 @@ tools:
feature_flag:
description: >
Variant split, rollout scope, payloads, and experience continuity for the linked feature flag, in
- the flag's own filters shape. This is the canonical input, do not send flag config via the
- deprecated parameters keys (feature_flag_variants, rollout_percentage). Set
+ the flag's own filters shape. This is the canonical input for flag config. Set
filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100,
exactly one key must be the literal string 'control') to change the variant split. Set
filters.groups to a single group [{"properties": [], "rollout_percentage": N}] (0-100) to change the
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 895497eac98e..fa59099b8d98 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -22451,28 +22451,14 @@ export namespace Schemas {
readonly user_access_level: string | null;
}
- export interface ExperimentVariant {
- /** Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'. */
- key: string;
- /** Human-readable variant name. */
- name?: string | null;
- rollout_percentage?: number | null;
- /** Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided. */
- split_percent?: number | null;
- }
-
/**
* Free-text notes per variant, keyed by variant key. Use to document what each variant does or its reroute URL.
*/
export type ExperimentParametersVariantNotes = {[key: string]: string} | null;
export interface ExperimentParameters {
- /** Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20. */
- feature_flag_variants?: ExperimentVariant[] | null;
/** Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments. */
minimum_detectable_effect?: number | null;
- /** Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100. */
- rollout_percentage?: number | null;
/** Free-text notes per variant, keyed by variant key. Use to document what each variant does or its reroute URL. */
variant_notes?: ExperimentParametersVariantNotes;
}
@@ -22685,7 +22671,7 @@ export namespace Schemas {
holdout_id?: number | null;
/** @nullable */
readonly exposure_cohort: number | null;
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParameters | null;
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculation | null;
@@ -22742,7 +22728,7 @@ export namespace Schemas {
primary_metrics_ordered_uuids?: unknown;
secondary_metrics_ordered_uuids?: unknown;
only_count_matured_users?: boolean;
- /** When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
+ /** When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
update_feature_flag_params?: boolean;
/** Experiment lifecycle state: 'draft' (not yet launched), 'running' (launched with active feature flag), 'paused' (running with feature flag deactivated — virtual state derived from feature_flag.active, not stored), 'exposure_frozen' (running with enrollment frozen to the already-exposed cohort while metrics keep flowing — virtual state derived from the flag's release groups, not stored), 'stopped' (ended). */
readonly status: ExperimentStatusEnum;
@@ -22794,7 +22780,7 @@ export namespace Schemas {
readonly holdout: ExperimentHoldout;
/** @nullable */
readonly exposure_cohort: number | null;
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParameters | null;
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculation | null;
@@ -23287,7 +23273,7 @@ export namespace Schemas {
holdout_id?: number | null;
/** @nullable */
readonly exposure_cohort: number | null;
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParameters | null;
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculation | null;
@@ -23344,7 +23330,7 @@ export namespace Schemas {
primary_metrics_ordered_uuids?: unknown;
secondary_metrics_ordered_uuids?: unknown;
only_count_matured_users?: boolean;
- /** When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
+ /** When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
update_feature_flag_params?: boolean;
/** Experiment lifecycle state: 'draft' (not yet launched), 'running' (launched with active feature flag), 'paused' (running with feature flag deactivated — virtual state derived from feature_flag.active, not stored), 'exposure_frozen' (running with enrollment frozen to the already-exposed cohort while metrics keep flowing — virtual state derived from the flag's release groups, not stored), 'stopped' (ended). */
readonly status: ExperimentStatusEnum;
@@ -39471,7 +39457,7 @@ export namespace Schemas {
holdout_id?: number | null;
/** @nullable */
readonly exposure_cohort?: number | null;
- /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
+ /** Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here. */
parameters?: ExperimentParameters | null;
/** Running-time calculator state: `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, and `exposure_estimate_config`. Canonical home for these keys, which historically lived in `parameters`. */
running_time_calculation?: ExperimentRunningTimeCalculation | null;
@@ -39528,7 +39514,7 @@ export namespace Schemas {
primary_metrics_ordered_uuids?: unknown;
secondary_metrics_ordered_uuids?: unknown;
only_count_matured_users?: boolean;
- /** When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
+ /** When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected. */
update_feature_flag_params?: boolean;
/** Experiment lifecycle state: 'draft' (not yet launched), 'running' (launched with active feature flag), 'paused' (running with feature flag deactivated — virtual state derived from feature_flag.active, not stored), 'exposure_frozen' (running with enrollment frozen to the already-exposed cohort while metrics keep flowing — virtual state derived from the flag's release groups, not stored), 'stopped' (ended). */
readonly status?: ExperimentStatusEnum;
diff --git a/services/mcp/src/generated/experiments/api.ts b/services/mcp/src/generated/experiments/api.ts
index 69d7e1c5c3fc..58b73ee14115 100644
--- a/services/mcp/src/generated/experiments/api.ts
+++ b/services/mcp/src/generated/experiments/api.ts
@@ -940,46 +940,12 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod
parameters: zod
.union([
zod.object({
- feature_flag_variants: zod
- .union([
- zod.array(
- zod.object({
- key: zod
- .string()
- .describe(
- "Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'."
- ),
- name: zod
- .union([zod.string(), zod.null()])
- .optional()
- .describe('Human-readable variant name.'),
- rollout_percentage: zod.union([zod.number(), zod.null()]).optional(),
- split_percent: zod
- .union([zod.number(), zod.null()])
- .optional()
- .describe(
- 'Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided.'
- ),
- })
- ),
- zod.null(),
- ])
- .optional()
- .describe(
- "Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20."
- ),
minimum_detectable_effect: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments.'
),
- rollout_percentage: zod
- .union([zod.number(), zod.null()])
- .optional()
- .describe(
- 'Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100.'
- ),
variant_notes: zod
.union([zod.record(zod.string(), zod.string()), zod.null()])
.optional()
@@ -991,7 +957,7 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- 'Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here.'
+ "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
),
running_time_calculation: zod
.union([
@@ -4275,7 +4241,7 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod
.boolean()
.default(experimentsCreateBodyUpdateFeatureFlagParamsDefault)
.describe(
- 'When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.'
+ 'When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.'
),
})
.describe('Experiment write payload. Identical to Experiment, plus the writable `feature_flag` config input.')
@@ -4505,46 +4471,12 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod
parameters: zod
.union([
zod.object({
- feature_flag_variants: zod
- .union([
- zod.array(
- zod.object({
- key: zod
- .string()
- .describe(
- "Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'."
- ),
- name: zod
- .union([zod.string(), zod.null()])
- .optional()
- .describe('Human-readable variant name.'),
- rollout_percentage: zod.union([zod.number(), zod.null()]).optional(),
- split_percent: zod
- .union([zod.number(), zod.null()])
- .optional()
- .describe(
- 'Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided.'
- ),
- })
- ),
- zod.null(),
- ])
- .optional()
- .describe(
- "Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20."
- ),
minimum_detectable_effect: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments.'
),
- rollout_percentage: zod
- .union([zod.number(), zod.null()])
- .optional()
- .describe(
- 'Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100.'
- ),
variant_notes: zod
.union([zod.record(zod.string(), zod.string()), zod.null()])
.optional()
@@ -4556,7 +4488,7 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- 'Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here.'
+ "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
),
running_time_calculation: zod
.union([
@@ -7845,7 +7777,7 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod
.boolean()
.optional()
.describe(
- 'When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.'
+ 'When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.'
),
})
.describe('Experiment write payload. Identical to Experiment, plus the writable `feature_flag` config input.')
@@ -8040,46 +7972,12 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod
parameters: zod
.union([
zod.object({
- feature_flag_variants: zod
- .union([
- zod.array(
- zod.object({
- key: zod
- .string()
- .describe(
- "Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'."
- ),
- name: zod
- .union([zod.string(), zod.null()])
- .optional()
- .describe('Human-readable variant name.'),
- rollout_percentage: zod.union([zod.number(), zod.null()]).optional(),
- split_percent: zod
- .union([zod.number(), zod.null()])
- .optional()
- .describe(
- 'Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided.'
- ),
- })
- ),
- zod.null(),
- ])
- .optional()
- .describe(
- "Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20."
- ),
minimum_detectable_effect: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments.'
),
- rollout_percentage: zod
- .union([zod.number(), zod.null()])
- .optional()
- .describe(
- 'Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100.'
- ),
variant_notes: zod
.union([zod.record(zod.string(), zod.string()), zod.null()])
.optional()
@@ -8091,7 +7989,7 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- 'Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here.'
+ "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
),
running_time_calculation: zod
.union([
@@ -11383,7 +11281,7 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod
.boolean()
.default(experimentsDuplicateCreateBodyUpdateFeatureFlagParamsDefault)
.describe(
- 'When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.'
+ 'When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.'
),
})
.describe(
diff --git a/services/mcp/src/tools/generated/experiments.ts b/services/mcp/src/tools/generated/experiments.ts
index ed55c23cf4dc..53b7a3c9abf6 100644
--- a/services/mcp/src/tools/generated/experiments.ts
+++ b/services/mcp/src/tools/generated/experiments.ts
@@ -181,7 +181,7 @@ const ExperimentCreateSchema = ExperimentsCreateBody.omit({
update_feature_flag_params: true,
}).extend({
feature_flag: ExperimentsCreateBody.shape['feature_flag'].describe(
- 'Variant split, rollout scope, payloads, and experience continuity for the auto-created feature flag, in the flag\'s own filters shape. This is the canonical input, do not send flag config via the deprecated parameters keys (feature_flag_variants, rollout_percentage). If the user mentions a specific percentage, load the configuring-experiment-rollout skill and clarify before setting these values. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100) to customize the variant split. Set filters.groups to a single group [{"properties": [], "rollout_percentage": N}] (0-100) to control the overall fraction of users entering the experiment. Default: 50/50 control/test, 100% rollout. Omit this parameter entirely when feature_flag_key refers to a pre-existing flag: the experiment links to that flag as-is and explicit config is rejected. HARD REQUIREMENT — when you provide variants, exactly one variant\'s `key` must be the literal string `control` (lowercase, no variations). It is the baseline used for analysis and the experiment runtime treats it specially. If the user describes variants as "A/B", "old/new", "original/redesign", or any other natural-language pair, map the baseline to `key: "control"` — not "A", "Control", "old", "original", or "baseline". Other variants can use any key (`test`, `variant_a`, etc.).'
+ 'Variant split, rollout scope, payloads, and experience continuity for the auto-created feature flag, in the flag\'s own filters shape. This is the canonical input for flag config. If the user mentions a specific percentage, load the configuring-experiment-rollout skill and clarify before setting these values. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100) to customize the variant split. Set filters.groups to a single group [{"properties": [], "rollout_percentage": N}] (0-100) to control the overall fraction of users entering the experiment. Default: 50/50 control/test, 100% rollout. Omit this parameter entirely when feature_flag_key refers to a pre-existing flag: the experiment links to that flag as-is and explicit config is rejected. HARD REQUIREMENT — when you provide variants, exactly one variant\'s `key` must be the literal string `control` (lowercase, no variations). It is the baseline used for analysis and the experiment runtime treats it specially. If the user describes variants as "A/B", "old/new", "original/redesign", or any other natural-language pair, map the baseline to `key: "control"` — not "A", "Control", "old", "original", or "baseline". Other variants can use any key (`test`, `variant_a`, etc.).'
),
})
@@ -901,7 +901,7 @@ const ExperimentUpdateSchema = ExperimentsPartialUpdateParams.omit({ project_id:
.extend({
id: z.preprocess(castStringToInt, ExperimentsPartialUpdateParams.shape['id']),
feature_flag: ExperimentsPartialUpdateBody.shape['feature_flag'].describe(
- 'Variant split, rollout scope, payloads, and experience continuity for the linked feature flag, in the flag\'s own filters shape. This is the canonical input, do not send flag config via the deprecated parameters keys (feature_flag_variants, rollout_percentage). Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100, exactly one key must be the literal string \'control\') to change the variant split. Set filters.groups to a single group [{"properties": [], "rollout_percentage": N}] (0-100) to change the overall rollout. Config this object omits is preserved from the flag\'s current state. On a running experiment this requires update_feature_flag_params=true (see rule 1: warn the user first).'
+ 'Variant split, rollout scope, payloads, and experience continuity for the linked feature flag, in the flag\'s own filters shape. This is the canonical input for flag config. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100, exactly one key must be the literal string \'control\') to change the variant split. Set filters.groups to a single group [{"properties": [], "rollout_percentage": N}] (0-100) to change the overall rollout. Config this object omits is preserved from the flag\'s current state. On a running experiment this requires update_feature_flag_params=true (see rule 1: warn the user first).'
),
running_time_calculation: ExperimentsPartialUpdateBody.shape['running_time_calculation'].describe(
"Persist a running-time / sample-size plan onto the experiment (the planning target shown in the experiment's running-time panel). Object with optional keys: minimum_detectable_effect (percentage, e.g. 20 for a 20% lift), recommended_sample_size (total across all variants), recommended_running_time (days), and exposure_estimate_config."
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-create.json
index c2e4bb41e1ce..5c245ff15a5f 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-create.json
@@ -2071,7 +2071,7 @@
"description": "Exposure configuration including filter test accounts and custom exposure events."
},
"feature_flag": {
- "description": "Variant split, rollout scope, payloads, and experience continuity for the auto-created feature flag, in the flag's own filters shape. This is the canonical input, do not send flag config via the deprecated parameters keys (feature_flag_variants, rollout_percentage). If the user mentions a specific percentage, load the configuring-experiment-rollout skill and clarify before setting these values. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100) to customize the variant split. Set filters.groups to a single group [{\"properties\": [], \"rollout_percentage\": N}] (0-100) to control the overall fraction of users entering the experiment. Default: 50/50 control/test, 100% rollout. Omit this parameter entirely when feature_flag_key refers to a pre-existing flag: the experiment links to that flag as-is and explicit config is rejected. HARD REQUIREMENT — when you provide variants, exactly one variant's `key` must be the literal string `control` (lowercase, no variations). It is the baseline used for analysis and the experiment runtime treats it specially. If the user describes variants as \"A/B\", \"old/new\", \"original/redesign\", or any other natural-language pair, map the baseline to `key: \"control\"` — not \"A\", \"Control\", \"old\", \"original\", or \"baseline\". Other variants can use any key (`test`, `variant_a`, etc.).",
+ "description": "Variant split, rollout scope, payloads, and experience continuity for the auto-created feature flag, in the flag's own filters shape. This is the canonical input for flag config. If the user mentions a specific percentage, load the configuring-experiment-rollout skill and clarify before setting these values. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100) to customize the variant split. Set filters.groups to a single group [{\"properties\": [], \"rollout_percentage\": N}] (0-100) to control the overall fraction of users entering the experiment. Default: 50/50 control/test, 100% rollout. Omit this parameter entirely when feature_flag_key refers to a pre-existing flag: the experiment links to that flag as-is and explicit config is rejected. HARD REQUIREMENT — when you provide variants, exactly one variant's `key` must be the literal string `control` (lowercase, no variations). It is the baseline used for analysis and the experiment runtime treats it specially. If the user describes variants as \"A/B\", \"old/new\", \"original/redesign\", or any other natural-language pair, map the baseline to `key: \"control\"` — not \"A\", \"Control\", \"old\", \"original\", or \"baseline\". Other variants can use any key (`test`, `variant_a`, etc.).",
"properties": {
"ensure_experience_continuity": {
"anyOf": [
@@ -2203,59 +2203,6 @@
"anyOf": [
{
"properties": {
- "feature_flag_variants": {
- "anyOf": [
- {
- "items": {
- "properties": {
- "key": {
- "description": "Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'.",
- "type": "string"
- },
- "name": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Human-readable variant name."
- },
- "rollout_percentage": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ]
- },
- "split_percent": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "description": "Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided."
- }
- },
- "required": ["key"],
- "type": "object"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "description": "Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20."
- },
"minimum_detectable_effect": {
"anyOf": [
{
@@ -2267,17 +2214,6 @@
],
"description": "Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments."
},
- "rollout_percentage": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "description": "Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100."
- },
"variant_notes": {
"anyOf": [
{
@@ -2302,7 +2238,7 @@
"type": "null"
}
],
- "description": "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
+ "description": "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
},
"stats_config": {}
},
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
index a18b6a2c6ac9..0e1603a520b7 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
@@ -2113,7 +2113,7 @@
"description": "Exposure configuration including filter test accounts and custom exposure events."
},
"feature_flag": {
- "description": "Variant split, rollout scope, payloads, and experience continuity for the linked feature flag, in the flag's own filters shape. This is the canonical input, do not send flag config via the deprecated parameters keys (feature_flag_variants, rollout_percentage). Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100, exactly one key must be the literal string 'control') to change the variant split. Set filters.groups to a single group [{\"properties\": [], \"rollout_percentage\": N}] (0-100) to change the overall rollout. Config this object omits is preserved from the flag's current state. On a running experiment this requires update_feature_flag_params=true (see rule 1: warn the user first).",
+ "description": "Variant split, rollout scope, payloads, and experience continuity for the linked feature flag, in the flag's own filters shape. This is the canonical input for flag config. Set filters.multivariate.variants (each with key and rollout_percentage; percentages must sum to 100, exactly one key must be the literal string 'control') to change the variant split. Set filters.groups to a single group [{\"properties\": [], \"rollout_percentage\": N}] (0-100) to change the overall rollout. Config this object omits is preserved from the flag's current state. On a running experiment this requires update_feature_flag_params=true (see rule 1: warn the user first).",
"properties": {
"ensure_experience_continuity": {
"anyOf": [
@@ -5543,59 +5543,6 @@
"anyOf": [
{
"properties": {
- "feature_flag_variants": {
- "anyOf": [
- {
- "items": {
- "properties": {
- "key": {
- "description": "Variant key. Exactly one variant in feature_flag_variants must use key 'control' (lowercase, exactly) — that is the baseline used for analysis and the special key the experiment runtime expects. Other variants use keys like 'test', 'variant_a', 'variant_b'. Map natural-language names ('original', 'A', 'baseline') to 'control'.",
- "type": "string"
- },
- "name": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Human-readable variant name."
- },
- "rollout_percentage": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ]
- },
- "split_percent": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "description": "Percentage of users assigned to this variant (0–100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage must be provided."
- }
- },
- "required": ["key"],
- "type": "object"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "description": "Experiment variants. If specified, must include a variant with key 'control' (lowercase). Defaults to a 50/50 control/test split when omitted. Minimum 2, maximum 20."
- },
"minimum_detectable_effect": {
"anyOf": [
{
@@ -5607,17 +5554,6 @@
],
"description": "Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. Suggest 20–30% for most experiments."
},
- "rollout_percentage": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "description": "Overall rollout percentage (0-100). Controls what fraction of all users enter the experiment. Users outside the rollout never see any variant and are excluded from analysis. Default: 100."
- },
"variant_notes": {
"anyOf": [
{
@@ -5642,7 +5578,7 @@
"type": "null"
}
],
- "description": "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config keys (`feature_flag_variants`, `rollout_percentage`) are a deprecated input surface kept for compatibility — the linked feature flag is the source of truth, and reads project its current config into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
+ "description": "Experiment parameters JSON. Supported keys include `custom_exposure_filter` and `variant_notes` (free-text notes per variant, keyed by variant key). Flag config (variants, rollout, aggregation, payloads, experience continuity) belongs on the `feature_flag` object; send it there. For backward compatibility, config still sent through these deprecated keys is copied onto the linked flag rather than rejected, and reads project the flag's current config back into this field. Excluded variants live on the top-level `excluded_variants` field, not here."
},
"running_time_calculation": {
"anyOf": [
@@ -5773,7 +5709,7 @@
},
"stats_config": {},
"update_feature_flag_params": {
- "description": "When true, sync the flag config sent in this request (via the `feature_flag` object, or the deprecated `parameters` keys) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.",
+ "description": "When true, sync the flag config sent in this request (via the `feature_flag` object) to the linked feature flag. Draft experiments always sync regardless. On a running experiment, `feature_flag` config without this flag is rejected.",
"type": "boolean"
}
},