: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(mcp): page through actors in insight drill-downs (#83837)
posthog[bot]88adebadc313
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 4573a9ebf962..f0ae1fc065c2 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -2807,6 +2807,16 @@"const": "FunnelsActorsQuery","type": "string"},+ "limit": {+ "$ref": "#/definitions/integer",+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."+ },+ "offset": {+ "$ref": "#/definitions/integer",+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`."+ },"source": {"$ref": "#/definitions/AssistantFunnelsQuery","description": "The source funnel insight query whose step (or trends point) we are drilling into."@@ -3511,6 +3521,16 @@"const": "InsightActorsQuery","type": "string"},+ "limit": {+ "$ref": "#/definitions/integer",+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."+ },+ "offset": {+ "$ref": "#/definitions/integer",+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`."+ },"source": {"$ref": "#/definitions/AssistantLifecycleQuery","description": "The source lifecycle insight query whose bucket we are drilling into."@@ -3818,6 +3838,16 @@"const": "InsightActorsQuery","type": "string"},+ "limit": {+ "$ref": "#/definitions/integer",+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."+ },+ "offset": {+ "$ref": "#/definitions/integer",+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`."+ },"source": {"$ref": "#/definitions/AssistantPathsQuery","description": "The source paths insight query whose actors we are listing."@@ -4264,6 +4294,16 @@"const": "InsightActorsQuery","type": "string"},+ "limit": {+ "$ref": "#/definitions/integer",+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."+ },+ "offset": {+ "$ref": "#/definitions/integer",+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole cohort: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`."+ },"source": {"$ref": "#/definitions/AssistantRetentionQuery","description": "The source retention insight query whose cohort we are drilling into."@@ -4515,6 +4555,16 @@"const": "InsightActorsQuery","type": "string"},+ "limit": {+ "$ref": "#/definitions/integer",+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."+ },+ "offset": {+ "$ref": "#/definitions/integer",+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`."+ },"series": {"$ref": "#/definitions/integer","description": "0-based index of the series to drill into when the source has multiple series. Defaults to 0."@@ -5042,6 +5092,16 @@"const": "InsightActorsQuery","type": "string"},+ "limit": {+ "$ref": "#/definitions/integer",+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."+ },+ "offset": {+ "$ref": "#/definitions/integer",+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`."+ },"series": {"$ref": "#/definitions/integer","description": "Series index (0-based) when the source has multiple series."diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex 42461b837f0d..8681063038b2 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -1342,6 +1342,20 @@ export interface AssistantTrendsActorsQuery {* @default true*/includeRecordings?: boolean++ /**+ * Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.+ * @default 100+ */+ limit?: integer++ /**+ * Number of persons to skip before the returned page. Use it with `limit` to walk the whole+ * result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true,+ * call again with `offset` raised by `limit`.+ * @default 0+ */+ offset?: integer}/** A single lifecycle bucket — see `AssistantLifecycleActorsQuery.status`. */@@ -1373,6 +1387,20 @@ export interface AssistantLifecycleActorsQuery {* in the source's `lifecycleFilter.toggledLifecycles` (defaults to all four when omitted).*/status: AssistantLifecycleStatus++ /**+ * Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.+ * @default 100+ */+ limit?: integer++ /**+ * Number of persons to skip before the returned page. Use it with `limit` to walk the whole+ * result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true,+ * call again with `offset` raised by `limit`.+ * @default 0+ */+ offset?: integer}/**@@ -1399,6 +1427,20 @@ export interface AssistantPathsActorsQuery {* @default true*/includeRecordings?: boolean++ /**+ * Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.+ * @default 100+ */+ limit?: integer++ /**+ * Number of persons to skip before the returned page. Use it with `limit` to walk the whole+ * result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true,+ * call again with `offset` raised by `limit`.+ * @default 0+ */+ offset?: integer}/**@@ -1428,6 +1470,20 @@ export interface AssistantRetentionActorsQuery {* Defaults to `0` when omitted.*/interval?: integer++ /**+ * Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.+ * @default 100+ */+ limit?: integer++ /**+ * Number of persons to skip before the returned page. Use it with `limit` to walk the whole+ * cohort: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call+ * again with `offset` raised by `limit`.+ * @default 0+ */+ offset?: integer}/**@@ -1460,6 +1516,20 @@ export interface AssistantStickinessActorsQuery {/** Whether to pull from the previous period when `compareFilter` is enabled in the source. */compare?: 'current' | 'previous'++ /**+ * Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.+ * @default 100+ */+ limit?: integer++ /**+ * Number of persons to skip before the returned page. Use it with `limit` to walk the whole+ * result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true,+ * call again with `offset` raised by `limit`.+ * @default 0+ */+ offset?: integer}/**@@ -1523,6 +1593,20 @@ export interface AssistantFunnelsActorsQuery {* @default true*/includeRecordings?: boolean++ /**+ * Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.+ * @default 100+ */+ limit?: integer++ /**+ * Number of persons to skip before the returned page. Use it with `limit` to walk the whole+ * result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true,+ * call again with `offset` raised by `limit`.+ * @default 0+ */+ offset?: integer}/**diff --git a/posthog/schema.py b/posthog/schema.pyindex cc7dde0481e3..997f4844a0f1 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -24989,6 +24989,19 @@ class AssistantFunnelsActorsQuery(BaseModel):description="Whether to include matched session recordings for each actor.",)kind: Literal["FunnelsActorsQuery"] = "FunnelsActorsQuery"+ limit: int | None = Field(+ default=100,+ description=("Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."),+ )+ offset: int | None = Field(+ default=0,+ description=(+ "Number of persons to skip before the returned page. Use it with `limit` to"+ " walk the whole result set: the response reports `limit`, `offset`, and"+ " `hasMore`, so when `hasMore` is true, call again with `offset` raised by"+ " `limit`."+ ),+ )source: AssistantFunnelsQuery = Field(...,description=("The source funnel insight query whose step (or trends point) we are drilling into."),@@ -25058,6 +25071,19 @@ class AssistantPathsActorsQuery(BaseModel):description="Whether to include matched session recordings for each actor.",)kind: Literal["InsightActorsQuery"] = "InsightActorsQuery"+ limit: int | None = Field(+ default=100,+ description=("Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."),+ )+ offset: int | None = Field(+ default=0,+ description=(+ "Number of persons to skip before the returned page. Use it with `limit` to"+ " walk the whole result set: the response reports `limit`, `offset`, and"+ " `hasMore`, so when `hasMore` is true, call again with `offset` raised by"+ " `limit`."+ ),+ )source: AssistantPathsQuery = Field(..., description="The source paths insight query whose actors we are listing.")@@ -25074,6 +25100,19 @@ class AssistantRetentionActorsQuery(BaseModel):),)kind: Literal["InsightActorsQuery"] = "InsightActorsQuery"+ limit: int | None = Field(+ default=100,+ description=("Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."),+ )+ offset: int | None = Field(+ default=0,+ description=(+ "Number of persons to skip before the returned page. Use it with `limit` to"+ " walk the whole cohort: the response reports `limit`, `offset`, and"+ " `hasMore`, so when `hasMore` is true, call again with `offset` raised by"+ " `limit`."+ ),+ )source: AssistantRetentionQuery = Field(...,description=("The source retention insight query whose cohort we are drilling into."),@@ -25098,6 +25137,19 @@ class AssistantStickinessActorsQuery(BaseModel):),)kind: Literal["InsightActorsQuery"] = "InsightActorsQuery"+ limit: int | None = Field(+ default=100,+ description=("Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."),+ )+ offset: int | None = Field(+ default=0,+ description=(+ "Number of persons to skip before the returned page. Use it with `limit` to"+ " walk the whole result set: the response reports `limit`, `offset`, and"+ " `hasMore`, so when `hasMore` is true, call again with `offset` raised by"+ " `limit`."+ ),+ )series: int | None = Field(default=None,description=("0-based index of the series to drill into when the source has multiple series. Defaults to 0."),@@ -25133,6 +25185,19 @@ class AssistantTrendsActorsQuery(BaseModel):description="Whether to include matched session recordings for each actor.",)kind: Literal["InsightActorsQuery"] = "InsightActorsQuery"+ limit: int | None = Field(+ default=100,+ description=("Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."),+ )+ offset: int | None = Field(+ default=0,+ description=(+ "Number of persons to skip before the returned page. Use it with `limit` to"+ " walk the whole result set: the response reports `limit`, `offset`, and"+ " `hasMore`, so when `hasMore` is true, call again with `offset` raised by"+ " `limit`."+ ),+ )series: int | None = Field(default=None,description="Series index (0-based) when the source has multiple series.",@@ -27150,6 +27215,19 @@ class AssistantLifecycleActorsQuery(BaseModel):description=("Bucket date for the data point. Must be an ISO date string (YYYY-MM-DD), e.g. '2024-01-15'."),)kind: Literal["InsightActorsQuery"] = "InsightActorsQuery"+ limit: int | None = Field(+ default=100,+ description=("Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped."),+ )+ offset: int | None = Field(+ default=0,+ description=(+ "Number of persons to skip before the returned page. Use it with `limit` to"+ " walk the whole result set: the response reports `limit`, `offset`, and"+ " `hasMore`, so when `hasMore` is true, call again with `offset` raised by"+ " `limit`."+ ),+ )source: AssistantLifecycleQuery = Field(...,description=("The source lifecycle insight query whose bucket we are drilling into."),diff --git a/products/product_analytics/mcp/apps/InsightActorsView.tsx b/products/product_analytics/mcp/apps/InsightActorsView.tsxindex 580d22428655..0f3e28992213 100644--- a/products/product_analytics/mcp/apps/InsightActorsView.tsx+++ b/products/product_analytics/mcp/apps/InsightActorsView.tsx@@ -101,8 +101,17 @@ function EventCountActorsView({ data, openLink }: InsightActorsViewProps): React<div className="flex flex-col gap-2"><div className="flex items-center justify-between"><span className="text-sm text-muted-foreground">- {rows.length} actor{rows.length === 1 ? '' : 's'}- {data.hasMore ? '+' : ''}+ {data.offset > 0 && rows.length > 0 ? (+ <>+ Actors {data.offset + 1} to {data.offset + rows.length}+ {data.hasMore ? ', more available' : ''}+ </>+ ) : (+ <>+ {rows.length} actor{rows.length === 1 ? '' : 's'}+ {data.hasMore ? '+' : ''}+ </>+ )}</span></div><DataTable<ActorRow>diff --git a/products/product_analytics/mcp/apps/RetentionActorsView.tsx b/products/product_analytics/mcp/apps/RetentionActorsView.tsxindex 4282a8f48097..da08425589dc 100644--- a/products/product_analytics/mcp/apps/RetentionActorsView.tsx+++ b/products/product_analytics/mcp/apps/RetentionActorsView.tsx@@ -68,8 +68,17 @@ export function RetentionActorsView({ data }: { data: InsightActorsData }): Reac<div className="p-4"><div className="flex flex-col gap-2"><span className="text-sm text-muted-foreground">- {rows.length} person{rows.length === 1 ? '' : 's'}- {data.hasMore ? '+' : ''} in this cohort+ {data.offset > 0 && rows.length > 0 ? (+ <>+ Persons {data.offset + 1} to {data.offset + rows.length} in this cohort+ {data.hasMore ? ', more available' : ''}+ </>+ ) : (+ <>+ {rows.length} person{rows.length === 1 ? '' : 's'}+ {data.hasMore ? '+' : ''} in this cohort+ </>+ )}</span><DataTable<RetentionActorRow>columns={columns}diff --git a/services/mcp/definitions/prompts/query-funnel-actors.md b/services/mcp/definitions/prompts/query-funnel-actors.mdindex 1c4a3897b9b7..5a4f734f02cd 100644--- a/services/mcp/definitions/prompts/query-funnel-actors.md+++ b/services/mcp/definitions/prompts/query-funnel-actors.md@@ -32,12 +32,20 @@ Use these two together. Do not mix them with `funnelStep`.> The funnel `time_to_convert` viz type has no persons drilldown — this tool does not support it.+## Paging++- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.+- `offset`: how many persons to skip before the returned page. Defaults to 0.+## Response-Each returned row contains `distinct_id`, `email`, and `name`, plus a `recordings` column when `includeRecordings` is set (default `true`). Results are limited to the top 100 actors.+Each returned row contains `distinct_id`, `email`, and `name`, plus a `recordings` column when `includeRecordings` is set (default `true`).++The response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people at the step — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.## Guidance- Keep the `source` funnel query identical to the one whose step the user is asking about — the series order, date range, conversion window, and filters all determine who converts at each step.- Make sure the mode matches the source's `funnelVizType`: `funnelStep` needs `"steps"` (the default), `funnelTrendsDropOff` needs `"trends"`. Mixing them returns wrong or empty results.-- For large cohorts, tighten the source (date range, filters) rather than expecting more than 100 rows.+- To read every person at a step, page with `offset` rather than raising `limit` past 1000, and keep `source` and the step selectors identical across pages so rows don't repeat or go missing.+- When you only need a sample, one page is enough — tighten the source (date range, filters) instead of paging through everyone.diff --git a/services/mcp/definitions/prompts/query-lifecycle-actors.md b/services/mcp/definitions/prompts/query-lifecycle-actors.mdindex d9b671fd2bd4..8bfeee7b7ee7 100644--- a/services/mcp/definitions/prompts/query-lifecycle-actors.md+++ b/services/mcp/definitions/prompts/query-lifecycle-actors.md@@ -10,14 +10,19 @@ Selectors:- `returning` — users active in the previous period and active in this one.- `resurrecting` — users inactive for one or more periods and active again now.- `dormant` — users active in the previous period but inactive now.+- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.+- `offset`: how many persons to skip before the returned page. Defaults to 0.Response:-Each returned row contains `distinct_id`, `email`, and `name`. Results are limited to the top 100 actors. Matched session recordings are not returned — the lifecycle runner does not project per-actor matching events.+Each returned row contains `distinct_id`, `email`, and `name`. Matched session recordings are not returned — the lifecycle runner does not project per-actor matching events.++The response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the bucket — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.Guidance:- Lifecycle excludes anonymous users (events with `$process_person_profile: false`), so actor lists only contain identified users — anonymous visitors never appear in any bucket.- Lifecycle insights only support a single series and do not expose `compareFilter`, so there is no `series` or `compare` selector here.- Keep the `source` lifecycle query minimal — only include the filters needed to define the same lifecycle population the user is asking about.-- For large buckets, tighten the source query (filters, date range) rather than expecting more rows.+- To read every person in a bucket, page with `offset` rather than raising `limit` past 1000, and keep `source`, `day`, and `status` identical across pages so rows don't repeat or go missing.+- When you only need a sample, one page is enough — tighten the source query (filters, date range) instead of paging through everyone.diff --git a/services/mcp/definitions/prompts/query-paths-actors.md b/services/mcp/definitions/prompts/query-paths-actors.mdindex cc18611628b2..f3c276cd3911 100644--- a/services/mcp/definitions/prompts/query-paths-actors.md+++ b/services/mcp/definitions/prompts/query-paths-actors.md@@ -16,14 +16,19 @@ Two modes:Selectors:- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).+- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.+- `offset`: how many persons to skip before the returned page. Defaults to 0.Response:-Each returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor). When `includeRecordings` is `true` (the default), a `recordings` column is also returned with PostHog replay URLs. Results are limited to the top 100 actors ordered by event count.+Each returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor), ordered by event count. When `includeRecordings` is `true` (the default), a `recordings` column is also returned with PostHog replay URLs.++The response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people on the path — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.Guidance:- Keep the `source` paths query minimal — only include the filters needed to define the same population the user is asking about.- The path keys come straight from a `query-paths` result row's `source` / `target`; do not hand-construct them.- `pathReplacements` and `showFullUrls` are not exposed — they don't change which actors are returned (`showFullUrls` is display-only; `pathReplacements` is covered by `localPathCleaningFilters`).-- For large result sets, narrow the source (start/end point, date range, filters) rather than expecting more rows.+- To read every person, page with `offset` rather than raising `limit` past 1000, and keep `source` identical across pages so rows don't repeat or go missing.+- When you only need a sample, one page is enough — narrow the source (start/end point, date range, filters) instead of paging through everyone.diff --git a/services/mcp/definitions/prompts/query-retention-actors.md b/services/mcp/definitions/prompts/query-retention-actors.mdindex aef0a781dbb6..cf8ddf349412 100644--- a/services/mcp/definitions/prompts/query-retention-actors.md+++ b/services/mcp/definitions/prompts/query-retention-actors.md@@ -5,12 +5,16 @@ Pair this with `query-retention`: first run the retention query to see the cohorSelectors:- `interval`: which acquisition cohort to list, 0-based. `0` is the acquisition interval itself (every actor who entered the cohort), `1` is the cohort that entered one interval later, and so on. Defaults to `0`. This selects a **row** of the retention table; the returned columns then cover every interval for that cohort.+- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.+- `offset`: how many persons to skip before the returned page. Defaults to 0.Response:-`results` is the per-person grid. Each row contains `distinct_id`, `email`, `name`, followed by one column per retention interval — `<period>_0` … `<period>_N`, where `<period>` is the retention period (`day` / `week` / `month` / `hour`). Each interval column is `1` if the actor was active in that interval and `0` if not. `<period>_0` is the acquisition interval and is always `1`. Rows are ordered by how many intervals the actor returned in (most-retained first). Results are limited to the top 100 actors.+`results` is the per-person grid. Each row contains `distinct_id`, `email`, `name`, followed by one column per retention interval — `<period>_0` … `<period>_N`, where `<period>` is the retention period (`day` / `week` / `month` / `hour`). Each interval column is `1` if the actor was active in that interval and `0` if not. `<period>_0` is the acquisition interval and is always `1`. Rows are ordered by how many intervals the actor returned in (most-retained first).-For the per-interval retention **counts and percentages** (the `Day N — count (pct%)` curve), run `query-retention` on the same `source` — those are computed over the full, un-capped cohort. Don't sum these (capped) rows to get cohort retention numbers.+The response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the cohort — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.++For the per-interval retention **counts and percentages** (the `Day N — count (pct%)` curve), run `query-retention` on the same `source` — those are computed over the whole cohort in one pass. Don't sum these (paged) rows to get cohort retention numbers.The number and names of the interval columns come from the source: `retentionFilter.period` sets the prefix, and `retentionFilter.totalIntervals` (or `retentionCustomBrackets.length + 1` when custom brackets are set) sets how many columns there are.@@ -20,4 +24,6 @@ Guidance:- Keep the `source` retention query identical to the one whose cohort the user is asking about — the cohort definition (target/returning events, period, type, brackets) determines who is in each cohort.- `interval` picks the cohort (a **row** of the retention table), not a single cell. The response always spans every return interval as `<period>_N` columns. To get who returned in a specific interval, filter the rows where that column is `1` — the query returns the cohort's whole trajectory, not a single cell.-- To narrow large result sets, tighten the source (date range, filters) rather than expecting more than 100 rows.+- To walk a whole cohort, page with `offset` rather than raising `limit` past 1000 — a page of 1000 people is already large, and paging keeps each response readable.+- Keep `source`, `interval`, and `limit` identical across the pages of one walk. Changing any of them re-cuts the cohort, so rows can repeat or go missing.+- When you only need a sample of the cohort, one page is enough — tighten the source (date range, filters) instead of paging through everyone.diff --git a/services/mcp/definitions/prompts/query-stickiness-actors.md b/services/mcp/definitions/prompts/query-stickiness-actors.mdindex 0b3839a138ac..18dc4c369bbd 100644--- a/services/mcp/definitions/prompts/query-stickiness-actors.md+++ b/services/mcp/definitions/prompts/query-stickiness-actors.md@@ -7,13 +7,18 @@ Selectors:- `day` **(required)**: the number of active intervals to drill into — the X-axis value of the bar. Despite the name, this is an interval **count**, not a date. For a daily insight, `day: 13` lists the users who were active on exactly 13 days within the source's date range; for a weekly insight it is a count of weeks, and so on.- `series`: 0-based index of the series to drill into when the stickiness query has multiple series. Defaults to 0.- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.+- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.+- `offset`: how many persons to skip before the returned page. Defaults to 0.Response:-Each returned row contains `distinct_id`, `email`, and `name`. Results are limited to the top 100 actors. There is no `event_count`, and there is no `includeRecordings` selector — stickiness drilldown is membership-based (active on exactly N intervals) and does not surface a matched-recordings column.+Each returned row contains `distinct_id`, `email`, and `name`. There is no `event_count`, and there is no `includeRecordings` selector — stickiness drilldown is membership-based (active on exactly N intervals) and does not surface a matched-recordings column.++The response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the bar — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.Guidance:- Keep the `source` stickiness query identical to the one whose bar the user is asking about — the series, interval granularity, date range, and filters all determine who falls in each bar.- `day` selects a single bar (a specific active-interval count), not a date. To list the users at a different bar, change `day`.-- For large result sets, tighten the source (date range, filters) rather than expecting more than 100 rows.+- To read every person in a bar, page with `offset` rather than raising `limit` past 1000, and keep `source`, `day`, `series`, `compare`, and `limit` identical across pages so rows don't repeat or go missing.+- When you only need a sample, one page is enough — tighten the source (date range, filters) instead of paging through everyone.diff --git a/services/mcp/definitions/prompts/query-trends-actors.md b/services/mcp/definitions/prompts/query-trends-actors.mdindex 385359cb9dcb..08b333631dfd 100644--- a/services/mcp/definitions/prompts/query-trends-actors.md+++ b/services/mcp/definitions/prompts/query-trends-actors.md@@ -9,13 +9,18 @@ Selectors:- `breakdown`: always an array, one value per `breakdownFilter.breakdowns` dimension, in the same order. Single dimension: `breakdown: ["Opera"]`. Multiple dimensions: `breakdown: ["Opera", "en-US"]`.- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).+- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.+- `offset`: how many persons to skip before the returned page. Defaults to 0.Response:-Each returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor). When `includeRecordings` is `true` (the default), a `recordings` column is also returned containing PostHog replay URLs that can be opened in a browser to watch the user's session. Results are limited to the top 100 actors ordered by event count.+Each returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor), ordered by event count. When `includeRecordings` is `true` (the default), a `recordings` column is also returned containing PostHog replay URLs that can be opened in a browser to watch the user's session.++The response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people behind the data point — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.Guidance:- Keep the `source` trends query minimal - only include the filters/breakdowns needed to identify the cell.- Always pick a specific `day` from the trends result.-- For large result sets, tighten the trends query (filters, date range) rather than expecting more rows.+- To read every person, page with `offset` rather than raising `limit` past 1000, and keep `source` and the other selectors identical across pages so rows don't repeat or go missing.+- When you only need a sample, one page is enough — tighten the trends query (filters, date range) instead of paging through everyone.diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 3dec989d550f..479c1d0081fa 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -8261,7 +8261,7 @@"system_prompt_hint": "Conversion rates, drop-off analysis, time to convert"},"query-funnel-actors": {- "description": "List the persons behind one step of a funnel insight — either those who converted through it or those who dropped off at it.\n\nPair this with `query-funnel`: first run the funnel query to read the per-step counts, then call this tool with the **same** funnel query as `source`. There are two mutually exclusive modes, and the selectors you use must match the source funnel's `funnelsFilter.funnelVizType`.\n\n## Step mode (the default — source `funnelVizType: \"steps\"`)\n\nUse `funnelStep` to pick a step. The **sign** picks the direction:\n\n- **Positive** `funnelStep` lists actors who **converted through** that step.\n- **Negative** `funnelStep` lists actors who **dropped off** at that step.\n\nSteps are **1-based**. Examples for a 3-step funnel:\n\n- `funnelStep: 1` — entered the funnel (reached step 1).\n- `funnelStep: 2` — converted through step 2.\n- `funnelStep: -2` — dropped off at step 2 (reached step 1 but not step 2).\n- `funnelStep: 3` — converted through the whole funnel.\n- `funnelStep: -3` — dropped off at step 3.\n\nYou cannot drop off at the entry step, so the smallest negative value is `-2`. To list every person at each step, call this tool once per `(step, direction)` you care about — a single call returns one cohort, not all steps.\n\n- `funnelStepBreakdown` (optional): scope to one breakdown series. Pass the breakdown value(s) from the matching `query-funnel` result row verbatim (an array, e.g. `[\"Chrome\"]`). Omit for the baseline (non-breakdown) series.\n\n## Trends-dropoff mode (source `funnelVizType: \"trends\"`)\n\nFor a funnel-trends (conversion-over-time) insight, drill into one point on the chart:\n\n- `funnelTrendsDropOff`: `true` lists actors who dropped off, `false` lists those who converted.\n- `funnelTrendsEntrancePeriodStart`: the entrance period as a `YYYY-MM-DD HH:mm:ss` string (e.g. `'2024-01-15 00:00:00'`), taken from the point the user is asking about.\n\nUse these two together. Do not mix them with `funnelStep`.\n\n> The funnel `time_to_convert` viz type has no persons drilldown — this tool does not support it.\n\n## Response\n\nEach returned row contains `distinct_id`, `email`, and `name`, plus a `recordings` column when `includeRecordings` is set (default `true`). Results are limited to the top 100 actors.\n\n## Guidance\n\n- Keep the `source` funnel query identical to the one whose step the user is asking about — the series order, date range, conversion window, and filters all determine who converts at each step.\n- Make sure the mode matches the source's `funnelVizType`: `funnelStep` needs `\"steps\"` (the default), `funnelTrendsDropOff` needs `\"trends\"`. Mixing them returns wrong or empty results.\n- For large cohorts, tighten the source (date range, filters) rather than expecting more than 100 rows.",+ "description": "List the persons behind one step of a funnel insight — either those who converted through it or those who dropped off at it.\n\nPair this with `query-funnel`: first run the funnel query to read the per-step counts, then call this tool with the **same** funnel query as `source`. There are two mutually exclusive modes, and the selectors you use must match the source funnel's `funnelsFilter.funnelVizType`.\n\n## Step mode (the default — source `funnelVizType: \"steps\"`)\n\nUse `funnelStep` to pick a step. The **sign** picks the direction:\n\n- **Positive** `funnelStep` lists actors who **converted through** that step.\n- **Negative** `funnelStep` lists actors who **dropped off** at that step.\n\nSteps are **1-based**. Examples for a 3-step funnel:\n\n- `funnelStep: 1` — entered the funnel (reached step 1).\n- `funnelStep: 2` — converted through step 2.\n- `funnelStep: -2` — dropped off at step 2 (reached step 1 but not step 2).\n- `funnelStep: 3` — converted through the whole funnel.\n- `funnelStep: -3` — dropped off at step 3.\n\nYou cannot drop off at the entry step, so the smallest negative value is `-2`. To list every person at each step, call this tool once per `(step, direction)` you care about — a single call returns one cohort, not all steps.\n\n- `funnelStepBreakdown` (optional): scope to one breakdown series. Pass the breakdown value(s) from the matching `query-funnel` result row verbatim (an array, e.g. `[\"Chrome\"]`). Omit for the baseline (non-breakdown) series.\n\n## Trends-dropoff mode (source `funnelVizType: \"trends\"`)\n\nFor a funnel-trends (conversion-over-time) insight, drill into one point on the chart:\n\n- `funnelTrendsDropOff`: `true` lists actors who dropped off, `false` lists those who converted.\n- `funnelTrendsEntrancePeriodStart`: the entrance period as a `YYYY-MM-DD HH:mm:ss` string (e.g. `'2024-01-15 00:00:00'`), taken from the point the user is asking about.\n\nUse these two together. Do not mix them with `funnelStep`.\n\n> The funnel `time_to_convert` viz type has no persons drilldown — this tool does not support it.\n\n## Paging\n\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\n## Response\n\nEach returned row contains `distinct_id`, `email`, and `name`, plus a `recordings` column when `includeRecordings` is set (default `true`).\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people at the step — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\n## Guidance\n\n- Keep the `source` funnel query identical to the one whose step the user is asking about — the series order, date range, conversion window, and filters all determine who converts at each step.\n- Make sure the mode matches the source's `funnelVizType`: `funnelStep` needs `\"steps\"` (the default), `funnelTrendsDropOff` needs `\"trends\"`. Mixing them returns wrong or empty results.\n- To read every person at a step, page with `offset` rather than raising `limit` past 1000, and keep `source` and the step selectors identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the source (date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons who converted or dropped off at a funnel step",@@ -8291,7 +8291,7 @@"system_prompt_hint": "New, returning, resurrecting, dormant user composition"},"query-lifecycle-actors": {- "description": "List the persons in a specific bucket of a lifecycle insight. Use this to answer \"who are the new / returning / resurrecting / dormant users on day Y?\".\n\n`source` is the lifecycle query that defines the population (event, date range, filters). Build it directly when the user's request already names a bucket-day, or reuse one you previously ran via `query-lifecycle` when drilling in from a chart.\n\nSelectors:\n\n- `day` **(required)**: the bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must align with the source's interval (a day boundary for `interval=day`, the start of the week for `interval=week`, etc.).\n- `status` **(required)**: which lifecycle bucket to drill into. One of `new`, `returning`, `resurrecting`, `dormant`.\n - `new` — users seen for the first time (person profile created) during the period.\n - `returning` — users active in the previous period and active in this one.\n - `resurrecting` — users inactive for one or more periods and active again now.\n - `dormant` — users active in the previous period but inactive now.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. Results are limited to the top 100 actors. Matched session recordings are not returned — the lifecycle runner does not project per-actor matching events.\n\nGuidance:\n\n- Lifecycle excludes anonymous users (events with `$process_person_profile: false`), so actor lists only contain identified users — anonymous visitors never appear in any bucket.\n- Lifecycle insights only support a single series and do not expose `compareFilter`, so there is no `series` or `compare` selector here.\n- Keep the `source` lifecycle query minimal — only include the filters needed to define the same lifecycle population the user is asking about.\n- For large buckets, tighten the source query (filters, date range) rather than expecting more rows.",+ "description": "List the persons in a specific bucket of a lifecycle insight. Use this to answer \"who are the new / returning / resurrecting / dormant users on day Y?\".\n\n`source` is the lifecycle query that defines the population (event, date range, filters). Build it directly when the user's request already names a bucket-day, or reuse one you previously ran via `query-lifecycle` when drilling in from a chart.\n\nSelectors:\n\n- `day` **(required)**: the bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must align with the source's interval (a day boundary for `interval=day`, the start of the week for `interval=week`, etc.).\n- `status` **(required)**: which lifecycle bucket to drill into. One of `new`, `returning`, `resurrecting`, `dormant`.\n - `new` — users seen for the first time (person profile created) during the period.\n - `returning` — users active in the previous period and active in this one.\n - `resurrecting` — users inactive for one or more periods and active again now.\n - `dormant` — users active in the previous period but inactive now.\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. Matched session recordings are not returned — the lifecycle runner does not project per-actor matching events.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the bucket — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Lifecycle excludes anonymous users (events with `$process_person_profile: false`), so actor lists only contain identified users — anonymous visitors never appear in any bucket.\n- Lifecycle insights only support a single series and do not expose `compareFilter`, so there is no `series` or `compare` selector here.\n- Keep the `source` lifecycle query minimal — only include the filters needed to define the same lifecycle population the user is asking about.\n- To read every person in a bucket, page with `offset` rather than raising `limit` past 1000, and keep `source`, `day`, and `status` identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the source query (filters, date range) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons in a lifecycle bucket",@@ -8526,7 +8526,7 @@"system_prompt_hint": "User navigation flows and sequences"},"query-paths-actors": {- "description": "List the persons behind a paths insight — either everyone who traversed the path, or those at one specific node/edge.\n\nPair this with `query-paths`: first run the paths query to see the flows (each result row is an edge `source → target` with a user count), then call this tool with the **same** paths query as `source`.\n\nTwo modes:\n\n**1. Everyone on the path (A → B).** Set `startPoint` / `endPoint` on the source `pathsFilter` and leave the path keys unset. Returns every actor whose journey matches that start/end constraint. Use this for \"who went from a.com to b.com?\".\n\n**2. Actors at a specific point.** Each node in the path graph has a key of the form `<stepIndex>_<value>` (e.g. `\"3_https://example.com/checkout\"`). The `source` and `target` fields of a `query-paths` result row **are** these keys — copy them verbatim. Set on the source `pathsFilter`:\n\n- `pathEndKey` — persons who **arrived at** that node (use a row's `target`).\n- `pathStartKey` — persons who **departed from** that node (use a row's `source`).\n- Set **both** `pathStartKey` + `pathEndKey` to pin a single edge (the actors behind one `source → target` count).\n- `pathDropoffKey` — persons who **dropped off** at that node. Mutually exclusive with the other two.\n\nSelectors:\n\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor). When `includeRecordings` is `true` (the default), a `recordings` column is also returned with PostHog replay URLs. Results are limited to the top 100 actors ordered by event count.\n\nGuidance:\n\n- Keep the `source` paths query minimal — only include the filters needed to define the same population the user is asking about.\n- The path keys come straight from a `query-paths` result row's `source` / `target`; do not hand-construct them.\n- `pathReplacements` and `showFullUrls` are not exposed — they don't change which actors are returned (`showFullUrls` is display-only; `pathReplacements` is covered by `localPathCleaningFilters`).\n- For large result sets, narrow the source (start/end point, date range, filters) rather than expecting more rows.",+ "description": "List the persons behind a paths insight — either everyone who traversed the path, or those at one specific node/edge.\n\nPair this with `query-paths`: first run the paths query to see the flows (each result row is an edge `source → target` with a user count), then call this tool with the **same** paths query as `source`.\n\nTwo modes:\n\n**1. Everyone on the path (A → B).** Set `startPoint` / `endPoint` on the source `pathsFilter` and leave the path keys unset. Returns every actor whose journey matches that start/end constraint. Use this for \"who went from a.com to b.com?\".\n\n**2. Actors at a specific point.** Each node in the path graph has a key of the form `<stepIndex>_<value>` (e.g. `\"3_https://example.com/checkout\"`). The `source` and `target` fields of a `query-paths` result row **are** these keys — copy them verbatim. Set on the source `pathsFilter`:\n\n- `pathEndKey` — persons who **arrived at** that node (use a row's `target`).\n- `pathStartKey` — persons who **departed from** that node (use a row's `source`).\n- Set **both** `pathStartKey` + `pathEndKey` to pin a single edge (the actors behind one `source → target` count).\n- `pathDropoffKey` — persons who **dropped off** at that node. Mutually exclusive with the other two.\n\nSelectors:\n\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor), ordered by event count. When `includeRecordings` is `true` (the default), a `recordings` column is also returned with PostHog replay URLs.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people on the path — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Keep the `source` paths query minimal — only include the filters needed to define the same population the user is asking about.\n- The path keys come straight from a `query-paths` result row's `source` / `target`; do not hand-construct them.\n- `pathReplacements` and `showFullUrls` are not exposed — they don't change which actors are returned (`showFullUrls` is display-only; `pathReplacements` is covered by `localPathCleaningFilters`).\n- To read every person, page with `offset` rather than raising `limit` past 1000, and keep `source` identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — narrow the source (start/end point, date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons on a paths insight",@@ -8556,7 +8556,7 @@"system_prompt_hint": "User return patterns over time"},"query-retention-actors": {- "description": "List the persons in one retention acquisition cohort and show, for each, which subsequent intervals they came back in.\n\nPair this with `query-retention`: first run the retention query to see the cohort table (rows are acquisition cohorts, columns are intervals after acquisition), then call this tool with the **same** retention query as `source` to drill into one cohort.\n\nSelectors:\n\n- `interval`: which acquisition cohort to list, 0-based. `0` is the acquisition interval itself (every actor who entered the cohort), `1` is the cohort that entered one interval later, and so on. Defaults to `0`. This selects a **row** of the retention table; the returned columns then cover every interval for that cohort.\n\nResponse:\n\n`results` is the per-person grid. Each row contains `distinct_id`, `email`, `name`, followed by one column per retention interval — `<period>_0` … `<period>_N`, where `<period>` is the retention period (`day` / `week` / `month` / `hour`). Each interval column is `1` if the actor was active in that interval and `0` if not. `<period>_0` is the acquisition interval and is always `1`. Rows are ordered by how many intervals the actor returned in (most-retained first). Results are limited to the top 100 actors.\n\nFor the per-interval retention **counts and percentages** (the `Day N — count (pct%)` curve), run `query-retention` on the same `source` — those are computed over the full, un-capped cohort. Don't sum these (capped) rows to get cohort retention numbers.\n\nThe number and names of the interval columns come from the source: `retentionFilter.period` sets the prefix, and `retentionFilter.totalIntervals` (or `retentionCustomBrackets.length + 1` when custom brackets are set) sets how many columns there are.\n\nThere is no `includeRecordings` selector — retention's persons output is appearance-based and does not surface matched session recordings.\n\nGuidance:\n\n- Keep the `source` retention query identical to the one whose cohort the user is asking about — the cohort definition (target/returning events, period, type, brackets) determines who is in each cohort.\n- `interval` picks the cohort (a **row** of the retention table), not a single cell. The response always spans every return interval as `<period>_N` columns. To get who returned in a specific interval, filter the rows where that column is `1` — the query returns the cohort's whole trajectory, not a single cell.\n- To narrow large result sets, tighten the source (date range, filters) rather than expecting more than 100 rows.",+ "description": "List the persons in one retention acquisition cohort and show, for each, which subsequent intervals they came back in.\n\nPair this with `query-retention`: first run the retention query to see the cohort table (rows are acquisition cohorts, columns are intervals after acquisition), then call this tool with the **same** retention query as `source` to drill into one cohort.\n\nSelectors:\n\n- `interval`: which acquisition cohort to list, 0-based. `0` is the acquisition interval itself (every actor who entered the cohort), `1` is the cohort that entered one interval later, and so on. Defaults to `0`. This selects a **row** of the retention table; the returned columns then cover every interval for that cohort.\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\n`results` is the per-person grid. Each row contains `distinct_id`, `email`, `name`, followed by one column per retention interval — `<period>_0` … `<period>_N`, where `<period>` is the retention period (`day` / `week` / `month` / `hour`). Each interval column is `1` if the actor was active in that interval and `0` if not. `<period>_0` is the acquisition interval and is always `1`. Rows are ordered by how many intervals the actor returned in (most-retained first).\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the cohort — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nFor the per-interval retention **counts and percentages** (the `Day N — count (pct%)` curve), run `query-retention` on the same `source` — those are computed over the whole cohort in one pass. Don't sum these (paged) rows to get cohort retention numbers.\n\nThe number and names of the interval columns come from the source: `retentionFilter.period` sets the prefix, and `retentionFilter.totalIntervals` (or `retentionCustomBrackets.length + 1` when custom brackets are set) sets how many columns there are.\n\nThere is no `includeRecordings` selector — retention's persons output is appearance-based and does not surface matched session recordings.\n\nGuidance:\n\n- Keep the `source` retention query identical to the one whose cohort the user is asking about — the cohort definition (target/returning events, period, type, brackets) determines who is in each cohort.\n- `interval` picks the cohort (a **row** of the retention table), not a single cell. The response always spans every return interval as `<period>_N` columns. To get who returned in a specific interval, filter the rows where that column is `1` — the query returns the cohort's whole trajectory, not a single cell.\n- To walk a whole cohort, page with `offset` rather than raising `limit` past 1000 — a page of 1000 people is already large, and paging keeps each response readable.\n- Keep `source`, `interval`, and `limit` identical across the pages of one walk. Changing any of them re-cuts the cohort, so rows can repeat or go missing.\n- When you only need a sample of the cohort, one page is enough — tighten the source (date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons in a retention cohort",@@ -8601,7 +8601,7 @@"system_prompt_hint": "Engagement frequency (how many days users do X)"},"query-stickiness-actors": {- "description": "List the persons behind one bar of a stickiness insight — the users who were active in a given number of intervals.\n\nPair this with `query-stickiness`: first run the stickiness query to read the distribution (the X-axis is the number of active intervals, the Y-axis is the number of users), then call this tool with the **same** stickiness query as `source` and `day` set to the bar you want to drill into.\n\nSelectors:\n\n- `day` **(required)**: the number of active intervals to drill into — the X-axis value of the bar. Despite the name, this is an interval **count**, not a date. For a daily insight, `day: 13` lists the users who were active on exactly 13 days within the source's date range; for a weekly insight it is a count of weeks, and so on.\n- `series`: 0-based index of the series to drill into when the stickiness query has multiple series. Defaults to 0.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. Results are limited to the top 100 actors. There is no `event_count`, and there is no `includeRecordings` selector — stickiness drilldown is membership-based (active on exactly N intervals) and does not surface a matched-recordings column.\n\nGuidance:\n\n- Keep the `source` stickiness query identical to the one whose bar the user is asking about — the series, interval granularity, date range, and filters all determine who falls in each bar.\n- `day` selects a single bar (a specific active-interval count), not a date. To list the users at a different bar, change `day`.\n- For large result sets, tighten the source (date range, filters) rather than expecting more than 100 rows.",+ "description": "List the persons behind one bar of a stickiness insight — the users who were active in a given number of intervals.\n\nPair this with `query-stickiness`: first run the stickiness query to read the distribution (the X-axis is the number of active intervals, the Y-axis is the number of users), then call this tool with the **same** stickiness query as `source` and `day` set to the bar you want to drill into.\n\nSelectors:\n\n- `day` **(required)**: the number of active intervals to drill into — the X-axis value of the bar. Despite the name, this is an interval **count**, not a date. For a daily insight, `day: 13` lists the users who were active on exactly 13 days within the source's date range; for a weekly insight it is a count of weeks, and so on.\n- `series`: 0-based index of the series to drill into when the stickiness query has multiple series. Defaults to 0.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. There is no `event_count`, and there is no `includeRecordings` selector — stickiness drilldown is membership-based (active on exactly N intervals) and does not surface a matched-recordings column.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the bar — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Keep the `source` stickiness query identical to the one whose bar the user is asking about — the series, interval granularity, date range, and filters all determine who falls in each bar.\n- `day` selects a single bar (a specific active-interval count), not a date. To list the users at a different bar, change `day`.\n- To read every person in a bar, page with `offset` rather than raising `limit` past 1000, and keep `source`, `day`, `series`, `compare`, and `limit` identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the source (date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons behind a stickiness bar",@@ -8631,7 +8631,7 @@"system_prompt_hint": "Time series, aggregations, formulas, comparisons"},"query-trends-actors": {- "description": "List the persons behind a specific data point in a trends insight. Use this to answer \"who were the users that did X on day Y?\" or \"which users are in this breakdown bucket?\".\n\nPair this with `query-trends`: first run the trends query to identify the data point of interest, then call this tool with the same trends query as `source` plus selectors that narrow to one cell.\n\nSelectors:\n\n- `day` **(required)**: a single bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must match exactly one data point from the trends result.\n- `series`: 0-based index of the series to drill into when the trends query has multiple series. Defaults to 0.\n- `breakdown`: always an array, one value per `breakdownFilter.breakdowns` dimension, in the same order. Single dimension: `breakdown: [\"Opera\"]`. Multiple dimensions: `breakdown: [\"Opera\", \"en-US\"]`.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor). When `includeRecordings` is `true` (the default), a `recordings` column is also returned containing PostHog replay URLs that can be opened in a browser to watch the user's session. Results are limited to the top 100 actors ordered by event count.\n\nGuidance:\n\n- Keep the `source` trends query minimal - only include the filters/breakdowns needed to identify the cell.\n- Always pick a specific `day` from the trends result.\n- For large result sets, tighten the trends query (filters, date range) rather than expecting more rows.",+ "description": "List the persons behind a specific data point in a trends insight. Use this to answer \"who were the users that did X on day Y?\" or \"which users are in this breakdown bucket?\".\n\nPair this with `query-trends`: first run the trends query to identify the data point of interest, then call this tool with the same trends query as `source` plus selectors that narrow to one cell.\n\nSelectors:\n\n- `day` **(required)**: a single bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must match exactly one data point from the trends result.\n- `series`: 0-based index of the series to drill into when the trends query has multiple series. Defaults to 0.\n- `breakdown`: always an array, one value per `breakdownFilter.breakdowns` dimension, in the same order. Single dimension: `breakdown: [\"Opera\"]`. Multiple dimensions: `breakdown: [\"Opera\", \"en-US\"]`.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor), ordered by event count. When `includeRecordings` is `true` (the default), a `recordings` column is also returned containing PostHog replay URLs that can be opened in a browser to watch the user's session.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people behind the data point — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Keep the `source` trends query minimal - only include the filters/breakdowns needed to identify the cell.\n- Always pick a specific `day` from the trends result.\n- To read every person, page with `offset` rather than raising `limit` past 1000, and keep `source` and the other selectors identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the trends query (filters, date range) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons behind a trends data point",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 100e52293e75..95ae01f1fe1d 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -8788,7 +8788,7 @@"system_prompt_hint": "Conversion rates, drop-off analysis, time to convert"},"query-funnel-actors": {- "description": "List the persons behind one step of a funnel insight — either those who converted through it or those who dropped off at it.\n\nPair this with `query-funnel`: first run the funnel query to read the per-step counts, then call this tool with the **same** funnel query as `source`. There are two mutually exclusive modes, and the selectors you use must match the source funnel's `funnelsFilter.funnelVizType`.\n\n## Step mode (the default — source `funnelVizType: \"steps\"`)\n\nUse `funnelStep` to pick a step. The **sign** picks the direction:\n\n- **Positive** `funnelStep` lists actors who **converted through** that step.\n- **Negative** `funnelStep` lists actors who **dropped off** at that step.\n\nSteps are **1-based**. Examples for a 3-step funnel:\n\n- `funnelStep: 1` — entered the funnel (reached step 1).\n- `funnelStep: 2` — converted through step 2.\n- `funnelStep: -2` — dropped off at step 2 (reached step 1 but not step 2).\n- `funnelStep: 3` — converted through the whole funnel.\n- `funnelStep: -3` — dropped off at step 3.\n\nYou cannot drop off at the entry step, so the smallest negative value is `-2`. To list every person at each step, call this tool once per `(step, direction)` you care about — a single call returns one cohort, not all steps.\n\n- `funnelStepBreakdown` (optional): scope to one breakdown series. Pass the breakdown value(s) from the matching `query-funnel` result row verbatim (an array, e.g. `[\"Chrome\"]`). Omit for the baseline (non-breakdown) series.\n\n## Trends-dropoff mode (source `funnelVizType: \"trends\"`)\n\nFor a funnel-trends (conversion-over-time) insight, drill into one point on the chart:\n\n- `funnelTrendsDropOff`: `true` lists actors who dropped off, `false` lists those who converted.\n- `funnelTrendsEntrancePeriodStart`: the entrance period as a `YYYY-MM-DD HH:mm:ss` string (e.g. `'2024-01-15 00:00:00'`), taken from the point the user is asking about.\n\nUse these two together. Do not mix them with `funnelStep`.\n\n> The funnel `time_to_convert` viz type has no persons drilldown — this tool does not support it.\n\n## Response\n\nEach returned row contains `distinct_id`, `email`, and `name`, plus a `recordings` column when `includeRecordings` is set (default `true`). Results are limited to the top 100 actors.\n\n## Guidance\n\n- Keep the `source` funnel query identical to the one whose step the user is asking about — the series order, date range, conversion window, and filters all determine who converts at each step.\n- Make sure the mode matches the source's `funnelVizType`: `funnelStep` needs `\"steps\"` (the default), `funnelTrendsDropOff` needs `\"trends\"`. Mixing them returns wrong or empty results.\n- For large cohorts, tighten the source (date range, filters) rather than expecting more than 100 rows.",+ "description": "List the persons behind one step of a funnel insight — either those who converted through it or those who dropped off at it.\n\nPair this with `query-funnel`: first run the funnel query to read the per-step counts, then call this tool with the **same** funnel query as `source`. There are two mutually exclusive modes, and the selectors you use must match the source funnel's `funnelsFilter.funnelVizType`.\n\n## Step mode (the default — source `funnelVizType: \"steps\"`)\n\nUse `funnelStep` to pick a step. The **sign** picks the direction:\n\n- **Positive** `funnelStep` lists actors who **converted through** that step.\n- **Negative** `funnelStep` lists actors who **dropped off** at that step.\n\nSteps are **1-based**. Examples for a 3-step funnel:\n\n- `funnelStep: 1` — entered the funnel (reached step 1).\n- `funnelStep: 2` — converted through step 2.\n- `funnelStep: -2` — dropped off at step 2 (reached step 1 but not step 2).\n- `funnelStep: 3` — converted through the whole funnel.\n- `funnelStep: -3` — dropped off at step 3.\n\nYou cannot drop off at the entry step, so the smallest negative value is `-2`. To list every person at each step, call this tool once per `(step, direction)` you care about — a single call returns one cohort, not all steps.\n\n- `funnelStepBreakdown` (optional): scope to one breakdown series. Pass the breakdown value(s) from the matching `query-funnel` result row verbatim (an array, e.g. `[\"Chrome\"]`). Omit for the baseline (non-breakdown) series.\n\n## Trends-dropoff mode (source `funnelVizType: \"trends\"`)\n\nFor a funnel-trends (conversion-over-time) insight, drill into one point on the chart:\n\n- `funnelTrendsDropOff`: `true` lists actors who dropped off, `false` lists those who converted.\n- `funnelTrendsEntrancePeriodStart`: the entrance period as a `YYYY-MM-DD HH:mm:ss` string (e.g. `'2024-01-15 00:00:00'`), taken from the point the user is asking about.\n\nUse these two together. Do not mix them with `funnelStep`.\n\n> The funnel `time_to_convert` viz type has no persons drilldown — this tool does not support it.\n\n## Paging\n\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\n## Response\n\nEach returned row contains `distinct_id`, `email`, and `name`, plus a `recordings` column when `includeRecordings` is set (default `true`).\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people at the step — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\n## Guidance\n\n- Keep the `source` funnel query identical to the one whose step the user is asking about — the series order, date range, conversion window, and filters all determine who converts at each step.\n- Make sure the mode matches the source's `funnelVizType`: `funnelStep` needs `\"steps\"` (the default), `funnelTrendsDropOff` needs `\"trends\"`. Mixing them returns wrong or empty results.\n- To read every person at a step, page with `offset` rather than raising `limit` past 1000, and keep `source` and the step selectors identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the source (date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons who converted or dropped off at a funnel step",@@ -8818,7 +8818,7 @@"system_prompt_hint": "New, returning, resurrecting, dormant user composition"},"query-lifecycle-actors": {- "description": "List the persons in a specific bucket of a lifecycle insight. Use this to answer \"who are the new / returning / resurrecting / dormant users on day Y?\".\n\n`source` is the lifecycle query that defines the population (event, date range, filters). Build it directly when the user's request already names a bucket-day, or reuse one you previously ran via `query-lifecycle` when drilling in from a chart.\n\nSelectors:\n\n- `day` **(required)**: the bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must align with the source's interval (a day boundary for `interval=day`, the start of the week for `interval=week`, etc.).\n- `status` **(required)**: which lifecycle bucket to drill into. One of `new`, `returning`, `resurrecting`, `dormant`.\n - `new` — users seen for the first time (person profile created) during the period.\n - `returning` — users active in the previous period and active in this one.\n - `resurrecting` — users inactive for one or more periods and active again now.\n - `dormant` — users active in the previous period but inactive now.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. Results are limited to the top 100 actors. Matched session recordings are not returned — the lifecycle runner does not project per-actor matching events.\n\nGuidance:\n\n- Lifecycle excludes anonymous users (events with `$process_person_profile: false`), so actor lists only contain identified users — anonymous visitors never appear in any bucket.\n- Lifecycle insights only support a single series and do not expose `compareFilter`, so there is no `series` or `compare` selector here.\n- Keep the `source` lifecycle query minimal — only include the filters needed to define the same lifecycle population the user is asking about.\n- For large buckets, tighten the source query (filters, date range) rather than expecting more rows.",+ "description": "List the persons in a specific bucket of a lifecycle insight. Use this to answer \"who are the new / returning / resurrecting / dormant users on day Y?\".\n\n`source` is the lifecycle query that defines the population (event, date range, filters). Build it directly when the user's request already names a bucket-day, or reuse one you previously ran via `query-lifecycle` when drilling in from a chart.\n\nSelectors:\n\n- `day` **(required)**: the bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must align with the source's interval (a day boundary for `interval=day`, the start of the week for `interval=week`, etc.).\n- `status` **(required)**: which lifecycle bucket to drill into. One of `new`, `returning`, `resurrecting`, `dormant`.\n - `new` — users seen for the first time (person profile created) during the period.\n - `returning` — users active in the previous period and active in this one.\n - `resurrecting` — users inactive for one or more periods and active again now.\n - `dormant` — users active in the previous period but inactive now.\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. Matched session recordings are not returned — the lifecycle runner does not project per-actor matching events.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the bucket — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Lifecycle excludes anonymous users (events with `$process_person_profile: false`), so actor lists only contain identified users — anonymous visitors never appear in any bucket.\n- Lifecycle insights only support a single series and do not expose `compareFilter`, so there is no `series` or `compare` selector here.\n- Keep the `source` lifecycle query minimal — only include the filters needed to define the same lifecycle population the user is asking about.\n- To read every person in a bucket, page with `offset` rather than raising `limit` past 1000, and keep `source`, `day`, and `status` identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the source query (filters, date range) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons in a lifecycle bucket",@@ -9053,7 +9053,7 @@"system_prompt_hint": "User navigation flows and sequences"},"query-paths-actors": {- "description": "List the persons behind a paths insight — either everyone who traversed the path, or those at one specific node/edge.\n\nPair this with `query-paths`: first run the paths query to see the flows (each result row is an edge `source → target` with a user count), then call this tool with the **same** paths query as `source`.\n\nTwo modes:\n\n**1. Everyone on the path (A → B).** Set `startPoint` / `endPoint` on the source `pathsFilter` and leave the path keys unset. Returns every actor whose journey matches that start/end constraint. Use this for \"who went from a.com to b.com?\".\n\n**2. Actors at a specific point.** Each node in the path graph has a key of the form `<stepIndex>_<value>` (e.g. `\"3_https://example.com/checkout\"`). The `source` and `target` fields of a `query-paths` result row **are** these keys — copy them verbatim. Set on the source `pathsFilter`:\n\n- `pathEndKey` — persons who **arrived at** that node (use a row's `target`).\n- `pathStartKey` — persons who **departed from** that node (use a row's `source`).\n- Set **both** `pathStartKey` + `pathEndKey` to pin a single edge (the actors behind one `source → target` count).\n- `pathDropoffKey` — persons who **dropped off** at that node. Mutually exclusive with the other two.\n\nSelectors:\n\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor). When `includeRecordings` is `true` (the default), a `recordings` column is also returned with PostHog replay URLs. Results are limited to the top 100 actors ordered by event count.\n\nGuidance:\n\n- Keep the `source` paths query minimal — only include the filters needed to define the same population the user is asking about.\n- The path keys come straight from a `query-paths` result row's `source` / `target`; do not hand-construct them.\n- `pathReplacements` and `showFullUrls` are not exposed — they don't change which actors are returned (`showFullUrls` is display-only; `pathReplacements` is covered by `localPathCleaningFilters`).\n- For large result sets, narrow the source (start/end point, date range, filters) rather than expecting more rows.",+ "description": "List the persons behind a paths insight — either everyone who traversed the path, or those at one specific node/edge.\n\nPair this with `query-paths`: first run the paths query to see the flows (each result row is an edge `source → target` with a user count), then call this tool with the **same** paths query as `source`.\n\nTwo modes:\n\n**1. Everyone on the path (A → B).** Set `startPoint` / `endPoint` on the source `pathsFilter` and leave the path keys unset. Returns every actor whose journey matches that start/end constraint. Use this for \"who went from a.com to b.com?\".\n\n**2. Actors at a specific point.** Each node in the path graph has a key of the form `<stepIndex>_<value>` (e.g. `\"3_https://example.com/checkout\"`). The `source` and `target` fields of a `query-paths` result row **are** these keys — copy them verbatim. Set on the source `pathsFilter`:\n\n- `pathEndKey` — persons who **arrived at** that node (use a row's `target`).\n- `pathStartKey` — persons who **departed from** that node (use a row's `source`).\n- Set **both** `pathStartKey` + `pathEndKey` to pin a single edge (the actors behind one `source → target` count).\n- `pathDropoffKey` — persons who **dropped off** at that node. Mutually exclusive with the other two.\n\nSelectors:\n\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor), ordered by event count. When `includeRecordings` is `true` (the default), a `recordings` column is also returned with PostHog replay URLs.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people on the path — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Keep the `source` paths query minimal — only include the filters needed to define the same population the user is asking about.\n- The path keys come straight from a `query-paths` result row's `source` / `target`; do not hand-construct them.\n- `pathReplacements` and `showFullUrls` are not exposed — they don't change which actors are returned (`showFullUrls` is display-only; `pathReplacements` is covered by `localPathCleaningFilters`).\n- To read every person, page with `offset` rather than raising `limit` past 1000, and keep `source` identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — narrow the source (start/end point, date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons on a paths insight",@@ -9083,7 +9083,7 @@"system_prompt_hint": "User return patterns over time"},"query-retention-actors": {- "description": "List the persons in one retention acquisition cohort and show, for each, which subsequent intervals they came back in.\n\nPair this with `query-retention`: first run the retention query to see the cohort table (rows are acquisition cohorts, columns are intervals after acquisition), then call this tool with the **same** retention query as `source` to drill into one cohort.\n\nSelectors:\n\n- `interval`: which acquisition cohort to list, 0-based. `0` is the acquisition interval itself (every actor who entered the cohort), `1` is the cohort that entered one interval later, and so on. Defaults to `0`. This selects a **row** of the retention table; the returned columns then cover every interval for that cohort.\n\nResponse:\n\n`results` is the per-person grid. Each row contains `distinct_id`, `email`, `name`, followed by one column per retention interval — `<period>_0` … `<period>_N`, where `<period>` is the retention period (`day` / `week` / `month` / `hour`). Each interval column is `1` if the actor was active in that interval and `0` if not. `<period>_0` is the acquisition interval and is always `1`. Rows are ordered by how many intervals the actor returned in (most-retained first). Results are limited to the top 100 actors.\n\nFor the per-interval retention **counts and percentages** (the `Day N — count (pct%)` curve), run `query-retention` on the same `source` — those are computed over the full, un-capped cohort. Don't sum these (capped) rows to get cohort retention numbers.\n\nThe number and names of the interval columns come from the source: `retentionFilter.period` sets the prefix, and `retentionFilter.totalIntervals` (or `retentionCustomBrackets.length + 1` when custom brackets are set) sets how many columns there are.\n\nThere is no `includeRecordings` selector — retention's persons output is appearance-based and does not surface matched session recordings.\n\nGuidance:\n\n- Keep the `source` retention query identical to the one whose cohort the user is asking about — the cohort definition (target/returning events, period, type, brackets) determines who is in each cohort.\n- `interval` picks the cohort (a **row** of the retention table), not a single cell. The response always spans every return interval as `<period>_N` columns. To get who returned in a specific interval, filter the rows where that column is `1` — the query returns the cohort's whole trajectory, not a single cell.\n- To narrow large result sets, tighten the source (date range, filters) rather than expecting more than 100 rows.",+ "description": "List the persons in one retention acquisition cohort and show, for each, which subsequent intervals they came back in.\n\nPair this with `query-retention`: first run the retention query to see the cohort table (rows are acquisition cohorts, columns are intervals after acquisition), then call this tool with the **same** retention query as `source` to drill into one cohort.\n\nSelectors:\n\n- `interval`: which acquisition cohort to list, 0-based. `0` is the acquisition interval itself (every actor who entered the cohort), `1` is the cohort that entered one interval later, and so on. Defaults to `0`. This selects a **row** of the retention table; the returned columns then cover every interval for that cohort.\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\n`results` is the per-person grid. Each row contains `distinct_id`, `email`, `name`, followed by one column per retention interval — `<period>_0` … `<period>_N`, where `<period>` is the retention period (`day` / `week` / `month` / `hour`). Each interval column is `1` if the actor was active in that interval and `0` if not. `<period>_0` is the acquisition interval and is always `1`. Rows are ordered by how many intervals the actor returned in (most-retained first).\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the cohort — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nFor the per-interval retention **counts and percentages** (the `Day N — count (pct%)` curve), run `query-retention` on the same `source` — those are computed over the whole cohort in one pass. Don't sum these (paged) rows to get cohort retention numbers.\n\nThe number and names of the interval columns come from the source: `retentionFilter.period` sets the prefix, and `retentionFilter.totalIntervals` (or `retentionCustomBrackets.length + 1` when custom brackets are set) sets how many columns there are.\n\nThere is no `includeRecordings` selector — retention's persons output is appearance-based and does not surface matched session recordings.\n\nGuidance:\n\n- Keep the `source` retention query identical to the one whose cohort the user is asking about — the cohort definition (target/returning events, period, type, brackets) determines who is in each cohort.\n- `interval` picks the cohort (a **row** of the retention table), not a single cell. The response always spans every return interval as `<period>_N` columns. To get who returned in a specific interval, filter the rows where that column is `1` — the query returns the cohort's whole trajectory, not a single cell.\n- To walk a whole cohort, page with `offset` rather than raising `limit` past 1000 — a page of 1000 people is already large, and paging keeps each response readable.\n- Keep `source`, `interval`, and `limit` identical across the pages of one walk. Changing any of them re-cuts the cohort, so rows can repeat or go missing.\n- When you only need a sample of the cohort, one page is enough — tighten the source (date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons in a retention cohort",@@ -9128,7 +9128,7 @@"system_prompt_hint": "Engagement frequency (how many days users do X)"},"query-stickiness-actors": {- "description": "List the persons behind one bar of a stickiness insight — the users who were active in a given number of intervals.\n\nPair this with `query-stickiness`: first run the stickiness query to read the distribution (the X-axis is the number of active intervals, the Y-axis is the number of users), then call this tool with the **same** stickiness query as `source` and `day` set to the bar you want to drill into.\n\nSelectors:\n\n- `day` **(required)**: the number of active intervals to drill into — the X-axis value of the bar. Despite the name, this is an interval **count**, not a date. For a daily insight, `day: 13` lists the users who were active on exactly 13 days within the source's date range; for a weekly insight it is a count of weeks, and so on.\n- `series`: 0-based index of the series to drill into when the stickiness query has multiple series. Defaults to 0.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. Results are limited to the top 100 actors. There is no `event_count`, and there is no `includeRecordings` selector — stickiness drilldown is membership-based (active on exactly N intervals) and does not surface a matched-recordings column.\n\nGuidance:\n\n- Keep the `source` stickiness query identical to the one whose bar the user is asking about — the series, interval granularity, date range, and filters all determine who falls in each bar.\n- `day` selects a single bar (a specific active-interval count), not a date. To list the users at a different bar, change `day`.\n- For large result sets, tighten the source (date range, filters) rather than expecting more than 100 rows.",+ "description": "List the persons behind one bar of a stickiness insight — the users who were active in a given number of intervals.\n\nPair this with `query-stickiness`: first run the stickiness query to read the distribution (the X-axis is the number of active intervals, the Y-axis is the number of users), then call this tool with the **same** stickiness query as `source` and `day` set to the bar you want to drill into.\n\nSelectors:\n\n- `day` **(required)**: the number of active intervals to drill into — the X-axis value of the bar. Despite the name, this is an interval **count**, not a date. For a daily insight, `day: 13` lists the users who were active on exactly 13 days within the source's date range; for a weekly insight it is a count of weeks, and so on.\n- `series`: 0-based index of the series to drill into when the stickiness query has multiple series. Defaults to 0.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `email`, and `name`. There is no `event_count`, and there is no `includeRecordings` selector — stickiness drilldown is membership-based (active on exactly N intervals) and does not surface a matched-recordings column.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people in the bar — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Keep the `source` stickiness query identical to the one whose bar the user is asking about — the series, interval granularity, date range, and filters all determine who falls in each bar.\n- `day` selects a single bar (a specific active-interval count), not a date. To list the users at a different bar, change `day`.\n- To read every person in a bar, page with `offset` rather than raising `limit` past 1000, and keep `source`, `day`, `series`, `compare`, and `limit` identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the source (date range, filters) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons behind a stickiness bar",@@ -9158,7 +9158,7 @@"system_prompt_hint": "Time series, aggregations, formulas, comparisons"},"query-trends-actors": {- "description": "List the persons behind a specific data point in a trends insight. Use this to answer \"who were the users that did X on day Y?\" or \"which users are in this breakdown bucket?\".\n\nPair this with `query-trends`: first run the trends query to identify the data point of interest, then call this tool with the same trends query as `source` plus selectors that narrow to one cell.\n\nSelectors:\n\n- `day` **(required)**: a single bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must match exactly one data point from the trends result.\n- `series`: 0-based index of the series to drill into when the trends query has multiple series. Defaults to 0.\n- `breakdown`: always an array, one value per `breakdownFilter.breakdowns` dimension, in the same order. Single dimension: `breakdown: [\"Opera\"]`. Multiple dimensions: `breakdown: [\"Opera\", \"en-US\"]`.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor). When `includeRecordings` is `true` (the default), a `recordings` column is also returned containing PostHog replay URLs that can be opened in a browser to watch the user's session. Results are limited to the top 100 actors ordered by event count.\n\nGuidance:\n\n- Keep the `source` trends query minimal - only include the filters/breakdowns needed to identify the cell.\n- Always pick a specific `day` from the trends result.\n- For large result sets, tighten the trends query (filters, date range) rather than expecting more rows.",+ "description": "List the persons behind a specific data point in a trends insight. Use this to answer \"who were the users that did X on day Y?\" or \"which users are in this breakdown bucket?\".\n\nPair this with `query-trends`: first run the trends query to identify the data point of interest, then call this tool with the same trends query as `source` plus selectors that narrow to one cell.\n\nSelectors:\n\n- `day` **(required)**: a single bucket date as an ISO date string (YYYY-MM-DD), e.g. `\"2024-01-15\"`. Must match exactly one data point from the trends result.\n- `series`: 0-based index of the series to drill into when the trends query has multiple series. Defaults to 0.\n- `breakdown`: always an array, one value per `breakdownFilter.breakdowns` dimension, in the same order. Single dimension: `breakdown: [\"Opera\"]`. Multiple dimensions: `breakdown: [\"Opera\", \"en-US\"]`.\n- `compare`: `current` (default) or `previous` when the source has `compareFilter` enabled.\n- `includeRecordings`: defaults to `true`. Set to `false` to skip fetching matched session recordings (faster if recordings are not needed).\n- `limit`: how many persons to return in one page. Defaults to 100, and anything above 1000 is clamped to 1000.\n- `offset`: how many persons to skip before the returned page. Defaults to 0.\n\nResponse:\n\nEach returned row contains `distinct_id`, `name`, `email`, and `event_count` (number of matching events for that actor), ordered by event count. When `includeRecordings` is `true` (the default), a `recordings` column is also returned containing PostHog replay URLs that can be opened in a browser to watch the user's session.\n\nThe response also reports `limit`, `offset`, and `hasMore`. When `hasMore` is `true` there are more people behind the data point — call again with `offset` raised by `limit` to read the next page, and repeat until `hasMore` is `false`.\n\nGuidance:\n\n- Keep the `source` trends query minimal - only include the filters/breakdowns needed to identify the cell.\n- Always pick a specific `day` from the trends result.\n- To read every person, page with `offset` rather than raising `limit` past 1000, and keep `source` and the other selectors identical across pages so rows don't repeat or go missing.\n- When you only need a sample, one page is enough — tighten the trends query (filters, date range) instead of paging through everyone.","category": "Query wrappers","feature": "insights","summary": "List persons behind a trends data point",diff --git a/services/mcp/src/api/client.ts b/services/mcp/src/api/client.tsindex 6cb7b60db7ef..51e031aafdba 100644--- a/services/mcp/src/api/client.ts+++ b/services/mcp/src/api/client.ts@@ -49,6 +49,27 @@ const SSE_DEFAULT_TIMEOUT_MS = 10 * 60 * 1000// in `ee/api/session_summaries.py`. If you change one, check the other.const SSE_READ_TIMEOUT_MS = 30_000+// Page size for the `query-*-actors` tools. The ceiling bounds how much of a caller's context+// window one page can consume; everything past it is reachable by paging with `offset`.+// Out-of-range values are clamped rather than rejected, because the schema codegen doesn't+// propagate `@minimum`/`@maximum` on integer fields into the generated zod.+const ACTORS_DEFAULT_LIMIT = 100+const ACTORS_MAX_LIMIT = 1000++function clampActorsLimit(value: unknown): number {+ if (typeof value !== 'number' || !Number.isFinite(value)) {+ return ACTORS_DEFAULT_LIMIT+ }+ return Math.min(Math.max(Math.trunc(value), 1), ACTORS_MAX_LIMIT)+}++function clampActorsOffset(value: unknown): number {+ if (typeof value !== 'number' || !Number.isFinite(value)) {+ return 0+ }+ return Math.max(Math.trunc(value), 0)+}+export interface GroupType {group_type: stringgroup_type_index: number@@ -1262,9 +1283,15 @@ export class ApiClient {query: Record<string, unknown>results: { columns: string[]; results: any[][] }hasMore: boolean+ limit: numberoffset: number}> => {- const normalized = normalizeQuery(query)+ // `limit`/`offset` are page controls on the outer ActorsQuery. The inner+ // InsightActorsQuery rejects unknown keys, so they have to come off the source+ // before it gets wrapped.+ const { limit: requestedLimit, offset: requestedOffset, ...normalized } = normalizeQuery(query)+ const limit = clampActorsLimit(requestedLimit)+ const offset = clampActorsOffset(requestedOffset)const includeRecordings = Boolean(normalized.includeRecordings)const finalSelect = includeRecordings ? [...select, 'matched_recordings'] : [...select]@@ -1272,13 +1299,20 @@ export class ApiClient {kind: 'ActorsQuery',source: normalized,select: finalSelect,- orderBy: [...orderBy],- limit: 100,+ // An explicit empty `orderBy` suppresses ActorsQueryRunner's default ordering and+ // reaches ClickHouse with no ORDER BY, so row order is undefined and consecutive+ // pages can repeat or skip actors. Omitting the key instead lets the runner order by+ // the actor id column it selected. The per-tool orders already end in a unique+ // tiebreak.+ ...(orderBy.length > 0 ? { orderBy: [...orderBy] } : {}),+ limit,+ offset,}const response = await this.request<{results: any[][]hasMore?: boolean+ limit?: numberoffset?: number}>({method: 'POST',@@ -1326,7 +1360,8 @@ export class ApiClient {query: wrappedQuery,results: { columns, results },hasMore: response.hasMore ?? false,- offset: response.offset ?? 0,+ limit: response.limit ?? limit,+ offset: response.offset ?? offset,}}@@ -1398,7 +1433,8 @@ export class ApiClient {// Funnel actors project `actor` (+ `matched_recordings` when `includeRecordings`, handled// by runActorsQuery). The query carries the step/trends-dropoff selectors on the inner- // FunnelsActorsQuery; ordering is backend-determined, so orderBy stays empty.+ // FunnelsActorsQuery; there is no meaningful ranking, so the backend's own actor-id+ // ordering applies.funnelActors: async ({ query }: { query: Record<string, unknown> }) => runActorsQuery(query, ['actor']),}}diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex d9f1e3bff36d..5b080af57074 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -1225,6 +1225,16 @@ const AssistantTrendsActorsQuery = z.object({.default(true).optional(),kind: z.literal('InsightActorsQuery').default('InsightActorsQuery'),+ limit: integer+ .describe('Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.')+ .default(100)+ .optional(),+ offset: integer+ .describe(+ 'Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.'+ )+ .default(0)+ .optional(),series: integer.describe('Series index (0-based) when the source has multiple series.').optional(),source: AssistantTrendsQuery.describe('The source insight query whose data point we are drilling into.'),})@@ -1236,6 +1246,16 @@ const AssistantLifecycleActorsQuery = z.object({.string().describe("Bucket date for the data point. Must be an ISO date string (YYYY-MM-DD), e.g. '2024-01-15'."),kind: z.literal('InsightActorsQuery').default('InsightActorsQuery'),+ limit: integer+ .describe('Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.')+ .default(100)+ .optional(),+ offset: integer+ .describe(+ 'Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.'+ )+ .default(0)+ .optional(),source: AssistantLifecycleQuery.describe('The source lifecycle insight query whose bucket we are drilling into.'),status: AssistantLifecycleStatus.describe("Lifecycle status to drill into for the given day. Must be one of the bucket names visible in the source's `lifecycleFilter.toggledLifecycles` (defaults to all four when omitted)."@@ -1249,6 +1269,16 @@ const AssistantPathsActorsQuery = z.object({.default(true).optional(),kind: z.literal('InsightActorsQuery').default('InsightActorsQuery'),+ limit: integer+ .describe('Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.')+ .default(100)+ .optional(),+ offset: integer+ .describe(+ 'Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.'+ )+ .default(0)+ .optional(),source: AssistantPathsQuery.describe('The source paths insight query whose actors we are listing.'),})@@ -1259,6 +1289,16 @@ const AssistantRetentionActorsQuery = z.object({).optional(),kind: z.literal('InsightActorsQuery').default('InsightActorsQuery'),+ limit: integer+ .describe('Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.')+ .default(100)+ .optional(),+ offset: integer+ .describe(+ 'Number of persons to skip before the returned page. Use it with `limit` to walk the whole cohort: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.'+ )+ .default(0)+ .optional(),source: AssistantRetentionQuery.describe('The source retention insight query whose cohort we are drilling into.'),})@@ -1271,6 +1311,16 @@ const AssistantStickinessActorsQuery = z.object({"The number of active intervals to drill into — the X-axis value of the stickiness bar. Despite the name, this is an interval **count**, not a date: for a daily insight, `day: 13` lists the users who were active on exactly 13 days within the source's date range."),kind: z.literal('InsightActorsQuery').default('InsightActorsQuery'),+ limit: integer+ .describe('Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.')+ .default(100)+ .optional(),+ offset: integer+ .describe(+ 'Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.'+ )+ .default(0)+ .optional(),series: integer.describe('0-based index of the series to drill into when the source has multiple series. Defaults to 0.').optional(),@@ -1307,6 +1357,16 @@ const AssistantFunnelsActorsQuery = z.object({.default(true).optional(),kind: z.literal('FunnelsActorsQuery').default('FunnelsActorsQuery'),+ limit: integer+ .describe('Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.')+ .default(100)+ .optional(),+ offset: integer+ .describe(+ 'Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.'+ )+ .default(0)+ .optional(),source: AssistantFunnelsQuery.describe('The source funnel insight query whose step (or trends point) we are drilling into.'),diff --git a/services/mcp/tests/tools/query-wrappers.integration.test.ts b/services/mcp/tests/tools/query-wrappers.integration.test.tsindex 0abd455595a4..00ec8c2d0c03 100644--- a/services/mcp/tests/tools/query-wrappers.integration.test.ts+++ b/services/mcp/tests/tools/query-wrappers.integration.test.ts@@ -430,7 +430,7 @@ describe('Query Wrapper Integration Tests', { concurrent: false }, () => {expect(result.results.columns).toEqual(['distinct_id', 'email', 'name'])})- it('wraps the source query in an outer ActorsQuery with select=["actor"] and no orderBy', async () => {+ it('wraps the source query in an outer ActorsQuery with select=["actor"] and no explicit orderBy', async () => {const tool = getToolByName(GENERATED_TOOLS, 'query-lifecycle-actors')const result = (await tool.handler(context, {source: lifecycleSource,@@ -440,7 +440,7 @@ describe('Query Wrapper Integration Tests', { concurrent: false }, () => {expect(result.query.kind).toBe('ActorsQuery')expect(result.query.select).toEqual(['actor'])- expect(result.query.orderBy).toEqual([])+ expect(result.query).not.toHaveProperty('orderBy')expect(result.query.source.kind).toBe('InsightActorsQuery')expect(result.query.source.source.kind).toBe('LifecycleQuery')expect(result.query.source.status).toBe('returning')@@ -629,7 +629,7 @@ describe('Query Wrapper Integration Tests', { concurrent: false }, () => {expect(result.query.kind).toBe('ActorsQuery')expect(result.query.select).toEqual(['actor'])- expect(result.query.orderBy).toEqual([])+ expect(result.query).not.toHaveProperty('orderBy')expect(result.query.source.kind).toBe('InsightActorsQuery')expect(result.query.source.day).toBe(2)expect(result.query.source.series).toBe(0)@@ -674,7 +674,7 @@ describe('Query Wrapper Integration Tests', { concurrent: false }, () => {const result = (await tool.handler(context, { source: funnelSource, funnelStep: 2 })) as anyexpect(result.query.kind).toBe('ActorsQuery')- expect(result.query.orderBy).toEqual([])+ expect(result.query).not.toHaveProperty('orderBy')expect(result.query.source.kind).toBe('FunnelsActorsQuery')expect(result.query.source.funnelStep).toBe(2)expect(result.query.source.source.kind).toBe('FunnelsQuery')diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.jsonindex e8d472bf0aea..a078152a128f 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.json@@ -32,6 +32,20 @@"default": "FunnelsActorsQuery","type": "string"},+ "limit": {+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "offset": {+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"output_format": {"default": "optimized","description": "Output format. \"optimized\" returns a human-readable summary from server-side formatters (recommended for analysis). \"json\" returns the raw query results as JSON.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.jsonindex 34fdd385bfaa..a1484af007f7 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.json@@ -10,6 +10,20 @@"default": "InsightActorsQuery","type": "string"},+ "limit": {+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "offset": {+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"output_format": {"default": "optimized","description": "Output format. \"optimized\" returns a human-readable summary from server-side formatters (recommended for analysis). \"json\" returns the raw query results as JSON.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-paths-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-paths-actors.jsonindex f214463cd686..b8e71b2d6d66 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-paths-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-paths-actors.json@@ -11,6 +11,20 @@"default": "InsightActorsQuery","type": "string"},+ "limit": {+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "offset": {+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"output_format": {"default": "optimized","description": "Output format. \"optimized\" returns a human-readable summary from server-side formatters (recommended for analysis). \"json\" returns the raw query results as JSON.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.jsonindex 264705d05423..2e27b5a2aad5 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json@@ -12,6 +12,20 @@"default": "InsightActorsQuery","type": "string"},+ "limit": {+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "offset": {+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole cohort: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"output_format": {"default": "optimized","description": "Output format. \"optimized\" returns a human-readable summary from server-side formatters (recommended for analysis). \"json\" returns the raw query results as JSON.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.jsonindex f7d9034a22e2..c1ee2b2cb027 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json@@ -17,6 +17,20 @@"default": "InsightActorsQuery","type": "string"},+ "limit": {+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "offset": {+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"output_format": {"default": "optimized","description": "Output format. \"optimized\" returns a human-readable summary from server-side formatters (recommended for analysis). \"json\" returns the raw query results as JSON.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.jsonindex 86e41cd77a41..94953981c3c8 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json@@ -27,6 +27,20 @@"default": "InsightActorsQuery","type": "string"},+ "limit": {+ "default": 100,+ "description": "Maximum number of persons to return in one page, from 1 to 1000. Higher values are clamped.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "offset": {+ "default": 0,+ "description": "Number of persons to skip before the returned page. Use it with `limit` to walk the whole result set: the response reports `limit`, `offset`, and `hasMore`, so when `hasMore` is true, call again with `offset` raised by `limit`.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"output_format": {"default": "optimized","description": "Output format. \"optimized\" returns a human-readable summary from server-side formatters (recommended for analysis). \"json\" returns the raw query results as JSON.",diff --git a/services/mcp/tests/unit/api-client.test.ts b/services/mcp/tests/unit/api-client.test.tsindex 0ca477c94f79..d973b9be6d8f 100644--- a/services/mcp/tests/unit/api-client.test.ts+++ b/services/mcp/tests/unit/api-client.test.ts@@ -324,4 +324,71 @@ describe('ApiClient', () => {vi.unstubAllGlobals()})})++ describe('actors query paging', () => {+ const retentionDrilldown = {+ kind: 'InsightActorsQuery',+ interval: 0,+ source: { kind: 'RetentionQuery', retentionFilter: { period: 'Day', totalIntervals: 3 } },+ }++ function runActors(+ method: 'retentionActors' | 'lifecycleActors',+ query: Record<string, unknown>+ ): Promise<Record<string, any>> {+ const mockFetch = vi.fn().mockResolvedValue(new Response(JSON.stringify({ results: [] }), { status: 200 }))+ vi.stubGlobal('fetch', mockFetch)+ const client = new ApiClient({ apiToken: 'test-token', baseUrl: 'https://example.com' })+ return client+ .query({ projectId: '1' })+ [method]({ query })+ .then(() => {+ const [, options] = mockFetch.mock.calls[0]!+ vi.unstubAllGlobals()+ return JSON.parse(options.body).query+ })+ }++ function runWithPage(page: Record<string, number>): Promise<Record<string, any>> {+ return runActors('retentionActors', { ...retentionDrilldown, ...page })+ }++ it('pages on the outer ActorsQuery and keeps the drilldown source clean', async () => {+ // The inner InsightActorsQuery rejects unknown keys, so leaking `limit`/`offset` into it+ // turns every paged call into a 400.+ const query = await runWithPage({ limit: 250, offset: 500 })++ expect(query.kind).toBe('ActorsQuery')+ expect(query.limit).toBe(250)+ expect(query.offset).toBe(500)+ expect(query.source).not.toHaveProperty('limit')+ expect(query.source).not.toHaveProperty('offset')+ expect(query.source.interval).toBe(0)+ })++ it.each([+ ['defaults to the first page', {}, 100, 0],+ ['clamps a limit above the maximum', { limit: 5000 }, 1000, 0],+ ['raises a limit below one', { limit: 0 }, 1, 0],+ ['floors a negative offset', { limit: 20, offset: -10 }, 20, 0],+ ])('%s', async (_name, page, expectedLimit, expectedOffset) => {+ const query = await runWithPage(page)++ expect(query.limit).toBe(expectedLimit)+ expect(query.offset).toBe(expectedOffset)+ })++ it('omits orderBy on unranked actor lists so pages stay disjoint', async () => {+ // Lifecycle has nothing to rank by. Sending `orderBy: []` suppresses the runner's+ // default ordering, and unordered rows make consecutive pages overlap.+ const query = await runActors('lifecycleActors', {+ kind: 'InsightActorsQuery',+ day: '2024-01-15',+ status: 'returning',+ source: { kind: 'LifecycleQuery', series: [{ kind: 'EventsNode', event: '$pageview' }] },+ })++ expect(query).not.toHaveProperty('orderBy')+ })+ })})