: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
chore(experiments): resolve the experiment-flag-cleanup-pr flag to on (#101452)
Anders872ced79fbce
diff --git a/products/experiments/backend/experiment_service.py b/products/experiments/backend/experiment_service.pyindex 7a970d327621..0a4a4b2a869d 100644--- a/products/experiments/backend/experiment_service.py+++ b/products/experiments/backend/experiment_service.py@@ -19,7 +19,6 @@ from django.utils import timezoneimport pydanticimport structlog-import posthoganalyticsfrom rest_framework import statusfrom rest_framework.exceptions import APIException, PermissionDenied, ValidationError@@ -120,10 +119,6 @@ from ee.clickhouse.views.experiment_saved_metrics import ExperimentToSavedMetriclogger = structlog.get_logger(__name__)-# Feature flag (in PostHog's internal project) gating which teams auto-open flag-cleanup PRs when an-# experiment ends. Evaluated as a project-group flag — see _cleanup_pr_flag_enabled.-EXPERIMENT_CLEANUP_PR_FLAG = "experiment-flag-cleanup-pr"-CleanupRepositorySource = Literal["explicit", "team_default", "single_repo", "ambiguous", "no_integration"]@@ -138,7 +133,7 @@ class CleanupRequestSummary(TypedDict):attempted: boolrepository_source: CleanupRepositorySource | None- skip_reason: Literal["no_conclusion", "flag_disabled", "no_repository", "error"] | None+ skip_reason: Literal["no_conclusion", "no_repository", "error"] | Noneconfident: bool | None@@ -2751,21 +2746,6 @@ class ExperimentService:return experiment- def _cleanup_pr_flag_enabled(self) -> bool:- # Our backend's posthoganalytics client points at PostHog's own internal project, so we gate a- # customer team by passing it as the "project" group and targeting that group's id on the flag.- # Local eval keeps this off the request's hot path (definitions refresh on a short poll).- return bool(- posthoganalytics.feature_enabled(- EXPERIMENT_CLEANUP_PR_FLAG,- str(self.team.id),- groups={"project": str(self.team.id)},- group_properties={"project": {"id": str(self.team.id)}},- only_evaluate_locally=True,- send_feature_flag_events=False,- )- )-def _maybe_open_cleanup_pr(self,experiment: Experiment,@@ -2773,8 +2753,8 @@ class ExperimentService:requested_repository: str | None = None,set_repository_as_team_default: bool = False,) -> CleanupRequestSummary:- """When opted in (the checkbox) and the team's gate flag is on, open a draft PR that removes the- experiment's feature-flag code, via the Tasks engine.+ """When opted in (the checkbox), open a draft PR that removes the experiment's feature-flag+ code, via the Tasks engine.Deferred to after commit (so a rolled-back end never opens a PR) and wrapped so it can neverbreak ending an experiment.@@ -2792,9 +2772,6 @@ class ExperimentService:if not conclusion:summary["skip_reason"] = "no_conclusion"return summary- if not self._cleanup_pr_flag_enabled():- summary["skip_reason"] = "flag_disabled"- return summaryflag_key = experiment.get_feature_flag_key()target = self.get_cleanup_repository_target(experiment, requested_repository=requested_repository)diff --git a/products/experiments/backend/presentation/serializers.py b/products/experiments/backend/presentation/serializers.pyindex d96f9f4a515f..f2ce0fd4b954 100644--- a/products/experiments/backend/presentation/serializers.py+++ b/products/experiments/backend/presentation/serializers.py@@ -1127,8 +1127,8 @@ class EndExperimentSerializer(serializers.Serializer):default=False,help_text=("When true, open a draft pull request that removes the experiment's feature-flag code "- "from the linked repository. Requires the requesting user to have access to PostHog Desktop "- "(403 otherwise). Only acts for allowlisted teams; ignored otherwise."+ "from the linked repository. A personal API key needs the task:write scope (403 otherwise). "+ "Skipped when the conclusion is empty, or when no connected repository can be resolved."),)repository = serializers.CharField(diff --git a/products/experiments/backend/test/test_experiment_cleanup_pr.py b/products/experiments/backend/test/test_experiment_cleanup_pr.pyindex 6f4c31c66cfd..9b3d1631bb84 100644--- a/products/experiments/backend/test/test_experiment_cleanup_pr.py+++ b/products/experiments/backend/test/test_experiment_cleanup_pr.py@@ -51,34 +51,29 @@ class TestExperimentCleanupPr(APIBaseTest):@parameterized.expand([- # (name, flag_enabled, open_cleanup_pr, conclusion, expect_task_created, expected_skip_reason)- ("flag_on_and_opted_in", True, True, "won", True, None),- ("not_opted_in", True, False, "won", False, None),- ("flag_off", False, True, "won", False, "flag_disabled"),- ("no_conclusion", True, True, None, False, "no_conclusion"),+ # (name, open_cleanup_pr, conclusion, expect_task_created, expected_skip_reason)+ ("opted_in", True, "won", True, None),+ ("not_opted_in", False, "won", False, None),+ ("no_conclusion", True, None, False, "no_conclusion"),])@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled")@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")- def test_cleanup_pr_fires_only_when_flag_on_and_opted_in(+ def test_cleanup_pr_fires_only_when_opted_in(self,_name,- flag_enabled,open_cleanup_pr,conclusion,expect_task_created,expected_skip_reason,mock_resolve_github,mock_create_task,- mock_feature_enabled,mock_report,):mock_resolve_github.return_value = SimpleNamespace(list_all_cached_repositories=lambda max_repos: [{"full_name": "posthog/posthog"}])- mock_feature_enabled.return_value = flag_enabledtask_id = uuid4()mock_create_task.return_value = SimpleNamespace(task_id=task_id)experiment = self._running_experiment(repository="posthog/posthog")@@ -177,7 +172,6 @@ class TestExperimentCleanupPr(APIBaseTest):])@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")def test_cleanup_repository_resolution(@@ -189,7 +183,6 @@ class TestExperimentCleanupPr(APIBaseTest):expected_repository,mock_resolve_github,mock_create_task,- _mock_feature_enabled,_mock_report,):if cached_repos is None:@@ -222,14 +215,12 @@ class TestExperimentCleanupPr(APIBaseTest):self.assertIsNotNone(experiment.flag_cleanup_task_id)@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")def test_repository_picked_at_end_time_targets_the_task(self,mock_resolve_github,mock_create_task,- _mock_feature_enabled,_mock_report,):# Several cached repos would otherwise be ambiguous and skip the cleanup — the@@ -254,14 +245,12 @@ class TestExperimentCleanupPr(APIBaseTest):self.assertEqual(experiment.repository, "acme/api")@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")def test_repository_outside_the_installation_skips_and_is_not_persisted(self,mock_resolve_github,mock_create_task,- _mock_feature_enabled,_mock_report,):mock_resolve_github.return_value = SimpleNamespace(@@ -290,7 +279,6 @@ class TestExperimentCleanupPr(APIBaseTest):])@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")def test_set_repository_as_team_default(@@ -300,7 +288,6 @@ class TestExperimentCleanupPr(APIBaseTest):expect_default_saved,mock_resolve_github,mock_create_task,- _mock_feature_enabled,_mock_report,):mock_resolve_github.return_value = SimpleNamespace(@@ -333,7 +320,6 @@ class TestExperimentCleanupPr(APIBaseTest):mock_create_task.assert_not_called()@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task",side_effect=Exception("sandbox unavailable"),@@ -343,7 +329,6 @@ class TestExperimentCleanupPr(APIBaseTest):self,mock_resolve_github,_mock_create_task,- _mock_feature_enabled,_mock_report,):mock_resolve_github.return_value = SimpleNamespace(diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.pyindex 91860a361397..c792090c261b 100644--- a/products/experiments/backend/test/test_presentation_api.py+++ b/products/experiments/backend/test/test_presentation_api.py@@ -5588,8 +5588,7 @@ class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):)self.assertEqual(end_response.status_code, status.HTTP_400_BAD_REQUEST)- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=False)- def test_end_endpoint_cleanup_pr_requires_task_write_scope(self, _mock_flag):+ def test_end_endpoint_cleanup_pr_requires_task_write_scope(self):exp_deny = self._create_running_experiment(name="Cleanup Deny", flag_key="cleanup-deny-flag")["id"]exp_no_opt = self._create_running_experiment(name="Cleanup No Opt", flag_key="cleanup-no-opt-flag")["id"]exp_allow = self._create_running_experiment(name="Cleanup Allow", flag_key="cleanup-allow-flag")["id"]@@ -5630,14 +5629,13 @@ class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):)self.assertEqual(resp.status_code, status.HTTP_200_OK, resp.content)- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=False)- def test_cleanup_pr_allowed_for_session_users(self, _mock_flag):+ def test_cleanup_pr_allowed_for_session_users(self):exp_ship = self._create_running_experiment(name="Cleanup Session Ship", flag_key="cleanup-session-ship-flag")["id"]- # Session auth carries no scopes, and opening a cleanup PR is no longer gated on the- # Desktop waitlist, so both actions succeed ("end first, ship later" flow).+ # Session auth carries no scopes, and opening a cleanup PR is not gated on the Desktop+ # waitlist, so both actions succeed ("end first, ship later" flow).resp = self.client.post(f"/api/projects/{self.team.id}/experiments/{exp_ship}/end/",{"conclusion": "won", "open_cleanup_pr": True},@@ -5828,14 +5826,13 @@ class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):[# (name, open_cleanup_pr, repository, expected_status)# Nothing persists in any of these: the value only sticks when a cleanup PR- # actually opens against it (team flag on + repo in the installation).+ # actually opens against it, which needs the repo in the GitHub installation.("not_persisted_when_cleanup_does_not_run", True, "acme/web", status.HTTP_200_OK),("ignored_without_opt_in", False, "acme/web", status.HTTP_200_OK),("invalid_format_rejected", True, "not-a-repo", status.HTTP_400_BAD_REQUEST),])- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=False)- def test_end_endpoint_repository(self, _name, open_cleanup_pr, repository, expected_status, _mock_flag):+ def test_end_endpoint_repository(self, _name, open_cleanup_pr, repository, expected_status):exp_id = self._create_running_experiment(name="End With Repo", flag_key="end-with-repo-flag")["id"]resp = self.client.post(@@ -5848,11 +5845,10 @@ class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):self.assertIsNone(Experiment.objects.get(id=exp_id).repository)@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")def test_end_endpoint_repository_persists_normalized_when_cleanup_opens(- self, mock_resolve_github, mock_create_task, _mock_flag, _mock_report+ self, mock_resolve_github, mock_create_task, _mock_report):mock_resolve_github.return_value = SimpleNamespace(list_all_cached_repositories=lambda max_repos: [{"full_name": "Acme/Web"}, {"full_name": "acme/api"}]@@ -5872,11 +5868,10 @@ class TestExperimentCRUD(_HoistFlagConfigClientMixin, APILicensedTest):self.assertEqual(Experiment.objects.get(id=exp_id).repository, "acme/web")@patch("products.experiments.backend.experiment_service.report_user_action")- @patch("products.experiments.backend.experiment_service.posthoganalytics.feature_enabled", return_value=True)@patch("products.experiments.backend.experiment_service.tasks_facade.create_and_run_task")@patch("products.tasks.backend.facade.repo_selection.resolve_team_github_integration")def test_set_repository_as_team_default_requires_project_admin(- self, mock_resolve_github, mock_create_task, _mock_flag, _mock_report+ self, mock_resolve_github, mock_create_task, _mock_report):mock_resolve_github.return_value = SimpleNamespace(list_all_cached_repositories=lambda max_repos: [{"full_name": "acme/web"}, {"full_name": "acme/api"}]diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.tsindex 10645f842474..815e492f8da8 100644--- a/products/experiments/frontend/generated/api.schemas.ts+++ b/products/experiments/frontend/generated/api.schemas.ts@@ -1976,7 +1976,7 @@ export interface EndExperimentApi {* @nullable*/conclusion_comment?: string | null- /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise. */+ /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved. */open_cleanup_pr?: boolean/*** GitHub repository to open the cleanup pull request in, in `organization/repository` format. Only used when open_cleanup_pr is true. It must be one of the team's connected repositories (see the flag_cleanup_target action); it is then saved as the experiment's repository. When omitted, the experiment's saved repository, the team's default cleanup repository, or the team's only connected repository is used.@@ -2557,7 +2557,7 @@ export interface ShipVariantApi {* @nullable*/conclusion_comment?: string | null- /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise. */+ /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved. */open_cleanup_pr?: boolean/*** GitHub repository to open the cleanup pull request in, in `organization/repository` format. Only used when open_cleanup_pr is true. It must be one of the team's connected repositories (see the flag_cleanup_target action); it is then saved as the experiment's repository. When omitted, the experiment's saved repository, the team's default cleanup repository, or the team's only connected repository is used.diff --git a/products/experiments/frontend/generated/api.zod.ts b/products/experiments/frontend/generated/api.zod.tsindex 6f3d9f02f22d..e2480b34382c 100644--- a/products/experiments/frontend/generated/api.zod.ts+++ b/products/experiments/frontend/generated/api.zod.ts@@ -1042,7 +1042,7 @@ export const ExperimentsEndCreateBody = /* @__PURE__ */ zod.object({.boolean().default(experimentsEndCreateBodyOpenCleanupPrDefault).describe(- "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise."+ "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved."),repository: zod.string()@@ -1207,7 +1207,7 @@ export const ExperimentsShipVariantCreateBody = /* @__PURE__ */ zod.object({.boolean().default(experimentsShipVariantCreateBodyOpenCleanupPrDefault).describe(- "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise."+ "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved."),repository: zod.string()diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yamlindex 498aabde83ed..48f5b8838a4c 100644--- a/products/experiments/mcp/tools.yaml+++ b/products/experiments/mcp/tools.yaml@@ -134,7 +134,6 @@ tools:aliases:- experimentId- experiment_id- feature_flag: experiment-flag-cleanup-prresponse:exclude:- can_view_taskdiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex cd2c8b3171e3..3a7eeb22cb2a 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -4341,8 +4341,7 @@"idempotentHint": true,"openWorldHint": true,"readOnlyHint": true- },- "feature_flag": "experiment-flag-cleanup-pr"+ }},"experiment-copy-to-project": {"description": "Requires an experiment ID. If you don't have the ID, load the finding-experiments skill to resolve the user's reference first. Load the managing-experiment-lifecycle skill for preconditions and side effects.\n\nREQUIRES EXPLICIT USER CONFIRMATION BEFORE CALLING. This writes a new experiment into a DIFFERENT project than the one the user is currently looking at. Resolve the target project from the user's wording to a concrete team id, then confirm the source experiment and the target project by name before invoking.\n\nCopies an experiment into another project in the SAME organization as a new draft. The target project must belong to the same organization — this CANNOT copy across organizations or regions. Use experiment-duplicate instead when the copy should land in the same project.\n\nWhat IS copied: name (defaults to \"Original Name (Copy)\", de-duplicated with a numeric suffix if that name already exists in the target), description, type, parameters (variant split, rollout), filters, primary and secondary metrics (each with freshly regenerated uuids and preserved ordering), stats config, scheduling config, exposure criteria, and the only_count_matured_users setting.\n\nWhat is NOT copied: saved-metric references (saved metrics are project-scoped, so they are dropped on a cross-project copy), holdout, exposure cohort, start/end dates, results, and conclusion. The copy always starts as a fresh draft.\n\nFeature flag: pass feature_flag_key to control the flag key created in the target project. If omitted, the source experiment's flag key is reused — and if a flag with that key already exists in the target project, the copy SHARES that existing flag (its variants are reused) rather than creating a new one. A shared flag means lifecycle operations on either experiment (shipping a variant, pausing) affect both. To avoid this, pass a feature_flag_key that does not already exist in the target project. If an existing target flag is reused, it must be multivariate with 2 to 20 variants, otherwise the call returns 400 (\"Feature flag must have at least 2 variants (a baseline and at least one test variant)\" or \"Feature flag must have at most 20 variants\"). No specific variant key is required — the analysis baseline defaults to the variant keyed \"control\" when present, else the first variant. Exception: copying a web experiment requires the reused target flag to have a variant keyed \"control\", otherwise the call returns 400 (\"Web experiments require a variant with key 'control'\").\n\nReturns 400 if the source experiment uses legacy metrics (\"Copying is not supported for experiments using legacy metrics.\"). Returns 404 if the target project is not found in the organization (\"Target team not found.\"). Returns 403 if you lack write access to the target project (\"You do not have write access to the target project.\").\n\nThe returned experiment (including its id) belongs to the TARGET project, not the source project.",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 0a65b3a47a40..58088a2a76b7 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -4412,8 +4412,7 @@"idempotentHint": true,"openWorldHint": true,"readOnlyHint": true- },- "feature_flag": "experiment-flag-cleanup-pr"+ }},"experiment-copy-to-project": {"description": "Requires an experiment ID. If you don't have the ID, load the finding-experiments skill to resolve the user's reference first. Load the managing-experiment-lifecycle skill for preconditions and side effects.\n\nREQUIRES EXPLICIT USER CONFIRMATION BEFORE CALLING. This writes a new experiment into a DIFFERENT project than the one the user is currently looking at. Resolve the target project from the user's wording to a concrete team id, then confirm the source experiment and the target project by name before invoking.\n\nCopies an experiment into another project in the SAME organization as a new draft. The target project must belong to the same organization — this CANNOT copy across organizations or regions. Use experiment-duplicate instead when the copy should land in the same project.\n\nWhat IS copied: name (defaults to \"Original Name (Copy)\", de-duplicated with a numeric suffix if that name already exists in the target), description, type, parameters (variant split, rollout), filters, primary and secondary metrics (each with freshly regenerated uuids and preserved ordering), stats config, scheduling config, exposure criteria, and the only_count_matured_users setting.\n\nWhat is NOT copied: saved-metric references (saved metrics are project-scoped, so they are dropped on a cross-project copy), holdout, exposure cohort, start/end dates, results, and conclusion. The copy always starts as a fresh draft.\n\nFeature flag: pass feature_flag_key to control the flag key created in the target project. If omitted, the source experiment's flag key is reused — and if a flag with that key already exists in the target project, the copy SHARES that existing flag (its variants are reused) rather than creating a new one. A shared flag means lifecycle operations on either experiment (shipping a variant, pausing) affect both. To avoid this, pass a feature_flag_key that does not already exist in the target project. If an existing target flag is reused, it must be multivariate with 2 to 20 variants, otherwise the call returns 400 (\"Feature flag must have at least 2 variants (a baseline and at least one test variant)\" or \"Feature flag must have at most 20 variants\"). No specific variant key is required — the analysis baseline defaults to the variant keyed \"control\" when present, else the first variant. Exception: copying a web experiment requires the reused target flag to have a variant keyed \"control\", otherwise the call returns 400 (\"Web experiments require a variant with key 'control'\").\n\nReturns 400 if the source experiment uses legacy metrics (\"Copying is not supported for experiments using legacy metrics.\"). Returns 404 if the target project is not found in the organization (\"Target team not found.\"). Returns 403 if you lack write access to the target project (\"You do not have write access to the target project.\").\n\nThe returned experiment (including its id) belongs to the TARGET project, not the source project.",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 8c16f9dabaf6..ef26f0f81059 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -32362,7 +32362,7 @@ export namespace Schemas {* @nullable*/conclusion_comment?: string | null;- /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise. */+ /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved. */open_cleanup_pr?: boolean;/*** GitHub repository to open the cleanup pull request in, in `organization/repository` format. Only used when open_cleanup_pr is true. It must be one of the team's connected repositories (see the flag_cleanup_target action); it is then saved as the experiment's repository. When omitted, the experiment's saved repository, the team's default cleanup repository, or the team's only connected repository is used.@@ -82318,7 +82318,7 @@ export namespace Schemas {* @nullable*/conclusion_comment?: string | null;- /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise. */+ /** When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved. */open_cleanup_pr?: boolean;/*** GitHub repository to open the cleanup pull request in, in `organization/repository` format. Only used when open_cleanup_pr is true. It must be one of the team's connected repositories (see the flag_cleanup_target action); it is then saved as the experiment's repository. When omitted, the experiment's saved repository, the team's default cleanup repository, or the team's only connected repository is used.diff --git a/services/mcp/src/generated/experiments/api.ts b/services/mcp/src/generated/experiments/api.tsindex 5bdec482b9c6..f2418e9542dd 100644--- a/services/mcp/src/generated/experiments/api.ts+++ b/services/mcp/src/generated/experiments/api.ts@@ -18584,7 +18584,7 @@ export const ExperimentsEndCreateBody = () => zod.object({.boolean().default(experimentsEndCreateBodyOpenCleanupPrDefault).describe(- "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise."+ "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved."),repository: zod.string()@@ -18856,7 +18856,7 @@ export const ExperimentsShipVariantCreateBody = () => zod.object({.boolean().default(experimentsShipVariantCreateBodyOpenCleanupPrDefault).describe(- "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. Requires the requesting user to have access to PostHog Desktop (403 otherwise). Only acts for allowlisted teams; ignored otherwise."+ "When true, open a draft pull request that removes the experiment's feature-flag code from the linked repository. A personal API key needs the task:write scope (403 otherwise). Skipped when the conclusion is empty, or when no connected repository can be resolved."),repository: zod.string()diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-cleanup-task.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-cleanup-task.jsonnew file mode 100644index 000000000000..1f1461179dd3--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-cleanup-task.json@@ -0,0 +1,11 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "id": {+ "description": "A unique integer value identifying this experiment.",+ "type": "number"+ }+ },+ "required": ["id"],+ "type": "object"+}diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.tsindex d6e7f8260cc2..06001b4ac1bb 100644--- a/services/mcp/tests/unit/tool-filtering.test.ts+++ b/services/mcp/tests/unit/tool-filtering.test.ts@@ -1007,14 +1007,13 @@ describe('Tool Filtering - Feature Flags', () => {'streamlit-apps','posthog-connect','experiment-behavior-comparison',- 'experiment-flag-cleanup-pr','data-warehouse-scene','data-quality-checks','context-layer','warehouse-multi-destination',]))- expect(flags).toHaveLength(36)+ expect(flags).toHaveLength(35)})it('every loops tool is gated on the loops flag', () => {