: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): search experiments by feature flag key (#113739)
Marcel Poelker84a365a8cb8b
diff --git a/products/experiments/backend/experiment_service.py b/products/experiments/backend/experiment_service.pyindex 77b32b1544d3..8869ab5a2b20 100644--- a/products/experiments/backend/experiment_service.py+++ b/products/experiments/backend/experiment_service.py@@ -4360,7 +4360,7 @@ class ExperimentService:search = query_params.get("search")if search:- queryset = queryset.filter(Q(name__icontains=search))+ queryset = queryset.filter(Q(name__icontains=search) | Q(feature_flag__key__icontains=search))order = query_params.get("order")if order:diff --git a/products/experiments/backend/presentation/views.py b/products/experiments/backend/presentation/views.pyindex d150867ce4fb..a6cad8b695b6 100644--- a/products/experiments/backend/presentation/views.py+++ b/products/experiments/backend/presentation/views.py@@ -322,7 +322,7 @@ EXPERIMENT_LIST_FILTER_PARAMETERS = [name="search",location=OpenApiParameter.QUERY,type=str,- description="Free-text search applied to the experiment name (case-insensitive).",+ description="Free-text search applied to the experiment name and its feature flag key (case-insensitive).",required=False,),OpenApiParameter(diff --git a/products/experiments/backend/test/test_experiment_service.py b/products/experiments/backend/test/test_experiment_service.pyindex 2cbdf498948a..08b65f87f220 100644--- a/products/experiments/backend/test/test_experiment_service.py+++ b/products/experiments/backend/test/test_experiment_service.py@@ -5446,6 +5446,7 @@ class TestExperimentService(APIBaseTest):("archived_true", {"archived": "true"}, {"Archived search"}),("archived_false", {"archived": "false"}, {"Creator self", "Creator other", "Search match"}),("search", {"search": "Search"}, {"Search match"}),+ ("search_flag_key", {"search": "CREATED-BY"}, {"Creator self", "Creator other"}),])def test_filter_experiments_queryset_filters_by_common_query_params(diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.tsindex 9ead74ba521f..eee4ebe1fe6a 100644--- a/products/experiments/frontend/generated/api.schemas.ts+++ b/products/experiments/frontend/generated/api.schemas.ts@@ -4611,7 +4611,7 @@ export type ExperimentsListParams = {*/prompt_name?: string/**- * Free-text search applied to the experiment name (case-insensitive).+ * Free-text search applied to the experiment name and its feature flag key (case-insensitive).*/search?: string/**@@ -4690,7 +4690,7 @@ export type ExperimentsMatchingIdsRetrieveParams = {*/prompt_name?: string/**- * Free-text search applied to the experiment name (case-insensitive).+ * Free-text search applied to the experiment name and its feature flag key (case-insensitive).*/search?: string/**diff --git a/products/experiments/frontend/scenes/ExperimentsScene.tsx b/products/experiments/frontend/scenes/ExperimentsScene.tsxindex f1e600a7bf37..8c014dd42ee9 100644--- a/products/experiments/frontend/scenes/ExperimentsScene.tsx+++ b/products/experiments/frontend/scenes/ExperimentsScene.tsx@@ -138,7 +138,7 @@ const ExperimentsTableFilters = ({><LemonInputtype="search"- placeholder="Search experiments"+ placeholder="Search by name or flag"onChange={(search) => onFiltersChange({ search, page: 1 })}value={filters.search || ''}/>diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yamlindex 4b9651333135..aafe175c0036 100644--- a/products/experiments/mcp/tools.yaml+++ b/products/experiments/mcp/tools.yaml@@ -760,10 +760,10 @@ tools:Supports filtering by status ("draft", "running", "paused", "exposure_frozen", "stopped", "complete" whichmaps to stopped, or "all"), archived state (defaults to non-archived), feature_flag_id, created_by_id, tags- / excluded_tags (JSON-encoded lists of tag names), and free-text search on name. Supports ordering by an- allowlisted set of fields (model fields plus computed "duration" and "status"). Returns paginated results- with each experiment's status, dates, feature flag key, and metrics summary. Use the returned ID for- get/update/lifecycle tools.+ / excluded_tags (JSON-encoded lists of tag names), and free-text search on name and feature flag key.+ Supports ordering by an allowlisted set of fields (model fields plus computed "duration" and "status").+ Returns paginated results with each experiment's status, dates, feature flag key, and metrics summary. Use+ the returned ID for get/update/lifecycle tools.param_overrides:status:description: >diff --git a/products/experiments/skills/finding-experiments/SKILL.md b/products/experiments/skills/finding-experiments/SKILL.mdindex 965732290cf9..9fcf92832732 100644--- a/products/experiments/skills/finding-experiments/SKILL.md+++ b/products/experiments/skills/finding-experiments/SKILL.md@@ -27,6 +27,8 @@ experiment matching the user's reference:free, so this is also the existence check to run before `experiment-create`. `ambiguous` meansseveral experiments share the flag and none is the single live one: show the `candidates` andpick one with `experiment-get` rather than creating another.+- **By partial flag key**: call `experiment-list` with `search` set to the fragment. `search` matches+ substrings of the experiment name and the flag key, ignoring case.## After finding matchesdiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex a77387f0c122..620907e5c9a8 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -5241,7 +5241,7 @@}},"experiment-list": {- "description": "List experiments in the current project. This is the primary tool for resolving experiment references — load the finding-experiments skill for guidance on searching by name, status, recency, or description. When the reference is a feature flag key, call experiment-get-by-flag-key instead of listing.\n\nSupports filtering by status (\"draft\", \"running\", \"paused\", \"exposure_frozen\", \"stopped\", \"complete\" which maps to stopped, or \"all\"), archived state (defaults to non-archived), feature_flag_id, created_by_id, tags / excluded_tags (JSON-encoded lists of tag names), and free-text search on name. Supports ordering by an allowlisted set of fields (model fields plus computed \"duration\" and \"status\"). Returns paginated results with each experiment's status, dates, feature flag key, and metrics summary. Use the returned ID for get/update/lifecycle tools.",+ "description": "List experiments in the current project. This is the primary tool for resolving experiment references — load the finding-experiments skill for guidance on searching by name, status, recency, or description. When the reference is a feature flag key, call experiment-get-by-flag-key instead of listing.\n\nSupports filtering by status (\"draft\", \"running\", \"paused\", \"exposure_frozen\", \"stopped\", \"complete\" which maps to stopped, or \"all\"), archived state (defaults to non-archived), feature_flag_id, created_by_id, tags / excluded_tags (JSON-encoded lists of tag names), and free-text search on name and feature flag key. Supports ordering by an allowlisted set of fields (model fields plus computed \"duration\" and \"status\"). Returns paginated results with each experiment's status, dates, feature flag key, and metrics summary. Use the returned ID for get/update/lifecycle tools.","category": "Experiments","feature": "experiments","summary": "Get all experiments",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex c4b5b039c8d9..aae262b99961 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -5326,7 +5326,7 @@}},"experiment-list": {- "description": "List experiments in the current project. This is the primary tool for resolving experiment references — load the finding-experiments skill for guidance on searching by name, status, recency, or description. When the reference is a feature flag key, call experiment-get-by-flag-key instead of listing.\n\nSupports filtering by status (\"draft\", \"running\", \"paused\", \"exposure_frozen\", \"stopped\", \"complete\" which maps to stopped, or \"all\"), archived state (defaults to non-archived), feature_flag_id, created_by_id, tags / excluded_tags (JSON-encoded lists of tag names), and free-text search on name. Supports ordering by an allowlisted set of fields (model fields plus computed \"duration\" and \"status\"). Returns paginated results with each experiment's status, dates, feature flag key, and metrics summary. Use the returned ID for get/update/lifecycle tools.",+ "description": "List experiments in the current project. This is the primary tool for resolving experiment references — load the finding-experiments skill for guidance on searching by name, status, recency, or description. When the reference is a feature flag key, call experiment-get-by-flag-key instead of listing.\n\nSupports filtering by status (\"draft\", \"running\", \"paused\", \"exposure_frozen\", \"stopped\", \"complete\" which maps to stopped, or \"all\"), archived state (defaults to non-archived), feature_flag_id, created_by_id, tags / excluded_tags (JSON-encoded lists of tag names), and free-text search on name and feature flag key. Supports ordering by an allowlisted set of fields (model fields plus computed \"duration\" and \"status\"). Returns paginated results with each experiment's status, dates, feature flag key, and metrics summary. Use the returned ID for get/update/lifecycle tools.","category": "Experiments","feature": "experiments","summary": "Get all experiments",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex cd9440ecf692..1898068efe32 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -119717,7 +119717,7 @@ export namespace Schemas {*/prompt_name?: string;/**- * Free-text search applied to the experiment name (case-insensitive).+ * Free-text search applied to the experiment name and its feature flag key (case-insensitive).*/search?: string;/**@@ -119797,7 +119797,7 @@ export namespace Schemas {*/prompt_name?: string;/**- * Free-text search applied to the experiment name (case-insensitive).+ * Free-text search applied to the experiment name and its feature flag key (case-insensitive).*/search?: string;/**diff --git a/services/mcp/src/generated/experiments/api.ts b/services/mcp/src/generated/experiments/api.tsindex 1c5c50cbcb60..02fe3ac58fe1 100644--- a/services/mcp/src/generated/experiments/api.ts+++ b/services/mcp/src/generated/experiments/api.ts@@ -775,7 +775,10 @@ export const ExperimentsListQueryParams = () => zod.object({.describe('Filter to experiments created from an LLM prompt with this name. Matches experiments whose parameters.prompt_metadata.name equals the given value.'),- search: zod.string().optional().describe('Free-text search applied to the experiment name (case-insensitive).'),+ search: zod+ .string()+ .optional()+ .describe('Free-text search applied to the experiment name and its feature flag key (case-insensitive).'),status: zod.enum(['all', 'complete', 'draft', 'exposure_frozen', 'paused', 'running', 'stopped']).optional()diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-list.jsonindex 6c69fd7b5688..0e479bffcfa9 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-list.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-list.json@@ -38,7 +38,7 @@"type": "string"},"search": {- "description": "Free-text search applied to the experiment name (case-insensitive).",+ "description": "Free-text search applied to the experiment name and its feature flag key (case-insensitive).","type": "string"},"status": {