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.

chore(experiments): stop dual-writing excluded_variants to parameters (#66292)

Anders6d813b23b7b8
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 6031caa9f790..7c7fb1f77d52 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -20621,13 +20621,6 @@
"ExperimentParameters": {
"additionalProperties": false,
"properties": {
- "excluded_variants": {
- "description": "Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis.",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
"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": {
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 46225e485fc6..c64c80749b26 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -4206,8 +4206,6 @@ export interface ExperimentParameters {
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
- /** Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. */
- excluded_variants?: string[]
/** 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/frontend/src/scenes/experiments/experimentLogic.test.ts b/frontend/src/scenes/experiments/experimentLogic.test.ts
index 58b59de1fab8..d5807b7bd10b 100644
--- a/frontend/src/scenes/experiments/experimentLogic.test.ts
+++ b/frontend/src/scenes/experiments/experimentLogic.test.ts
@@ -2005,35 +2005,17 @@ describe('experimentLogic', () => {
})
describe('excluded variants', () => {
- it('excludedVariants selector reads the excluded_variants column first', async () => {
+ it('excludedVariants selector reads the excluded_variants column', async () => {
await expectLogic(logic, () => {
logic.actions.setExperiment({
...experiment,
excluded_variants: ['test-3'],
- parameters: {
- ...experiment.parameters,
- excluded_variants: ['test-2'],
- },
})
}).toMatchValues({
excludedVariants: ['test-3'],
})
})
- it('excludedVariants selector falls back to parameters.excluded_variants', async () => {
- await expectLogic(logic, () => {
- logic.actions.setExperiment({
- ...experiment,
- parameters: {
- ...experiment.parameters,
- excluded_variants: ['test-2'],
- },
- })
- }).toMatchValues({
- excludedVariants: ['test-2'],
- })
- })
-
it('excludedVariants defaults to [] when missing', async () => {
await expectLogic(logic, () => {
logic.actions.setExperiment({
@@ -2073,10 +2055,7 @@ describe('experimentLogic', () => {
await expectLogic(logic, () => {
logic.actions.setExperiment({
...experiment,
- parameters: {
- ...experiment.parameters,
- excluded_variants: ['test-1', 'test-2'],
- },
+ excluded_variants: ['test-1', 'test-2'],
})
}).toMatchValues({
excludedVariants: ['test-1', 'test-2'],
diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsx
index 6a396be6b6db..95be31a128df 100644
--- a/frontend/src/scenes/experiments/experimentLogic.tsx
+++ b/frontend/src/scenes/experiments/experimentLogic.tsx
@@ -2732,10 +2732,7 @@ export const experimentLogic = kea<experimentLogicType>([
variants: [(s) => [s.experiment], (experiment): MultivariateFlagVariant[] => getExperimentVariants(experiment)],
excludedVariants: [
(s) => [s.experiment],
- // Canonical home is the excluded_variants column; fall back to the legacy parameters
- // mirror during the deprecation window. `??` honors an explicit empty list.
- (experiment: Experiment): string[] =>
- experiment?.excluded_variants ?? experiment?.parameters?.excluded_variants ?? [],
+ (experiment: Experiment): string[] => experiment?.excluded_variants ?? [],
],
experimentMathAggregationForTrends: [
(s) => [s.experiment],
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 8d2e025f56de..a1eb42d2e8f3 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -4782,7 +4782,6 @@ export interface Experiment {
variant_screenshot_media_ids?: Record<string, string[]>
variant_notes?: Record<string, string>
rollout_percentage?: number
- excluded_variants?: string[]
/** Present when the experiment was created from an LLM prompt via /create_from_prompt/. */
prompt_metadata?: {
name: string
diff --git a/posthog/schema.py b/posthog/schema.py
index 5579dae68366..ac003106aabf 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -5109,13 +5109,6 @@ class ExperimentParameters(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
- excluded_variants: list[str] | None = Field(
- default=None,
- description=(
- "Variant keys to exclude from metric result calculations. Excluded variants"
- " are still served to users but omitted from statistical analysis."
- ),
- )
feature_flag_variants: list[ExperimentVariant] | None = Field(
default=None,
description=(
diff --git a/products/experiments/backend/experiment_service.py b/products/experiments/backend/experiment_service.py
index 713c5fe79a2b..3806a352706e 100644
--- a/products/experiments/backend/experiment_service.py
+++ b/products/experiments/backend/experiment_service.py
@@ -53,7 +53,6 @@ from products.experiments.backend.models.experiment import (
ExperimentTimeseriesRecalculation,
ExperimentToSavedMetric,
experiment_has_legacy_metrics,
- get_excluded_variants,
holdout_filters_for_flag,
)
from products.experiments.backend.models.team_experiments_config import TeamExperimentsConfig
@@ -187,31 +186,6 @@ class ExperimentService:
"'key' to 'control'."
)
- excluded_variants = parameters.get("excluded_variants")
- if excluded_variants is None:
- return
-
- if not isinstance(excluded_variants, list) or not all(isinstance(v, str) for v in excluded_variants):
- raise ValidationError("excluded_variants must be a list of strings")
-
- if not excluded_variants:
- return
-
- # `parameters` is replaced wholesale on update (see update_experiment:
- # `update_data.get("parameters", experiment.parameters)`), not merged — so a
- # PATCH that sets `excluded_variants` must also resend `feature_flag_variants`,
- # otherwise the stored object would have no variants at all. Surface that
- # explicitly rather than letting every key fall through to "unknown variants".
- if not variants:
- raise ValidationError(
- "excluded_variants requires feature_flag_variants in the same request — "
- "parameters are replaced as a whole on update, so send the full parameters object"
- )
-
- variant_keys = {v["key"] for v in variants}
- baseline_key = (parameters.get("stats_config") or {}).get("baseline_variant_key", "control")
- ExperimentService._validate_excluded_variant_keys(excluded_variants, variant_keys, baseline_key)
-
@staticmethod
def _validate_excluded_variant_keys(
excluded_variants: list[str], variant_keys: Iterable[str], baseline_key: str
@@ -253,16 +227,6 @@ class ExperimentService:
if not isinstance(value, list) or not all(isinstance(v, str) for v in value):
raise ValidationError("excluded_variants must be a list of strings")
- @staticmethod
- def _merge_excluded_variants_into_parameters(parameters: dict | None, excluded_variants: list[str] | None) -> dict:
- """Mirror the canonical excluded_variants into the legacy `parameters` blob."""
- merged = dict(parameters or {})
- if excluded_variants is None:
- merged.pop("excluded_variants", None)
- else:
- merged["excluded_variants"] = list(excluded_variants)
- return merged
-
RUNNING_TIME_CALCULATION_KEYS = (
"minimum_detectable_effect",
"recommended_running_time",
@@ -793,12 +757,6 @@ class ExperimentService:
self.validate_running_time_calculation(running_time_calculation)
self.validate_excluded_variants(excluded_variants)
running_time_calculation = running_time_calculation or {}
- # Dual-write for excluded_variants during the parameters deprecation window: the canonical
- # column wins over legacy `parameters` when supplied; otherwise derive the column from `parameters`.
- if excluded_variants is not None:
- parameters = self._merge_excluded_variants_into_parameters(parameters, excluded_variants)
- else:
- excluded_variants = (parameters or {}).get("excluded_variants")
self.validate_experiment_metrics(metrics)
self.validate_experiment_metrics(metrics_secondary)
self.validate_metric_action_ids(metrics, self.team.id)
@@ -1346,7 +1304,7 @@ class ExperimentService:
experiment.start_date,
experiment.stats_config,
experiment.exposure_criteria,
- excluded_variants=get_excluded_variants(experiment),
+ excluded_variants=experiment.excluded_variants or [],
),
)
@@ -2198,9 +2156,8 @@ class ExperimentService:
effective_stats_config = update_data.get("stats_config", experiment.stats_config)
self.validate_stats_config(effective_stats_config, variant_keys)
- # Validate excluded_variants on the canonical column path against the resolved flag
- # variants — no feature_flag_variants resend required (the legacy
- # `parameters.excluded_variants` path is still validated in the serializer).
+ # Validate excluded_variants against the resolved flag variants — no
+ # feature_flag_variants resend required.
if "excluded_variants" in update_data:
new_excluded = update_data["excluded_variants"]
if new_excluded:
@@ -2221,16 +2178,13 @@ class ExperimentService:
stats_config = update_data.get("stats_config", experiment.stats_config)
exposure_criteria = update_data.get("exposure_criteria", experiment.exposure_criteria)
only_count_matured_users = update_data.get("only_count_matured_users", experiment.only_count_matured_users)
- # Canonical excluded_variants for fingerprints: prefer an explicit column update, then
- # legacy parameters in the payload, then the stored canonical value. Computed here
- # (before the dual-write below) so a new client PATCHing only excluded_variants still
- # fingerprints with the new exclusions.
+ # Canonical excluded_variants for fingerprints: prefer an explicit column update,
+ # otherwise the stored canonical value. So a client PATCHing only excluded_variants
+ # still fingerprints with the new exclusions.
if "excluded_variants" in update_data:
excluded_variants = update_data["excluded_variants"]
- elif "parameters" in update_data:
- excluded_variants = (update_data["parameters"] or {}).get("excluded_variants")
else:
- excluded_variants = get_excluded_variants(experiment)
+ excluded_variants = experiment.excluded_variants or []
for metric_field in ["metrics", "metrics_secondary"]:
metrics = update_data.get(metric_field, getattr(experiment, metric_field, None))
@@ -2260,17 +2214,6 @@ class ExperimentService:
feature_flag.active = True
feature_flag.save()
- # --- excluded_variants dual-write -----------------------------------
- # Mirror the canonical excluded_variants column into legacy `parameters`.
- # The column wins when both are sent.
- if "excluded_variants" in update_data:
- update_data["parameters"] = self._merge_excluded_variants_into_parameters(
- update_data.get("parameters", experiment.parameters),
- update_data["excluded_variants"],
- )
- elif "parameters" in update_data:
- update_data["excluded_variants"] = (update_data["parameters"] or {}).get("excluded_variants")
-
# --- apply changes and save ----------------------------------------
for attr, value in update_data.items():
setattr(experiment, attr, value)
diff --git a/products/experiments/backend/hogql_queries/experiment_exposures_query_runner.py b/products/experiments/backend/hogql_queries/experiment_exposures_query_runner.py
index 5b5645ce5f52..fbe8b16c4fe4 100644
--- a/products/experiments/backend/hogql_queries/experiment_exposures_query_runner.py
+++ b/products/experiments/backend/hogql_queries/experiment_exposures_query_runner.py
@@ -45,7 +45,7 @@ from products.experiments.backend.hogql_queries.experiment_query_runner import (
experiment_has_min_runtime_for_precomputation,
)
from products.experiments.backend.hogql_queries.exposure_query_logic import get_entity_key
-from products.experiments.backend.models.experiment import Experiment, get_excluded_variants
+from products.experiments.backend.models.experiment import Experiment
from products.experiments.backend.models.team_experiments_config import TeamExperimentsConfig
logger = structlog.get_logger(__name__)
@@ -85,7 +85,7 @@ class ExperimentExposuresQueryRunner(QueryRunner):
# Holdout is intentionally not appended: holdout users were never exposed to
# the experiment, so they don't belong in the exposure chart. self.query.holdout
# is still consulted by _calculate_srm for the holdout-adjusted rollout math.
- self.excluded_variants = set(get_excluded_variants(self.experiment))
+ self.excluded_variants = set(self.experiment.excluded_variants or [])
multivariate_data = self.query.feature_flag.get("filters", {}).get("multivariate", {})
self.variants = [
variant.get("key")
diff --git a/products/experiments/backend/hogql_queries/experiment_query_runner.py b/products/experiments/backend/hogql_queries/experiment_query_runner.py
index 9874aaf0e7b3..2acb91e39a7d 100644
--- a/products/experiments/backend/hogql_queries/experiment_query_runner.py
+++ b/products/experiments/backend/hogql_queries/experiment_query_runner.py
@@ -63,7 +63,7 @@ from products.experiments.backend.hogql_queries.utils import (
split_baseline_and_test_variants,
)
from products.experiments.backend.metric_utils import get_default_metric_title
-from products.experiments.backend.models.experiment import Experiment, get_excluded_variants
+from products.experiments.backend.models.experiment import Experiment
from products.experiments.backend.models.team_experiments_config import TeamExperimentsConfig
logger = structlog.get_logger(__name__)
@@ -164,7 +164,7 @@ class ExperimentQueryRunner(QueryRunner):
# the experiment, so they don't belong in the metric scorecard.
# self.experiment.holdout is still readable for code paths that need it
# (e.g. the Distribution table on the Variants tab).
- excluded_variants = set(get_excluded_variants(self.experiment))
+ excluded_variants = set(self.experiment.excluded_variants or [])
self.variants = [
variant["key"] for variant in self.feature_flag.variants if variant["key"] not in excluded_variants
]
diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_excluded_variants.py b/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_excluded_variants.py
index e5dea739f3ff..b6c702fa4a97 100644
--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_excluded_variants.py
+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_excluded_variants.py
@@ -25,18 +25,17 @@ class TestExcludedVariants(ExperimentQueryRunnerBaseTest):
@parameterized.expand(
[
- # name, extra_variants, attach_holdout, parameters
- ("excluded_variant_dropped", ["test-2"], False, {"excluded_variants": ["test-2"]}),
- ("no_exclusions_unchanged", [], False, {}),
- ("none_parameters_unchanged", [], False, None),
- ("empty_excluded_variants_unchanged", [], False, {"excluded_variants": []}),
- ("holdout_and_excluded_both_filtered", ["test-2"], True, {"excluded_variants": ["test-2"]}),
- ("holdout_attached", [], True, "unset"),
- ("excluded_variants_naming_holdout_is_idempotent", [], True, {"excluded_variants": [_HOLDOUT_KEY]}),
+ # name, extra_variants, attach_holdout, excluded_variants ("unset" leaves the column as None)
+ ("excluded_variant_dropped", ["test-2"], False, ["test-2"]),
+ ("empty_exclusions", [], False, []),
+ ("column_unset", [], False, "unset"),
+ ("holdout_and_excluded_both_filtered", ["test-2"], True, ["test-2"]),
+ ("holdout_attached_no_exclusions", [], True, "unset"),
+ ("excluded_variants_naming_holdout_is_idempotent", [], True, [_HOLDOUT_KEY]),
]
)
@freeze_time("2020-01-01T12:00:00Z")
- def test_runner_variant_filtering(self, name, extra_variants, attach_holdout, parameters):
+ def test_runner_variant_filtering(self, name, extra_variants, attach_holdout, excluded_variants):
feature_flag = self.create_feature_flag(key=f"{name.replace('_', '-')}-test")
for index, variant_key in enumerate(extra_variants):
feature_flag.filters["multivariate"]["variants"].append(
@@ -56,18 +55,11 @@ class TestExcludedVariants(ExperimentQueryRunnerBaseTest):
)
experiment.holdout = holdout
- if parameters != "unset":
- resolved = parameters
- if isinstance(parameters, dict):
- holdout_key = f"holdout-{holdout.id}" if holdout is not None else self._HOLDOUT_KEY
- resolved = {
- **parameters,
- "excluded_variants": [
- holdout_key if key == self._HOLDOUT_KEY else key
- for key in parameters.get("excluded_variants", [])
- ],
- }
- experiment.parameters = resolved
+ if excluded_variants != "unset":
+ holdout_key = f"holdout-{holdout.id}" if holdout is not None else self._HOLDOUT_KEY
+ experiment.excluded_variants = [
+ holdout_key if key == self._HOLDOUT_KEY else key for key in excluded_variants
+ ]
experiment.save()
runner = self._make_runner(experiment)
diff --git a/products/experiments/backend/models/experiment.py b/products/experiments/backend/models/experiment.py
index e194c82f5d90..fb81f2555b12 100644
--- a/products/experiments/backend/models/experiment.py
+++ b/products/experiments/backend/models/experiment.py
@@ -80,9 +80,7 @@ class Experiment(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.
running_time_calculation = models.JSONField(default=dict, null=True, blank=True)
# Variant keys dropped from statistical analysis. Canonical home for what historically
- # lived in `parameters.excluded_variants`. No default on purpose: `null` means "never set"
- # (fall back to the legacy `parameters` mirror during the deprecation window), while `[]`
- # means an explicit "no exclusions". A `list` default would shadow the fallback.
+ # lived in `parameters.excluded_variants`. `null`/empty both mean "no exclusions".
excluded_variants = ArrayField(models.TextField(), null=True, blank=True)
only_count_matured_users = models.BooleanField(default=False)
@@ -237,18 +235,6 @@ def holdout_filters_for_flag(holdout_id: int | None, filters: list | None) -> di
}
-def get_excluded_variants(experiment: "Experiment") -> list[str]:
- """Variant keys dropped from statistical analysis.
-
- Canonical home is the `excluded_variants` column; falls back to the legacy
- `parameters` mirror during the deprecation window. A `None` column means "never set"
- (use the fallback); an explicit empty list is honored as "no exclusions".
- """
- if experiment.excluded_variants is not None:
- return list(experiment.excluded_variants)
- return list((experiment.parameters or {}).get("excluded_variants") or [])
-
-
LEGACY_METRIC_KINDS: frozenset[str] = frozenset({"ExperimentTrendsQuery", "ExperimentFunnelsQuery"})
diff --git a/products/experiments/backend/presentation/serializers.py b/products/experiments/backend/presentation/serializers.py
index b02a44d49d45..8e18d61a6522 100644
--- a/products/experiments/backend/presentation/serializers.py
+++ b/products/experiments/backend/presentation/serializers.py
@@ -38,7 +38,6 @@ from products.experiments.backend.models.experiment import (
ExperimentHoldout,
ExperimentMetricsRecalculation,
experiment_has_legacy_metrics,
- get_excluded_variants,
)
from products.experiments.backend.running_time_calculator import METRIC_TYPE_CHOICES
from products.feature_flags.backend.api.feature_flag import MinimalFeatureFlagSerializer
@@ -153,10 +152,9 @@ class ExperimentBaseSerializer(UserAccessControlSerializerMixin, serializers.Mod
help_text=(
"Experiment parameters JSON. Supported keys include "
"`feature_flag_variants`, `rollout_percentage`, "
- "`custom_exposure_filter`, `excluded_variants` "
- "(list of variant keys to drop from statistical analysis; "
- "the baseline variant and holdout pseudo-variants cannot be excluded), "
- "and `variant_notes` (free-text notes per variant, keyed by variant key)."
+ "`custom_exposure_filter`, and `variant_notes` "
+ "(free-text notes per variant, keyed by variant key). "
+ "Excluded variants live on the top-level `excluded_variants` field, not here."
),
)
running_time_calculation = ExperimentRunningTimeCalculationField(
@@ -176,7 +174,7 @@ class ExperimentBaseSerializer(UserAccessControlSerializerMixin, serializers.Mod
"Variant keys to exclude from metric result calculations. Excluded variants are still "
"served to users but omitted from statistical analysis. The baseline variant and holdout "
"pseudo-variants cannot be excluded. Canonical home for what historically lived in "
- "`parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window."
+ "`parameters.excluded_variants`."
),
)
conclusion = serializers.ChoiceField(
@@ -421,7 +419,7 @@ class ExperimentSerializer(ExperimentBaseSerializer):
get_experiment_stats_method(instance),
instance.exposure_criteria,
only_count_matured_users=instance.only_count_matured_users,
- excluded_variants=get_excluded_variants(instance),
+ excluded_variants=instance.excluded_variants or [],
)
return data
diff --git a/products/experiments/backend/test/test_experiment_service.py b/products/experiments/backend/test/test_experiment_service.py
index 9e1e92096002..fc406c50978b 100644
--- a/products/experiments/backend/test/test_experiment_service.py
+++ b/products/experiments/backend/test/test_experiment_service.py
@@ -32,7 +32,6 @@ from products.experiments.backend.models.experiment import (
ExperimentMetricResult,
ExperimentSavedMetric,
ExperimentTimeseriesRecalculation,
- get_excluded_variants,
)
from products.experiments.backend.models.team_experiments_config import TeamExperimentsConfig
from products.feature_flags.backend.api.feature_flag import FeatureFlagSerializer
@@ -5541,68 +5540,33 @@ class TestExperimentService(APIBaseTest):
)
-class TestValidateExperimentParametersExcludedVariants:
- def _base_params(self) -> dict[str, Any]:
- return {
- "feature_flag_variants": [
- {"key": "control", "rollout_percentage": 50},
- {"key": "test-1", "rollout_percentage": 25},
- {"key": "test-2", "rollout_percentage": 25},
- ]
- }
+class TestValidateExcludedVariantKeys:
+ _VARIANT_KEYS = {"control", "test-1", "test-2"}
@pytest.mark.parametrize(
- "extra_params",
+ "excluded_variants,baseline_key",
[
- {},
- {"excluded_variants": []},
- {"excluded_variants": ["test-2"]},
- {"excluded_variants": ["test-2", "test-2"]},
+ ([], "control"),
+ (["test-2"], "control"),
+ (["test-2", "test-2"], "control"),
],
)
- def test_valid_excluded_variants(self, extra_params: dict[str, Any]):
- ExperimentService.validate_experiment_parameters({**self._base_params(), **extra_params})
+ def test_valid_excluded_variants(self, excluded_variants: list[str], baseline_key: str):
+ ExperimentService._validate_excluded_variant_keys(excluded_variants, self._VARIANT_KEYS, baseline_key)
@pytest.mark.parametrize(
- "extra_params,match",
+ "excluded_variants,baseline_key,match",
[
- ({"excluded_variants": ["does-not-exist"]}, "unknown variants"),
- ({"excluded_variants": ["control"]}, "baseline variant cannot be excluded"),
- ({"excluded_variants": ["holdout-42"]}, "cannot exclude holdout"),
- ({"excluded_variants": ["test-1", "test-2"]}, "at least one test variant"),
- ({"excluded_variants": "test-2"}, "must be a list of strings"),
- ({"excluded_variants": [123]}, "must be a list of strings"),
- (
- {"stats_config": {"baseline_variant_key": "test-1"}, "excluded_variants": ["test-1"]},
- "baseline variant cannot be excluded",
- ),
+ (["does-not-exist"], "control", "unknown variants"),
+ (["control"], "control", "baseline variant cannot be excluded"),
+ (["holdout-42"], "control", "cannot exclude holdout"),
+ (["test-1", "test-2"], "control", "at least one test variant"),
+ (["test-1"], "test-1", "baseline variant cannot be excluded"),
],
)
- def test_invalid_excluded_variants_raises(self, extra_params: dict[str, Any], match: str):
+ def test_invalid_excluded_variants_raises(self, excluded_variants: list[str], baseline_key: str, match: str):
with pytest.raises(ValidationError, match=match):
- ExperimentService.validate_experiment_parameters({**self._base_params(), **extra_params})
-
- def test_excluded_variants_without_feature_flag_variants_raises(self):
- with pytest.raises(ValidationError, match="requires feature_flag_variants in the same request"):
- ExperimentService.validate_experiment_parameters({"excluded_variants": ["test-1"]})
-
-
-class TestGetExcludedVariants:
- @pytest.mark.parametrize(
- "column,parameters,expected",
- [
- (None, None, []),
- (None, {}, []),
- # the column is canonical, including an explicit empty list
- (["test-2"], {"excluded_variants": ["legacy"]}, ["test-2"]),
- ([], {"excluded_variants": ["legacy"]}, []),
- # falls back to legacy parameters only when the column is None (never set)
- (None, {"excluded_variants": ["legacy"]}, ["legacy"]),
- ],
- )
- def test_precedence(self, column, parameters, expected):
- experiment = Experiment(excluded_variants=column, parameters=parameters)
- assert get_excluded_variants(experiment) == expected
+ ExperimentService._validate_excluded_variant_keys(excluded_variants, self._VARIANT_KEYS, baseline_key)
class TestValidateExcludedVariants:
diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.py
index c6db94a2ce42..665d0a880fe9 100644
--- a/products/experiments/backend/test/test_presentation_api.py
+++ b/products/experiments/backend/test/test_presentation_api.py
@@ -7267,19 +7267,7 @@ class TestExperimentExcludedVariants(APILicensedTest):
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
return response.json()
- def test_create_with_legacy_parameters_populates_column(self):
- created = self._create_experiment(
- parameters={"feature_flag_variants": self.THREE_VARIANTS, "excluded_variants": ["test-2"]}
- )
-
- self.assertEqual(created["excluded_variants"], ["test-2"])
-
- experiment = Experiment.objects.get(pk=created["id"])
- self.assertEqual(experiment.excluded_variants, ["test-2"])
- assert experiment.parameters is not None
- self.assertEqual(experiment.parameters["excluded_variants"], ["test-2"])
-
- def test_create_with_excluded_variants_mirrors_into_parameters(self):
+ def test_create_with_excluded_variants_writes_only_column(self):
created = self._create_experiment(
parameters={"feature_flag_variants": self.THREE_VARIANTS},
excluded_variants=["test-2"],
@@ -7288,8 +7276,10 @@ class TestExperimentExcludedVariants(APILicensedTest):
self.assertEqual(created["excluded_variants"], ["test-2"])
experiment = Experiment.objects.get(pk=created["id"])
+ self.assertEqual(experiment.excluded_variants, ["test-2"])
+ # No longer mirrored into the deprecated parameters blob
assert experiment.parameters is not None
- self.assertEqual(experiment.parameters["excluded_variants"], ["test-2"])
+ self.assertNotIn("excluded_variants", experiment.parameters)
def test_update_excluded_variants_does_not_require_feature_flag_variants(self):
"""The headline of the parameters split: excluding a variant no longer requires
@@ -7304,9 +7294,9 @@ class TestExperimentExcludedVariants(APILicensedTest):
experiment = Experiment.objects.get(pk=created["id"])
self.assertEqual(experiment.excluded_variants, ["test-2"])
- # Legacy mirror updated, and the variants stored in parameters survive the merge
+ # Only the column is written; the deprecated parameters blob is untouched
assert experiment.parameters is not None
- self.assertEqual(experiment.parameters["excluded_variants"], ["test-2"])
+ self.assertNotIn("excluded_variants", experiment.parameters)
self.assertEqual(len(experiment.parameters["feature_flag_variants"]), 3)
def test_update_excluded_variants_does_not_touch_feature_flag(self):
@@ -7323,44 +7313,6 @@ class TestExperimentExcludedVariants(APILicensedTest):
flag.refresh_from_db()
self.assertEqual(len(flag.filters["multivariate"]["variants"]), 3)
- def test_update_parameters_derives_column(self):
- created = self._create_experiment(parameters={"feature_flag_variants": self.THREE_VARIANTS})
-
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{created['id']}/",
- {"parameters": {"feature_flag_variants": self.THREE_VARIANTS, "excluded_variants": ["test-2"]}},
- )
- self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
-
- experiment = Experiment.objects.get(pk=created["id"])
- self.assertEqual(experiment.excluded_variants, ["test-2"])
-
- # parameters replaces wholesale, so dropping the key clears the canonical column too
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{created['id']}/",
- {"parameters": {"feature_flag_variants": self.THREE_VARIANTS}},
- )
- self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
- experiment.refresh_from_db()
- self.assertIsNone(experiment.excluded_variants)
-
- def test_excluded_variants_wins_when_both_sent(self):
- created = self._create_experiment(parameters={"feature_flag_variants": self.THREE_VARIANTS})
-
- response = self.client.patch(
- f"/api/projects/{self.team.id}/experiments/{created['id']}/",
- {
- "parameters": {"feature_flag_variants": self.THREE_VARIANTS, "excluded_variants": ["test-1"]},
- "excluded_variants": ["test-2"],
- },
- )
- self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
-
- experiment = Experiment.objects.get(pk=created["id"])
- self.assertEqual(experiment.excluded_variants, ["test-2"])
- assert experiment.parameters is not None
- self.assertEqual(experiment.parameters["excluded_variants"], ["test-2"])
-
@parameterized.expand(
[
("unknown_variant", ["does-not-exist"]),
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index 7f58e325bb3d..959ecbefca6b 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -257,8 +257,6 @@ export interface ExperimentVariantApi {
export type ExperimentParametersApiVariantNotes = { [key: string]: string } | null
export interface ExperimentParametersApi {
- /** Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. */
- excluded_variants?: string[] | null
/** 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. */
@@ -382,12 +380,12 @@ export interface ExperimentBasicApi {
readonly holdout: ExperimentHoldoutApi
/** @nullable */
readonly exposure_cohort: number | null
- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key). */
+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). 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
/**
- * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.
+ * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.
* @nullable
*/
excluded_variants?: string[] | null
@@ -701,12 +699,12 @@ export interface ExperimentApi {
holdout_id?: number | null
/** @nullable */
readonly exposure_cohort: number | null
- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key). */
+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). 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
/**
- * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.
+ * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.
* @nullable
*/
excluded_variants?: string[] | null
@@ -807,12 +805,12 @@ export interface PatchedExperimentApi {
holdout_id?: number | null
/** @nullable */
readonly exposure_cohort?: number | null
- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key). */
+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). 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
/**
- * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.
+ * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.
* @nullable
*/
excluded_variants?: string[] | null
diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yaml
index 005b1946ef27..c627205beadc 100644
--- a/products/experiments/mcp/tools.yaml
+++ b/products/experiments/mcp/tools.yaml
@@ -842,6 +842,7 @@ tools:
- description
- parameters
- running_time_calculation
+ - excluded_variants
- metrics
- metrics_secondary
- saved_metrics_ids
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f561f6853936..4d0d0d910616 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -20970,8 +20970,6 @@ export namespace Schemas {
export type ExperimentParametersVariantNotes = {[key: string]: string} | null;
export interface ExperimentParameters {
- /** Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. */
- excluded_variants?: string[] | null;
/** 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. */
@@ -21189,12 +21187,12 @@ export namespace Schemas {
holdout_id?: number | null;
/** @nullable */
readonly exposure_cohort: number | null;
- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key). */
+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). 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;
/**
- * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.
+ * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.
* @nullable
*/
excluded_variants?: string[] | null;
@@ -21298,12 +21296,12 @@ export namespace Schemas {
readonly holdout: ExperimentHoldout;
/** @nullable */
readonly exposure_cohort: number | null;
- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key). */
+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). 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;
/**
- * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.
+ * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.
* @nullable
*/
excluded_variants?: string[] | null;
@@ -37112,12 +37110,12 @@ export namespace Schemas {
holdout_id?: number | null;
/** @nullable */
readonly exposure_cohort?: number | null;
- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key). */
+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). 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;
/**
- * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.
+ * Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.
* @nullable
*/
excluded_variants?: string[] | null;
diff --git a/services/mcp/src/generated/experiments/api.ts b/services/mcp/src/generated/experiments/api.ts
index 45da22976a7f..22cef71e6554 100644
--- a/services/mcp/src/generated/experiments/api.ts
+++ b/services/mcp/src/generated/experiments/api.ts
@@ -260,12 +260,6 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod
parameters: zod
.union([
zod.object({
- excluded_variants: zod
- .union([zod.array(zod.string()), zod.null()])
- .optional()
- .describe(
- 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis.'
- ),
feature_flag_variants: zod
.union([
zod.array(
@@ -317,7 +311,7 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key).'
+ 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). Excluded variants live on the top-level `excluded_variants` field, not here.'
),
running_time_calculation: zod
.union([
@@ -380,7 +374,7 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod
.array(zod.string())
.nullish()
.describe(
- 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.'
+ 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.'
),
secondary_metrics: zod.unknown().optional(),
saved_metrics_ids: zod
@@ -2654,12 +2648,6 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod
parameters: zod
.union([
zod.object({
- excluded_variants: zod
- .union([zod.array(zod.string()), zod.null()])
- .optional()
- .describe(
- 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis.'
- ),
feature_flag_variants: zod
.union([
zod.array(
@@ -2711,7 +2699,7 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key).'
+ 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). Excluded variants live on the top-level `excluded_variants` field, not here.'
),
running_time_calculation: zod
.union([
@@ -2774,7 +2762,7 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod
.array(zod.string())
.nullish()
.describe(
- 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.'
+ 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.'
),
secondary_metrics: zod.unknown().optional(),
saved_metrics_ids: zod
@@ -5107,12 +5095,6 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod
parameters: zod
.union([
zod.object({
- excluded_variants: zod
- .union([zod.array(zod.string()), zod.null()])
- .optional()
- .describe(
- 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis.'
- ),
feature_flag_variants: zod
.union([
zod.array(
@@ -5164,7 +5146,7 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key).'
+ 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). Excluded variants live on the top-level `excluded_variants` field, not here.'
),
running_time_calculation: zod
.union([
@@ -5227,7 +5209,7 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod
.array(zod.string())
.nullish()
.describe(
- 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`; kept in sync with `parameters` during the deprecation window.'
+ 'Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`.'
),
secondary_metrics: zod.unknown().optional(),
saved_metrics_ids: zod
diff --git a/services/mcp/src/tools/generated/experiments.ts b/services/mcp/src/tools/generated/experiments.ts
index 4d1b2ae71656..77442c489838 100644
--- a/services/mcp/src/tools/generated/experiments.ts
+++ b/services/mcp/src/tools/generated/experiments.ts
@@ -736,7 +736,6 @@ const ExperimentUpdateSchema = ExperimentsPartialUpdateParams.omit({ project_id:
start_date: true,
end_date: true,
feature_flag_key: true,
- excluded_variants: true,
secondary_metrics: true,
filters: true,
deleted: true,
@@ -778,6 +777,9 @@ const experimentUpdate = (): ToolBase<typeof ExperimentUpdateSchema, WithPostHog
if (params.running_time_calculation !== undefined) {
body['running_time_calculation'] = params.running_time_calculation
}
+ if (params.excluded_variants !== undefined) {
+ body['excluded_variants'] = params.excluded_variants
+ }
if (params.saved_metrics_ids !== undefined) {
body['saved_metrics_ids'] = params.saved_metrics_ids
}
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 e61d56890f74..ff01988c1c32 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-create.json
@@ -232,20 +232,6 @@
"anyOf": [
{
"properties": {
- "excluded_variants": {
- "anyOf": [
- {
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "description": "Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis."
- },
"feature_flag_variants": {
"anyOf": [
{
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 349a8b9957f2..9cf61d47298d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
@@ -46,6 +46,20 @@
],
"description": "Description of the experiment hypothesis and expected outcomes."
},
+ "excluded_variants": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis. The baseline variant and holdout pseudo-variants cannot be excluded. Canonical home for what historically lived in `parameters.excluded_variants`."
+ },
"exposure_criteria": {
"anyOf": [
{
@@ -3558,20 +3572,6 @@
"anyOf": [
{
"properties": {
- "excluded_variants": {
- "anyOf": [
- {
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "description": "Variant keys to exclude from metric result calculations. Excluded variants are still served to users but omitted from statistical analysis."
- },
"feature_flag_variants": {
"anyOf": [
{
@@ -3671,7 +3671,7 @@
"type": "null"
}
],
- "description": "Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded), and `variant_notes` (free-text notes per variant, keyed by variant key)."
+ "description": "Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `custom_exposure_filter`, and `variant_notes` (free-text notes per variant, keyed by variant key). Excluded variants live on the top-level `excluded_variants` field, not here."
},
"running_time_calculation": {
"anyOf": [