: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(experiments): expose running_time_calculation on the api with dual-write (#62943)
Anders5b7c5d1fcba8
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 18c668efb77c..49ec26a6d2a9 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -18865,6 +18865,32 @@},"type": "object"},+ "ExperimentExposureEstimateConfig": {+ "additionalProperties": false,+ "description": "Exposure estimate settings for the experiment running-time calculator.",+ "properties": {+ "conversionRateInputType": {+ "description": "'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data.",+ "enum": ["manual", "automatic"],+ "type": "string"+ },+ "manualBaselineValue": {+ "description": "Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode.",+ "type": "number"+ },+ "manualExposureRate": {+ "description": "Manually entered estimate of users exposed to the experiment per day. Only used in manual mode.",+ "type": "number"+ },+ "manualMetricType": {+ "description": "Metric type the manual baseline value refers to. Only used in manual mode.",+ "enum": ["funnel", "mean_count", "mean_sum_or_avg"],+ "type": "string"+ }+ },+ "required": ["conversionRateInputType"],+ "type": "object"+ },"ExperimentExposureQuery": {"additionalProperties": false,"properties": {@@ -19960,6 +19986,36 @@],"type": "object"},+ "ExperimentRunningTimeCalculation": {+ "additionalProperties": false,+ "description": "Running-time calculator state for an experiment. Canonical home for keys that historically lived in `parameters`.",+ "properties": {+ "exposure_estimate_config": {+ "anyOf": [+ {+ "$ref": "#/definitions/ExperimentExposureEstimateConfig"+ },+ {+ "type": "null"+ }+ ],+ "description": "How the exposure estimate is configured: manual user-entered values or automatic from live experiment data."+ },+ "minimum_detectable_effect": {+ "description": "Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes.",+ "type": "number"+ },+ "recommended_running_time": {+ "description": "Estimated number of days needed to reach the recommended sample size.",+ "type": "number"+ },+ "recommended_sample_size": {+ "description": "Recommended number of exposed users needed for statistical significance.",+ "type": "number"+ }+ },+ "type": "object"+ },"ExperimentSignificanceCode": {"enum": ["significant", "not_enough_exposure", "low_win_probability", "high_loss", "high_p_value"],"type": "string"diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 8c2a23ba7ffd..d665e6f24ed4 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -3785,6 +3785,30 @@ export interface ExperimentParameters {excluded_variants?: string[]}+/** Exposure estimate settings for the experiment running-time calculator. */+export interface ExperimentExposureEstimateConfig {+ /** 'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data. */+ conversionRateInputType: 'manual' | 'automatic'+ /** Metric type the manual baseline value refers to. Only used in manual mode. */+ manualMetricType?: 'funnel' | 'mean_count' | 'mean_sum_or_avg'+ /** Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode. */+ manualBaselineValue?: number+ /** Manually entered estimate of users exposed to the experiment per day. Only used in manual mode. */+ manualExposureRate?: number+}++/** Running-time calculator state for an experiment. Canonical home for keys that historically lived in `parameters`. */+export interface ExperimentRunningTimeCalculation {+ /** Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. */+ minimum_detectable_effect?: number+ /** Estimated number of days needed to reach the recommended sample size. */+ recommended_running_time?: number+ /** Recommended number of exposed users needed for statistical significance. */+ recommended_sample_size?: number+ /** How the exposure estimate is configured: manual user-entered values or automatic from live experiment data. */+ exposure_estimate_config?: ExperimentExposureEstimateConfig | null+}+/** Slim exposure config for experiment API payloads. Discriminated by `kind`:* 'ExperimentEventExposureConfig' tracks exposure via a custom event,* 'ActionsNode' tracks exposure via an action. */diff --git a/posthog/schema.py b/posthog/schema.pyindex 3c2bf3a28ee6..24a9c619150e 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -56,6 +56,7 @@ from posthog.schema_enums import (ChartDisplayType as ChartDisplayType,ColorMode as ColorMode,Compare as Compare,+ ConversionRateInputType as ConversionRateInputType,CoreEventCategory as CoreEventCategory,CorrelationType as CorrelationType,CountPerActorMathType as CountPerActorMathType,@@ -144,6 +145,7 @@ from posthog.schema_enums import (LogSeverityLevel as LogSeverityLevel,LogsOrderBy as LogsOrderBy,LogsSparklineBreakdownBy as LogsSparklineBreakdownBy,+ ManualMetricType as ManualMetricType,MarketingAnalyticsBaseColumns as MarketingAnalyticsBaseColumns,MarketingAnalyticsColumnsSchemaNames as MarketingAnalyticsColumnsSchemaNames,MarketingAnalyticsConstants as MarketingAnalyticsConstants,@@ -1172,6 +1174,34 @@ class EventsQueryPersonColumn(BaseModel):uuid: str+class ExperimentExposureEstimateConfig(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ conversionRateInputType: ConversionRateInputType = Field(+ ...,+ description=(+ "'manual' when the baseline value and exposure rate were entered by hand,"+ " 'automatic' when derived from live experiment data."+ ),+ )+ manualBaselineValue: float | None = Field(+ default=None,+ description=(+ "Manually entered baseline metric value (a conversion percentage for funnel"+ " metrics). Only used in manual mode."+ ),+ )+ manualExposureRate: float | None = Field(+ default=None,+ description=("Manually entered estimate of users exposed to the experiment per day. Only used in manual mode."),+ )+ manualMetricType: ManualMetricType | None = Field(+ default=None,+ description=("Metric type the manual baseline value refers to. Only used in manual mode."),+ )++class ExperimentExposureTimeSeries(BaseModel):model_config = ConfigDict(extra="forbid",@@ -1220,6 +1250,33 @@ class ExperimentMetricOutlierHandling(BaseModel):)+class ExperimentRunningTimeCalculation(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ exposure_estimate_config: ExperimentExposureEstimateConfig | None = Field(+ default=None,+ description=(+ "How the exposure estimate is configured: manual user-entered values or"+ " automatic from live experiment data."+ ),+ )+ minimum_detectable_effect: float | None = Field(+ default=None,+ description=(+ "Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes."+ ),+ )+ recommended_running_time: float | None = Field(+ default=None,+ description=("Estimated number of days needed to reach the recommended sample size."),+ )+ recommended_sample_size: float | None = Field(+ default=None,+ description=("Recommended number of exposed users needed for statistical significance."),+ )++class ExperimentVariant(BaseModel):model_config = ConfigDict(extra="forbid",diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex beb954d07eb9..6ee747367f28 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -1079,6 +1079,17 @@ class StartHandling(StrEnum):LAST_SEEN = "last_seen"+class ConversionRateInputType(StrEnum):+ MANUAL = "manual"+ AUTOMATIC = "automatic"+++class ManualMetricType(StrEnum):+ FUNNEL = "funnel"+ MEAN_COUNT = "mean_count"+ MEAN_SUM_OR_AVG = "mean_sum_or_avg"++class ExperimentMetricGoal(StrEnum):INCREASE = "increase"DECREASE = "decrease"diff --git a/products/experiments/backend/experiment_service.py b/products/experiments/backend/experiment_service.pyindex 905156ecbace..47afcb178ae1 100644--- a/products/experiments/backend/experiment_service.py+++ b/products/experiments/backend/experiment_service.py@@ -231,6 +231,53 @@ class ExperimentService:if not variant_keys - set(excluded_variants) - {baseline_key}:raise ValidationError("at least one test variant must remain in analysis")+ RUNNING_TIME_CALCULATION_KEYS = (+ "minimum_detectable_effect",+ "recommended_running_time",+ "recommended_sample_size",+ "exposure_estimate_config",+ )++ @staticmethod+ def validate_running_time_calculation(value: dict | None) -> None:+ """Validate the running-time calculator config accepted by the API layer."""+ if not value:+ return+ if not isinstance(value, dict):+ raise ValidationError("running_time_calculation must be an object")++ unknown = set(value.keys()) - set(ExperimentService.RUNNING_TIME_CALCULATION_KEYS)+ if unknown:+ raise ValidationError(f"running_time_calculation got unknown keys: {sorted(unknown)}")++ for key in ("minimum_detectable_effect", "recommended_running_time", "recommended_sample_size"):+ number = value.get(key)+ if number is not None and (isinstance(number, bool) or not isinstance(number, int | float)):+ raise ValidationError(f"{key} must be a number")++ exposure_estimate_config = value.get("exposure_estimate_config")+ if exposure_estimate_config is not None and not isinstance(exposure_estimate_config, dict):+ raise ValidationError("exposure_estimate_config must be an object")++ @staticmethod+ def _running_time_calculation_from_parameters(parameters: dict | None) -> dict:+ return {+ key: (parameters or {})[key]+ for key in ExperimentService.RUNNING_TIME_CALCULATION_KEYS+ if key in (parameters or {})+ }++ @staticmethod+ def _merge_running_time_calculation_into_parameters(parameters: dict | None, calculation: dict | None) -> dict:+ """Replace the legacy calculator keys in `parameters` with the canonical calculation values."""+ merged = {+ key: value+ for key, value in (parameters or {}).items()+ if key not in ExperimentService.RUNNING_TIME_CALCULATION_KEYS+ }+ merged.update(calculation or {})+ return merged+EXPOSURE_CONFIG_KINDS = ("ExperimentEventExposureConfig", "ActionsNode")EXPOSURE_CONFIG_HINT = (@@ -671,6 +718,7 @@ class ExperimentService:description: str = "",type: str = "product",parameters: dict | None = None,+ running_time_calculation: dict | None = None,metrics: list[dict] | None = None,metrics_secondary: list[dict] | None = None,secondary_metrics: list[dict] | None = None,@@ -709,6 +757,13 @@ class ExperimentService:metrics_secondary = self._assign_uuids_to_metrics(metrics_secondary, seen=seen_metric_uuids)self.validate_variant_shapes(parameters)self.validate_variant_percentages(parameters)+ self.validate_running_time_calculation(running_time_calculation)+ # Dual-write during the parameters deprecation window: running_time_calculation is+ # canonical, but the legacy calculator keys in `parameters` stay in sync for old readers.+ if running_time_calculation is not None:+ parameters = self._merge_running_time_calculation_into_parameters(parameters, running_time_calculation)+ else:+ running_time_calculation = self._running_time_calculation_from_parameters(parameters)self.validate_experiment_metrics(metrics)self.validate_experiment_metrics(metrics_secondary)self.validate_metric_action_ids(metrics, self.team.id)@@ -791,6 +846,7 @@ class ExperimentService:"description": description,"type": type,"parameters": parameters,+ "running_time_calculation": running_time_calculation,"metrics": metrics if metrics is not None else [],"metrics_secondary": metrics_secondary if metrics_secondary is not None else [],"secondary_metrics": secondary_metrics if secondary_metrics is not None else [],@@ -1991,6 +2047,21 @@ class ExperimentService:feature_flag.active = Truefeature_flag.save()+ # --- running-time calculation dual-write ----------------------------+ # During the parameters deprecation window, keep running_time_calculation and+ # the legacy calculator keys in `parameters` in sync. `parameters` is replaced+ # wholesale on update, so derive the counterpart from whichever side this+ # update carries (running_time_calculation wins when both are sent).+ if "running_time_calculation" in update_data:+ update_data["parameters"] = self._merge_running_time_calculation_into_parameters(+ update_data.get("parameters", experiment.parameters),+ update_data["running_time_calculation"],+ )+ elif "parameters" in update_data:+ update_data["running_time_calculation"] = self._running_time_calculation_from_parameters(+ update_data["parameters"]+ )+# --- apply changes and save ----------------------------------------for attr, value in update_data.items():setattr(experiment, attr, value)@@ -2043,6 +2114,7 @@ class ExperimentService:"end_date","filters","parameters",+ "running_time_calculation","archived","deleted","secondary_metrics",@@ -2067,6 +2139,8 @@ class ExperimentService:if extra_keys:raise ValidationError(f"Can't update keys: {', '.join(sorted(extra_keys))} on Experiment")+ self.validate_running_time_calculation(update_data.get("running_time_calculation"))+if not experiment.is_draft:if "feature_flag_variants" in update_data.get("parameters", {}):if len(update_data["parameters"]["feature_flag_variants"]) != len(feature_flag.variants):diff --git a/products/experiments/backend/facade/api.py b/products/experiments/backend/facade/api.pyindex 7a66d1e2eb31..b57eda56b2d4 100644--- a/products/experiments/backend/facade/api.py+++ b/products/experiments/backend/facade/api.py@@ -58,6 +58,7 @@ def create_experiment(*, team: Team, user: User, input_dto: CreateExperimentInpudescription=input_dto.description,type=input_dto.type,parameters=input_dto.parameters,+ running_time_calculation=input_dto.running_time_calculation,metrics=input_dto.metrics,metrics_secondary=input_dto.metrics_secondary,secondary_metrics=input_dto.secondary_metrics,diff --git a/products/experiments/backend/facade/contracts.py b/products/experiments/backend/facade/contracts.pyindex b0c743ee3a25..e28918b18c53 100644--- a/products/experiments/backend/facade/contracts.py+++ b/products/experiments/backend/facade/contracts.py@@ -30,6 +30,10 @@ class CreateExperimentInput:# Feature flag configurationparameters: dict[str, Any] | None = None+ # Running-time calculator state (minimum_detectable_effect, recommended_running_time,+ # recommended_sample_size, exposure_estimate_config)+ running_time_calculation: dict[str, Any] | None = None+# Metrics configurationmetrics: list[dict] | None = Nonemetrics_secondary: list[dict] | None = Nonediff --git a/products/experiments/backend/presentation/serializers.py b/products/experiments/backend/presentation/serializers.pyindex 95de5b952d92..03b928e310be 100644--- a/products/experiments/backend/presentation/serializers.py+++ b/products/experiments/backend/presentation/serializers.py@@ -13,7 +13,12 @@ from pydantic import RootModel as PydanticRootModelfrom rest_framework import serializersfrom rest_framework.exceptions import ValidationError-from posthog.schema import ExperimentApiExposureCriteria, ExperimentApiMetric, ExperimentParameters+from posthog.schema import (+ ExperimentApiExposureCriteria,+ ExperimentApiMetric,+ ExperimentParameters,+ ExperimentRunningTimeCalculation,+)from posthog.api.scoped_related_fields import TeamScopedPrimaryKeyRelatedFieldfrom posthog.api.shared import UserBasicSerializer@@ -95,6 +100,11 @@ class ExperimentExposureCriteriaField(serializers.JSONField):pass+@extend_schema_field(ExperimentRunningTimeCalculation) # type: ignore[arg-type]+class ExperimentRunningTimeCalculationField(serializers.JSONField):+ pass++class ExperimentSerializer(UserAccessControlSerializerMixin, serializers.ModelSerializer):feature_flag_key = serializers.CharField(source="get_feature_flag_key",@@ -153,7 +163,20 @@ class ExperimentSerializer(UserAccessControlSerializerMixin, serializers.ModelSe"`recommended_running_time`, `recommended_sample_size`, ""`custom_exposure_filter`, and `excluded_variants` ""(list of variant keys to drop from statistical analysis; "- "the baseline variant and holdout pseudo-variants cannot be excluded)."+ "the baseline variant and holdout pseudo-variants cannot be excluded). "+ "The running-time calculator keys (`minimum_detectable_effect`, "+ "`recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) "+ "are deprecated here — prefer `running_time_calculation`."+ ),+ )+ running_time_calculation = ExperimentRunningTimeCalculationField(+ required=False,+ allow_null=True,+ help_text=(+ "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`; values are kept in sync with `parameters` "+ "during the deprecation window."),)metrics = ExperimentMetricsField(@@ -241,6 +264,7 @@ class ExperimentSerializer(UserAccessControlSerializerMixin, serializers.ModelSe"holdout_id","exposure_cohort","parameters",+ "running_time_calculation","secondary_metrics","saved_metrics","saved_metrics_ids",@@ -352,6 +376,10 @@ class ExperimentSerializer(UserAccessControlSerializerMixin, serializers.ModelSeExperimentService.validate_experiment_parameters(value)return value+ def validate_running_time_calculation(self, value):+ ExperimentService.validate_running_time_calculation(value)+ return value+def validate_exposure_criteria(self, exposure_criteria: dict | None):ExperimentService.validate_experiment_exposure_criteria(exposure_criteria)return exposure_criteria@@ -383,6 +411,7 @@ class ExperimentSerializer(UserAccessControlSerializerMixin, serializers.ModelSedescription=self.validated_data.get("description", ""),type=self.validated_data.get("type", "product"),parameters=self.validated_data.get("parameters"),+ running_time_calculation=self.validated_data.get("running_time_calculation"),metrics=self.validated_data.get("metrics"),metrics_secondary=self.validated_data.get("metrics_secondary"),secondary_metrics=self.validated_data.get("secondary_metrics"),@@ -420,6 +449,7 @@ class ExperimentSerializer(UserAccessControlSerializerMixin, serializers.ModelSe"description","type","parameters",+ "running_time_calculation","metrics","metrics_secondary","secondary_metrics",diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.pyindex 8ab01fce82ee..fe9c9f804339 100644--- a/products/experiments/backend/test/test_presentation_api.py+++ b/products/experiments/backend/test/test_presentation_api.py@@ -6700,3 +6700,173 @@ class TestExperimentParametersFieldMutation(APILicensedTest):{"key": "test", "rollout_percentage": 50},]}+++class TestExperimentRunningTimeCalculation(APILicensedTest):+ EXPOSURE_ESTIMATE_CONFIG = {+ "conversionRateInputType": "manual",+ "manualMetricType": "funnel",+ "manualBaselineValue": 5,+ "manualExposureRate": 100,+ }++ def _create_experiment(self, **overrides: Any) -> dict:+ payload: dict[str, Any] = {+ "name": "Running time experiment",+ "feature_flag_key": "running-time-flag",+ "filters": {"events": [{"order": 0, "id": "$pageview"}], "properties": []},+ **overrides,+ }+ response = self.client.post(f"/api/projects/{self.team.id}/experiments/", payload)+ self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())+ return response.json()++ def test_create_with_legacy_parameters_populates_running_time_calculation(self):+ created = self._create_experiment(+ parameters={+ "minimum_detectable_effect": 25,+ "recommended_running_time": 14,+ "recommended_sample_size": 5000,+ "exposure_estimate_config": self.EXPOSURE_ESTIMATE_CONFIG,+ }+ )++ expected = {+ "minimum_detectable_effect": 25,+ "recommended_running_time": 14,+ "recommended_sample_size": 5000,+ "exposure_estimate_config": self.EXPOSURE_ESTIMATE_CONFIG,+ }+ self.assertEqual(created["running_time_calculation"], expected)+ self.assertEqual(created["parameters"]["minimum_detectable_effect"], 25)++ experiment = Experiment.objects.get(pk=created["id"])+ self.assertEqual(experiment.running_time_calculation, expected)++ def test_create_with_running_time_calculation_mirrors_into_parameters(self):+ created = self._create_experiment(+ running_time_calculation={+ "minimum_detectable_effect": 20,+ "exposure_estimate_config": self.EXPOSURE_ESTIMATE_CONFIG,+ }+ )++ self.assertEqual(+ created["running_time_calculation"],+ {"minimum_detectable_effect": 20, "exposure_estimate_config": self.EXPOSURE_ESTIMATE_CONFIG},+ )+ self.assertEqual(created["parameters"]["minimum_detectable_effect"], 20)+ self.assertEqual(created["parameters"]["exposure_estimate_config"], self.EXPOSURE_ESTIMATE_CONFIG)++ experiment = Experiment.objects.get(pk=created["id"])+ assert experiment.parameters is not None+ self.assertEqual(experiment.parameters["minimum_detectable_effect"], 20)++ def test_update_running_time_calculation_merges_into_parameters(self):+ created = self._create_experiment(+ parameters={+ "feature_flag_variants": [+ {"key": "control", "rollout_percentage": 50},+ {"key": "test", "rollout_percentage": 50},+ ],+ "minimum_detectable_effect": 25,+ "recommended_sample_size": 5000,+ }+ )++ response = self.client.patch(+ f"/api/projects/{self.team.id}/experiments/{created['id']}/",+ {"running_time_calculation": {"minimum_detectable_effect": 10, "recommended_running_time": 7}},+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())++ experiment = Experiment.objects.get(pk=created["id"])+ self.assertEqual(+ experiment.running_time_calculation,+ {"minimum_detectable_effect": 10, "recommended_running_time": 7},+ )+ # Other parameters keys survive; calculator keys are replaced wholesale+ assert experiment.parameters is not None+ self.assertEqual(len(experiment.parameters["feature_flag_variants"]), 2)+ self.assertEqual(experiment.parameters["minimum_detectable_effect"], 10)+ self.assertEqual(experiment.parameters["recommended_running_time"], 7)+ self.assertNotIn("recommended_sample_size", experiment.parameters)++ def test_update_running_time_calculation_does_not_touch_feature_flag(self):+ variants = [+ {"key": "control", "rollout_percentage": 34},+ {"key": "test_a", "rollout_percentage": 33},+ {"key": "test_b", "rollout_percentage": 33},+ ]+ created = self._create_experiment(parameters={"feature_flag_variants": variants})+ flag = FeatureFlag.objects.get(key="running-time-flag")+ self.assertEqual(len(flag.filters["multivariate"]["variants"]), 3)++ response = self.client.patch(+ f"/api/projects/{self.team.id}/experiments/{created['id']}/",+ {"running_time_calculation": {"minimum_detectable_effect": 15}},+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())++ flag.refresh_from_db()+ self.assertEqual(len(flag.filters["multivariate"]["variants"]), 3)++ def test_update_parameters_derives_running_time_calculation(self):+ created = self._create_experiment()++ response = self.client.patch(+ f"/api/projects/{self.team.id}/experiments/{created['id']}/",+ {"parameters": {"minimum_detectable_effect": 30, "recommended_sample_size": 1000}},+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())++ experiment = Experiment.objects.get(pk=created["id"])+ self.assertEqual(+ experiment.running_time_calculation,+ {"minimum_detectable_effect": 30, "recommended_sample_size": 1000},+ )++ # parameters replaces wholesale, so dropping the keys clears the canonical field too+ response = self.client.patch(+ f"/api/projects/{self.team.id}/experiments/{created['id']}/",+ {"parameters": {}},+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())+ experiment.refresh_from_db()+ self.assertEqual(experiment.running_time_calculation, {})++ def test_running_time_calculation_wins_when_both_sent(self):+ created = self._create_experiment()++ response = self.client.patch(+ f"/api/projects/{self.team.id}/experiments/{created['id']}/",+ {+ "parameters": {"minimum_detectable_effect": 99},+ "running_time_calculation": {"minimum_detectable_effect": 11},+ },+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())++ experiment = Experiment.objects.get(pk=created["id"])+ self.assertEqual(experiment.running_time_calculation, {"minimum_detectable_effect": 11})+ assert experiment.parameters is not None+ self.assertEqual(experiment.parameters["minimum_detectable_effect"], 11)++ @parameterized.expand(+ [+ ("unknown_key", {"not_a_real_key": 1}),+ ("non_numeric_mde", {"minimum_detectable_effect": "twenty"}),+ ("boolean_running_time", {"recommended_running_time": True}),+ ("non_object_exposure_config", {"exposure_estimate_config": "manual"}),+ ]+ )+ def test_invalid_running_time_calculation_rejected(self, _name: str, value: dict):+ response = self.client.post(+ f"/api/projects/{self.team.id}/experiments/",+ {+ "name": "Invalid running time",+ "feature_flag_key": "invalid-running-time-flag",+ "running_time_calculation": value,+ },+ )+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.tsindex 1284c3f4d273..0f5b9e71d6c9 100644--- a/products/experiments/frontend/generated/api.schemas.ts+++ b/products/experiments/frontend/generated/api.schemas.ts@@ -246,6 +246,43 @@ export interface ExperimentParametersApi {rollout_percentage?: number | null}+export type ConversionRateInputTypeApi = (typeof ConversionRateInputTypeApi)[keyof typeof ConversionRateInputTypeApi]++export const ConversionRateInputTypeApi = {+ Manual: 'manual',+ Automatic: 'automatic',+} as const++export type ManualMetricTypeApi = (typeof ManualMetricTypeApi)[keyof typeof ManualMetricTypeApi]++export const ManualMetricTypeApi = {+ Funnel: 'funnel',+ MeanCount: 'mean_count',+ MeanSumOrAvg: 'mean_sum_or_avg',+} as const++export interface ExperimentExposureEstimateConfigApi {+ /** 'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data. */+ conversionRateInputType: ConversionRateInputTypeApi+ /** Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode. */+ manualBaselineValue?: number | null+ /** Manually entered estimate of users exposed to the experiment per day. Only used in manual mode. */+ manualExposureRate?: number | null+ /** Metric type the manual baseline value refers to. Only used in manual mode. */+ manualMetricType?: ManualMetricTypeApi | null+}++export interface ExperimentRunningTimeCalculationApi {+ /** How the exposure estimate is configured: manual user-entered values or automatic from live experiment data. */+ exposure_estimate_config?: ExperimentExposureEstimateConfigApi | null+ /** Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. */+ minimum_detectable_effect?: number | null+ /** Estimated number of days needed to reach the recommended sample size. */+ recommended_running_time?: number | null+ /** Recommended number of exposed users needed for statistical significance. */+ recommended_sample_size?: number | null+}+export interface ExperimentToSavedMetricApi {readonly id: numberexperiment: number@@ -531,8 +568,10 @@ export interface ExperimentApi {holdout_id?: number | null/** @nullable */readonly exposure_cohort: number | null- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). */+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`. */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`; values are kept in sync with `parameters` during the deprecation window. */+ running_time_calculation?: ExperimentRunningTimeCalculationApi | nullsecondary_metrics?: unknownreadonly saved_metrics: readonly ExperimentToSavedMetricApi[]/**@@ -631,8 +670,10 @@ export interface PatchedExperimentApi {holdout_id?: number | null/** @nullable */readonly exposure_cohort?: number | null- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). */+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`. */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`; values are kept in sync with `parameters` during the deprecation window. */+ running_time_calculation?: ExperimentRunningTimeCalculationApi | nullsecondary_metrics?: unknownreadonly saved_metrics?: readonly ExperimentToSavedMetricApi[]/**diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 4a212722ea9f..fb9523b81144 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -12840,6 +12840,14 @@ export namespace Schemas {has_misconfigured: boolean;}+ export type ConversionRateInputType = typeof ConversionRateInputType[keyof typeof ConversionRateInputType];+++ export const ConversionRateInputType = {+ Manual: 'manual',+ Automatic: 'automatic',+ } as const;+/*** * `0` - Disabled* * `1` - Stateless@@ -18452,6 +18460,37 @@ export namespace Schemas {rollout_percentage?: number | null;}+ export type ManualMetricType = typeof ManualMetricType[keyof typeof ManualMetricType];+++ export const ManualMetricType = {+ Funnel: 'funnel',+ MeanCount: 'mean_count',+ MeanSumOrAvg: 'mean_sum_or_avg',+ } as const;++ export interface ExperimentExposureEstimateConfig {+ /** 'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data. */+ conversionRateInputType: ConversionRateInputType;+ /** Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode. */+ manualBaselineValue?: number | null;+ /** Manually entered estimate of users exposed to the experiment per day. Only used in manual mode. */+ manualExposureRate?: number | null;+ /** Metric type the manual baseline value refers to. Only used in manual mode. */+ manualMetricType?: ManualMetricType | null;+ }++ export interface ExperimentRunningTimeCalculation {+ /** How the exposure estimate is configured: manual user-entered values or automatic from live experiment data. */+ exposure_estimate_config?: ExperimentExposureEstimateConfig | null;+ /** Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes. */+ minimum_detectable_effect?: number | null;+ /** Estimated number of days needed to reach the recommended sample size. */+ recommended_running_time?: number | null;+ /** Recommended number of exposed users needed for statistical significance. */+ recommended_sample_size?: number | null;+ }+export interface ExperimentToSavedMetric {readonly id: number;experiment: number;@@ -18619,8 +18658,10 @@ export namespace Schemas {holdout_id?: number | null;/** @nullable */readonly exposure_cohort: number | null;- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). */+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`. */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`; values are kept in sync with `parameters` during the deprecation window. */+ running_time_calculation?: ExperimentRunningTimeCalculation | null;secondary_metrics?: unknown;readonly saved_metrics: readonly ExperimentToSavedMetric[];/**@@ -32157,8 +32198,10 @@ export namespace Schemas {holdout_id?: number | null;/** @nullable */readonly exposure_cohort?: number | null;- /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). */+ /** Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`. */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`; values are kept in sync with `parameters` during the deprecation window. */+ running_time_calculation?: ExperimentRunningTimeCalculation | null;secondary_metrics?: unknown;readonly saved_metrics?: readonly ExperimentToSavedMetric[];/**diff --git a/services/mcp/src/generated/experiments/api.ts b/services/mcp/src/generated/experiments/api.tsindex 62b0363cc988..0d0366951152 100644--- a/services/mcp/src/generated/experiments/api.ts+++ b/services/mcp/src/generated/experiments/api.ts@@ -304,7 +304,64 @@ export const ExperimentsCreateBody = /* @__PURE__ */ zod]).optional().describe(- 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded).'+ 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`.'+ ),+ running_time_calculation: zod+ .union([+ zod.object({+ exposure_estimate_config: zod+ .union([+ zod.object({+ conversionRateInputType: zod+ .enum(['manual', 'automatic'])+ .describe(+ "'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data."+ ),+ manualBaselineValue: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe(+ 'Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode.'+ ),+ manualExposureRate: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe(+ 'Manually entered estimate of users exposed to the experiment per day. Only used in manual mode.'+ ),+ manualMetricType: zod+ .union([zod.enum(['funnel', 'mean_count', 'mean_sum_or_avg']), zod.null()])+ .optional()+ .describe(+ 'Metric type the manual baseline value refers to. Only used in manual mode.'+ ),+ }),+ zod.null(),+ ])+ .optional()+ .describe(+ 'How the exposure estimate is configured: manual user-entered values or automatic from live experiment data.'+ ),+ 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.'+ ),+ recommended_running_time: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe('Estimated number of days needed to reach the recommended sample size.'),+ recommended_sample_size: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe('Recommended number of exposed users needed for statistical significance.'),+ }),+ zod.null(),+ ])+ .optional()+ .describe(+ '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`; values are kept in sync with `parameters` during the deprecation window.'),secondary_metrics: zod.unknown().optional(),saved_metrics_ids: zod@@ -2603,7 +2660,64 @@ export const ExperimentsPartialUpdateBody = /* @__PURE__ */ zod]).optional().describe(- 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded).'+ 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`.'+ ),+ running_time_calculation: zod+ .union([+ zod.object({+ exposure_estimate_config: zod+ .union([+ zod.object({+ conversionRateInputType: zod+ .enum(['manual', 'automatic'])+ .describe(+ "'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data."+ ),+ manualBaselineValue: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe(+ 'Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode.'+ ),+ manualExposureRate: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe(+ 'Manually entered estimate of users exposed to the experiment per day. Only used in manual mode.'+ ),+ manualMetricType: zod+ .union([zod.enum(['funnel', 'mean_count', 'mean_sum_or_avg']), zod.null()])+ .optional()+ .describe(+ 'Metric type the manual baseline value refers to. Only used in manual mode.'+ ),+ }),+ zod.null(),+ ])+ .optional()+ .describe(+ 'How the exposure estimate is configured: manual user-entered values or automatic from live experiment data.'+ ),+ 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.'+ ),+ recommended_running_time: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe('Estimated number of days needed to reach the recommended sample size.'),+ recommended_sample_size: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe('Recommended number of exposed users needed for statistical significance.'),+ }),+ zod.null(),+ ])+ .optional()+ .describe(+ '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`; values are kept in sync with `parameters` during the deprecation window.'),secondary_metrics: zod.unknown().optional(),saved_metrics_ids: zod@@ -4948,7 +5062,64 @@ export const ExperimentsDuplicateCreateBody = /* @__PURE__ */ zod]).optional().describe(- 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded).'+ 'Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`.'+ ),+ running_time_calculation: zod+ .union([+ zod.object({+ exposure_estimate_config: zod+ .union([+ zod.object({+ conversionRateInputType: zod+ .enum(['manual', 'automatic'])+ .describe(+ "'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data."+ ),+ manualBaselineValue: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe(+ 'Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode.'+ ),+ manualExposureRate: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe(+ 'Manually entered estimate of users exposed to the experiment per day. Only used in manual mode.'+ ),+ manualMetricType: zod+ .union([zod.enum(['funnel', 'mean_count', 'mean_sum_or_avg']), zod.null()])+ .optional()+ .describe(+ 'Metric type the manual baseline value refers to. Only used in manual mode.'+ ),+ }),+ zod.null(),+ ])+ .optional()+ .describe(+ 'How the exposure estimate is configured: manual user-entered values or automatic from live experiment data.'+ ),+ 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.'+ ),+ recommended_running_time: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe('Estimated number of days needed to reach the recommended sample size.'),+ recommended_sample_size: zod+ .union([zod.number(), zod.null()])+ .optional()+ .describe('Recommended number of exposed users needed for statistical significance.'),+ }),+ zod.null(),+ ])+ .optional()+ .describe(+ '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`; values are kept in sync with `parameters` during the deprecation window.'),secondary_metrics: zod.unknown().optional(),saved_metrics_ids: zoddiff --git a/services/mcp/src/tools/generated/experiments.ts b/services/mcp/src/tools/generated/experiments.tsindex d6c986e75fb6..9b81efb97869 100644--- a/services/mcp/src/tools/generated/experiments.ts+++ b/services/mcp/src/tools/generated/experiments.ts@@ -106,6 +106,7 @@ const experimentCopyToProject = (): ToolBase<typeof ExperimentCopyToProjectSchemconst ExperimentCreateSchema = ExperimentsCreateBody.omit({start_date: true,end_date: true,+ running_time_calculation: true,secondary_metrics: true,saved_metrics_ids: true,filters: true,@@ -235,6 +236,9 @@ const experimentDuplicate = (): ToolBase<typeof ExperimentDuplicateSchema, unknoif (params.parameters !== undefined) {body['parameters'] = params.parameters}+ if (params.running_time_calculation !== undefined) {+ body['running_time_calculation'] = params.running_time_calculation+ }if (params.secondary_metrics !== undefined) {body['secondary_metrics'] = params.secondary_metrics}@@ -723,6 +727,7 @@ const ExperimentUpdateSchema = ExperimentsPartialUpdateParams.omit({ project_id:start_date: true,end_date: true,feature_flag_key: true,+ running_time_calculation: true,secondary_metrics: true,saved_metrics_ids: true,filters: true,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-duplicate.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-duplicate.jsonindex c3ef87cab10a..73df8126d15c 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-duplicate.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-duplicate.json@@ -3651,9 +3651,108 @@"type": "null"}],- "description": "Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded)."+ "description": "Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`."},"primary_metrics_ordered_uuids": {},+ "running_time_calculation": {+ "anyOf": [+ {+ "properties": {+ "exposure_estimate_config": {+ "anyOf": [+ {+ "properties": {+ "conversionRateInputType": {+ "description": "'manual' when the baseline value and exposure rate were entered by hand, 'automatic' when derived from live experiment data.",+ "enum": ["manual", "automatic"],+ "type": "string"+ },+ "manualBaselineValue": {+ "anyOf": [+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ],+ "description": "Manually entered baseline metric value (a conversion percentage for funnel metrics). Only used in manual mode."+ },+ "manualExposureRate": {+ "anyOf": [+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ],+ "description": "Manually entered estimate of users exposed to the experiment per day. Only used in manual mode."+ },+ "manualMetricType": {+ "anyOf": [+ {+ "enum": ["funnel", "mean_count", "mean_sum_or_avg"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Metric type the manual baseline value refers to. Only used in manual mode."+ }+ },+ "required": ["conversionRateInputType"],+ "type": "object"+ },+ {+ "type": "null"+ }+ ],+ "description": "How the exposure estimate is configured: manual user-entered values or automatic from live experiment data."+ },+ "minimum_detectable_effect": {+ "anyOf": [+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ],+ "description": "Minimum detectable effect as a percentage. Lower values need more users but catch smaller changes."+ },+ "recommended_running_time": {+ "anyOf": [+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ],+ "description": "Estimated number of days needed to reach the recommended sample size."+ },+ "recommended_sample_size": {+ "anyOf": [+ {+ "type": "number"+ },+ {+ "type": "null"+ }+ ],+ "description": "Recommended number of exposed users needed for statistical significance."+ }+ },+ "type": "object"+ },+ {+ "type": "null"+ }+ ],+ "description": "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`; values are kept in sync with `parameters` during the deprecation window."+ },"saved_metrics_ids": {"anyOf": [{diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.jsonindex ac7045be4bff..e8b7efa88a04 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json@@ -3619,7 +3619,7 @@"type": "null"}],- "description": "Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded)."+ "description": "Experiment parameters JSON. Supported keys include `feature_flag_variants`, `rollout_percentage`, `minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `custom_exposure_filter`, and `excluded_variants` (list of variant keys to drop from statistical analysis; the baseline variant and holdout pseudo-variants cannot be excluded). The running-time calculator keys (`minimum_detectable_effect`, `recommended_running_time`, `recommended_sample_size`, `exposure_estimate_config`) are deprecated here — prefer `running_time_calculation`."},"stats_config": {},"update_feature_flag_params": {