: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
fix(experiments/posthog-ai): Fix stale tool names and columns in 3 agent skills (#62781)
Marcel Poelker8adfb14306c2
diff --git a/products/experiments/skills/analyzing-experiment-session-replays/SKILL.md b/products/experiments/skills/analyzing-experiment-session-replays/SKILL.mdindex 08f5b6f9b36c..cecca7c74070 100644--- a/products/experiments/skills/analyzing-experiment-session-replays/SKILL.md+++ b/products/experiments/skills/analyzing-experiment-session-replays/SKILL.md@@ -36,19 +36,19 @@ First, retrieve the experiment information and the feature flag variants (sourceYou can either:-- **Option A**: Use the `experiment_results_summary` tool if you already have the experiment ID from context+- **Option A**: Use the `experiment-get` tool if you already have the experiment ID from context- **Option B**: Query the experiments table via HogQL:```sqlSELECT- id,- name,- feature_flag_key,- start_date,- end_date-FROM system.experiments-WHERE id = <experiment_id>- AND team_id = <team_id>+ e.id,+ e.name,+ f.key AS feature_flag_key,+ e.start_date,+ e.end_date+FROM system.experiments e+JOIN system.feature_flags f ON f.id = e.feature_flag_id+WHERE e.id = <experiment_id>```From the experiment data, extract:@@ -64,15 +64,12 @@ The parameters can be out of sync or deprecated. The feature flag is the sourceQuery the feature flag to get the current variants:```sql-SELECT- key,- filters+SELECT filters.multivariate.variants AS variantsFROM system.feature_flagsWHERE key = '<feature_flag_key>'- AND team_id = <team_id>```-Extract the variant keys from `filters.multivariate.variants` array.+Select the variants path directly — selecting the whole `filters` object gets truncated in results for flags with large targeting configs.Example structure: `[{"key": "control", "name": "Control", "rollout_percentage": 50}, {"key": "test", ...}]`The variant `key` values (e.g., "control", "test", "variant_a") are what you'll use to filter session recordings.@@ -81,31 +78,19 @@ The variant `key` values (e.g., "control", "test", "variant_a") are what you'llFor each variant in the experiment, construct recording filters that match users exposed to that variant.-**Filter structure for a variant:**+**Filter structure for a variant** (input to `query-session-recordings-list`):```json{"date_from": "<experiment.start_date>","date_to": "<experiment.end_date or current time>","filter_test_accounts": true,- "events": [+ "properties": [{- "id": "$feature_flag_called",- "type": "events",- "properties": [- {- "key": "$feature_flag",- "value": ["<feature_flag_key>"],- "operator": "exact",- "type": "event"- },- {- "key": "$feature/<feature_flag_key>",- "value": ["<variant_key>"],- "operator": "exact",- "type": "event"- }- ]+ "type": "event",+ "key": "$feature/<feature_flag_key>",+ "operator": "exact",+ "value": ["<variant_key>"]}]}@@ -113,14 +98,15 @@ For each variant in the experiment, construct recording filters that match users**Key points:**-- Filter by `$feature_flag_called` events where the flag matches the experiment's feature flag-- Use `$feature/<flag_key>` property to filter for the specific variant value+- The `$feature/<flag_key>` event property records which variant the user saw — filtering on it matches recordings containing at least one event from that variant+- `value` is an array of variant key strings (e.g. `["control"]`); for boolean flags use `["true"]` or `["false"]`+- Avoid the `type: "flag"` / `flag_evaluates_to` property filter for variant scoping — the recordings query accepts it but silently ignores it, returning unfiltered results (last verified 2026-06-10). If you want to try it anyway, verify it actually filters first: a query with a nonexistent flag key should return zero recordings- Set the date range to the experiment's start and end dates- Enable `filter_test_accounts: true` to exclude test users### 3. Retrieve recordings for each variant-Use the `filter_session_recordings` tool with the filters constructed in step 2.+Use the `query-session-recordings-list` tool with the filters constructed in step 2.Call the tool once per variant to get recordings for each group:@@ -130,12 +116,12 @@ Call the tool once per variant to get recordings for each group:The tool returns a list of recordings with metadata including:-- User/distinct_id-- Session duration-- Activity metrics (clicks, keypresses)-- Console errors-- First URL visited-- Start time+- `distinct_id` — the person's distinct ID+- `recording_duration`, `active_seconds`, `inactive_seconds`+- `click_count`, `keypress_count`, `mouse_activity_count`+- `console_log_count`, `console_warn_count`, `console_error_count`+- `start_url` — first page URL visited+- `start_time` / `end_time`, `activity_score`### 4. Compare and analyze@@ -173,10 +159,10 @@ Agent steps:2. Query feature flag "checkout-flow-test" to get variants from filters.multivariate.variants3. Extract variant keys: "control" and "new-checkout"4. Build filters for control variant:- - Events: $feature_flag_called with $feature_flag="checkout-flow-test" and $feature/checkout-flow-test="control"+ - Property filter: { type: "event", key: "$feature/checkout-flow-test", operator: "exact", value: ["control"] }- Date range: 2025-01-01 to 2025-01-31-5. Call filter_session_recordings with control filters → 147 recordings found-6. Build filters for new-checkout variant and call filter_session_recordings → 152 recordings found+5. Call query-session-recordings-list with control filters → 147 recordings found+6. Build filters for new-checkout variant and call query-session-recordings-list → 152 recordings found7. Compare patterns:- Control: Average 3m 45s session duration, 12% console errors- New-checkout: Average 2m 30s session duration, 5% console errors@@ -198,9 +184,9 @@ Agent steps:**Filter construction:**-- The `$feature/<flag_key>` property is how PostHog tracks which variant a user saw-- Always use `$feature_flag_called` as the event type-- Both `$feature_flag` and `$feature/<flag_key>` properties are required+- The `$feature/<flag_key>` event property is how you scope recordings to a variant+- One filter per variant — call the tool once per variant with its own filter+- For boolean flags, use `["true"]`/`["false"]` as the value instead of a variant key**Error handling:**@@ -210,6 +196,6 @@ Agent steps:## Related tools-- `filter_session_recordings`: Core tool for retrieving session recordings with filters-- `experiment_results_summary`: Get experiment metadata and statistical results-- `execute_sql`: Query experiments table for details via HogQL+- `query-session-recordings-list`: Core tool for retrieving session recordings with filters+- `experiment-get`: Get experiment metadata; `experiment-results-get` for statistical results+- `execute-sql`: Query experiments table for details via HogQLdiff --git a/products/posthog_ai/skills/auditing-experiments-flags/SKILL.md b/products/posthog_ai/skills/auditing-experiments-flags/SKILL.mdindex 8e94d127bc9c..61e41b5066d0 100644--- a/products/posthog_ai/skills/auditing-experiments-flags/SKILL.md+++ b/products/posthog_ai/skills/auditing-experiments-flags/SKILL.md@@ -6,7 +6,7 @@ description: 'Audit PostHog experiments and feature flags for configuration issu# Auditing experiments and feature flagsThis skill teaches you how to run configuration audits on experiments and feature flags.-All checks use `read_data` and `list_data` — no SQL queries are needed for Phase 1 checks.+All checks use the experiment and feature flag read tools (`experiment-get`, `experiment-list`, `feature-flag-get-definition`, `feature-flag-get-all`) — no SQL queries are needed for Phase 1 checks.## Usage modes@@ -14,7 +14,7 @@ All checks use `read_data` and `list_data` — no SQL queries are needed for PhaWhen the user asks about a specific experiment or flag:-1. Fetch the entity via `read_data` (e.g., `read_data("experiments", id)` or `read_data("feature_flags", id)`).+1. Fetch the entity via `experiment-get` (experiment ID) or `feature-flag-get-definition` (numeric flag ID).2. Apply the relevant checks from [experiment checks](./references/experiment-checks.md) or [flag checks](./references/flag-checks.md).3. Report findings inline as markdown, grouped by severity (CRITICAL first, then WARNING, then INFO).4. Include entity links as `[Experiment: name](/experiments/id)` or `[Flag: key](/feature_flags/id)`.@@ -23,7 +23,7 @@ When the user asks about a specific experiment or flag:When the user asks to audit all experiments or all flags:-1. Bulk-fetch via `list_data` (e.g., `list_data("experiments")` or `list_data("feature_flags")`).+1. Bulk-fetch via `experiment-list` or `feature-flag-get-all`.2. Run all checks for that domain against each entity.3. Group findings by severity, then by entity.4. Report as inline markdown.@@ -32,10 +32,10 @@ When the user asks to audit all experiments or all flags:When the user asks for a comprehensive audit of both experiments and flags:-1. Fetch all experiments via `list_data("experiments")` and all flags via `list_data("feature_flags")`.+1. Fetch all experiments via `experiment-list` and all flags via `feature-flag-get-all`.2. Run all experiment checks and all flag checks.3. Apply [recurring patterns](./references/synthesis-patterns.md) to identify patterns across multiple findings.-4. If there are more than 5 entities with findings, output as a notebook artifact via `create_notebook` for easier navigation. Otherwise report inline.+4. If there are more than 5 entities with findings, output as a notebook artifact via `notebooks-create` for easier navigation. Otherwise report inline.## Output format@@ -55,7 +55,7 @@ Example:## Handling unavailable data-Some checks require activity logs, which may not be available via `read_data`.+Some checks require activity logs (`feature-flags-activity-retrieve` for flags), which may not be available in every session.If activity log data is unavailable:- Skip `checkActivityHistory` (experiment check) entirely.@@ -65,7 +65,7 @@ If activity log data is unavailable:## Partial failures-If a `read_data` or `list_data` call fails for some entities:+If a fetch call fails for some entities:- Continue with the entities you could fetch.- Report which entities could not be assessed and why.diff --git a/products/posthog_ai/skills/auditing-experiments-flags/references/experiment-checks.md b/products/posthog_ai/skills/auditing-experiments-flags/references/experiment-checks.mdindex 1ba732052f97..3831bcec8cab 100644--- a/products/posthog_ai/skills/auditing-experiments-flags/references/experiment-checks.md+++ b/products/posthog_ai/skills/auditing-experiments-flags/references/experiment-checks.md@@ -1,6 +1,6 @@# Experiment checks-Run these checks against each experiment fetched via `read_data("experiments", id)` or `list_data("experiments")`.+Run these checks against each experiment fetched via `experiment-get` or `experiment-list`.For each check, the "Look at" section tells you which fields to inspect on the experiment object.The "Findings" section lists what to report and at what severity.@@ -31,7 +31,7 @@ Verifies the experiment has a valid primary metric configuration.Verifies the experiment's linked feature flag is valid and correctly configured.-**Look at**: `feature_flag` (the linked flag object or ID), and fetch the flag via `read_data("feature_flags", feature_flag_id)` if only an ID is available.+**Look at**: `feature_flag` (the linked flag object or ID), and fetch the flag via `feature-flag-get-definition` if only an ID is available.**Findings**:diff --git a/products/posthog_ai/skills/auditing-experiments-flags/references/flag-checks.md.j2 b/products/posthog_ai/skills/auditing-experiments-flags/references/flag-checks.md.j2index 4519693ed22d..703a6e056b6a 100644--- a/products/posthog_ai/skills/auditing-experiments-flags/references/flag-checks.md.j2+++ b/products/posthog_ai/skills/auditing-experiments-flags/references/flag-checks.md.j2@@ -1,7 +1,7 @@{%- set c = audit_constants() -%}# Feature flag checks-Run these checks against each flag fetched via `read_data("feature_flags", id)` or `list_data("feature_flags")`.+Run these checks against each flag fetched via `feature-flag-get-definition` or `feature-flag-get-all`.---@@ -47,7 +47,7 @@ Detects flags that were created but never activated.Detects flags whose linked experiments are all done.-**Look at**: `experiment_set` (list of linked experiment IDs), and for each experiment, check its `end_date` and `archived` status via `read_data("experiments", id)`.+**Look at**: `experiment_set` (list of linked experiment IDs), and for each experiment, check its `end_date` and `archived` status via `experiment-get`.**Findings**:diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-cohorts.md b/products/posthog_ai/skills/querying-posthog-data/references/models-cohorts.mdindex 07c6ed9bab40..9fbe4002cb3c 100644--- a/products/posthog_ai/skills/querying-posthog-data/references/models-cohorts.md+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-cohorts.md@@ -98,7 +98,6 @@ Type | Description- **Persons**: Many-to-many via `raw_cohort_people` table- **Calculation History**: One-to-many via `system.cohort_calculation_history`-- **Experiments**: Referenced by `system.experiments.exposure_cohort_id`### Important Notes@@ -160,9 +159,6 @@ Code | Descriptionsystem.cohorts (main cohort definition)├── <- system.cohort_calculation_history.cohort_id└── persons through `IN COHORT`--system.experiments-└── exposure_cohort_id -> system.cohorts.id```---diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-flags-experiments.md b/products/posthog_ai/skills/querying-posthog-data/references/models-flags-experiments.mdindex ef4a94706c5b..4f637cae65b4 100644--- a/products/posthog_ai/skills/querying-posthog-data/references/models-flags-experiments.md+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-flags-experiments.md@@ -6,29 +6,17 @@ Feature flags control rollouts of new features and are used for A/B testing.### Columns+These are the only columns exposed via HogQL — the full flag model (e.g. `active`, `ensure_experience_continuity`, `last_called_at`, rollback settings) is not queryable here; fetch the flag via the feature flag API tools instead.+Column | Type | Nullable | Description`id` | integer | NOT NULL | Primary key (auto-generated)+`team_id` | integer | NOT NULL | Project scope`key` | varchar(400) | NOT NULL | Unique flag key per team`name` | text | NOT NULL | Flag description (not the display name)`filters` | jsonb | NOT NULL | Targeting conditions and variants`rollout_percentage` | integer | NULL | Overall rollout percentage`created_at` | timestamp with tz | NOT NULL | Creation timestamp-`deleted` | boolean | NOT NULL | Soft delete flag-`active` | boolean | NOT NULL | Whether flag is enabled-`rollback_conditions` | jsonb | NULL | Automatic rollback configuration-`performed_rollback` | boolean | NULL | Whether rollback was triggered-`ensure_experience_continuity` | boolean | NULL | Sticky bucketing for users-`created_by_id` | integer | NULL | Creator user ID-`usage_dashboard_id` | integer | NULL | FK to `system.dashboards.id`-`has_enriched_analytics` | boolean | NULL | Whether rich analytics enabled-`is_remote_configuration` | boolean | NULL | Whether used as remote config-`has_encrypted_payloads` | boolean | NULL | Whether payloads are encrypted-`last_modified_by_id` | integer | NULL | Last modifier user ID-`version` | integer | NULL | Version number for tracking changes-`evaluation_runtime` | varchar(10) | NULL | `server`, `client`, or `all`-`updated_at` | timestamp with tz | NULL | Last update timestamp-`last_called_at` | timestamp with tz | NULL | Last evaluation timestamp-`bucketing_identifier` | varchar(50) | NULL | `distinct_id` or `device_id`+`deleted` | integer (0/1) | NOT NULL | Soft delete flag### Filters Structure@@ -74,34 +62,21 @@ Experiments are A/B tests that compare variants against a control group.### Columns+These are the only columns exposed via HogQL — the full experiment model (e.g. `deleted`, `conclusion`, `metrics`, `metrics_secondary`, `stats_config`, `exposure_criteria`, `holdout_id`, `type`) is not queryable here; fetch the experiment via the experiment API tools instead.+Column | Type | Nullable | Description`id` | integer | NOT NULL | Primary key (auto-generated)+`team_id` | integer | NOT NULL | Project scope`name` | varchar(400) | NOT NULL | Experiment name`description` | varchar(400) | NULL | Experiment description-`filters` | jsonb | NOT NULL | Target metric definition-`parameters` | jsonb | NULL | Experiment configuration-`secondary_metrics` | jsonb | NULL | Additional metrics to track+`filters` | jsonb | NOT NULL | Legacy target metric definition+`parameters` | jsonb | NULL | Experiment configuration (variants, MDE, sample size)`start_date` | timestamp with tz | NULL | When experiment started (NULL = draft)`end_date` | timestamp with tz | NULL | When experiment ended`created_at` | timestamp with tz | NOT NULL | Creation timestamp`updated_at` | timestamp with tz | NOT NULL | Last update timestamp-`archived` | boolean | NOT NULL | Whether experiment is archived-`deleted` | boolean | NULL | Soft delete flag-`created_by_id` | integer | NULL | Creator user ID+`archived` | integer (0/1) | NOT NULL | Whether experiment is archived`feature_flag_id` | integer | NOT NULL | FK to `system.feature_flags.id`-`exposure_cohort_id` | integer | NULL | FK to `system.cohorts.id`-`holdout_id` | integer | NULL | Holdout ID-`type` | varchar(40) | NULL | `web` or `product`-`variants` | jsonb | NULL | Variant configuration-`metrics` | jsonb | NULL | Primary metrics (new format)-`metrics_secondary` | jsonb | NULL | Secondary metrics (new format)-`stats_config` | jsonb | NULL | Statistical analysis configuration-`exposure_criteria` | jsonb | NULL | Exposure event criteria-`conclusion` | varchar(30) | NULL | `won`, `lost`, `inconclusive`, `stopped_early`, `invalid`-`conclusion_comment` | text | NULL | Notes about conclusion-`scheduling_config` | jsonb | NULL | Scheduled actions configuration-`primary_metrics_ordered_uuids` | jsonb | NULL | Ordered primary metric UUIDs-`secondary_metrics_ordered_uuids` | jsonb | NULL | Ordered secondary metric UUIDs### Parameters Structure@@ -121,10 +96,10 @@ Column | Type | Nullable | Description### Key Relationships- **Feature Flag**: `feature_flag_id` -> `system.feature_flags.id` (required)-- **Exposure Cohort**: `exposure_cohort_id` -> `system.cohorts.id`### Important Notes- An experiment is a "draft" if `start_date` is NULL+- Soft-deleted experiments still appear in this table — there is no `deleted` column to filter them out; confirm via the experiment API tools when deletion status matters- Each experiment requires an associated feature flag- The feature flag controls variant assignment