Skip to content

: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.

fix(replay-vision): accept a boolean on the scanner list enabled filter (#96290)

posthog[bot]7dc539d71110
diff --git a/products/replay_vision/backend/api/scanners.py b/products/replay_vision/backend/api/scanners.py
index 81be31c6941c..a70e2088f994 100644
--- a/products/replay_vision/backend/api/scanners.py
+++ b/products/replay_vision/backend/api/scanners.py
@@ -903,7 +903,10 @@ class _ScannerOrderByFilter(OrderByFilter):
class ReplayScannerFilter(django_filters.FilterSet):
enabled = django_filters.CharFilter(
method="_filter_enabled",
- help_text="Filter by enabled state. Accepts a comma-separated list of `enabled`/`disabled`.",
+ help_text=(
+ "Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, "
+ "or the boolean form `true`/`false`. Omit to list every scanner."
+ ),
)
scanner_type = MultiChoiceFilter(
field_name="scanner_type",
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index 8b5c1a95e057..24df05c3aef3 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -540,18 +540,23 @@ class TestReplayScannerViewSet(_VisionAPITestCase):
@parameterized.expand(
[
- ("enabled", "disabled", 1),
- ("enabled", "enabled,disabled", 2),
- ("enabled", "true", 1),
- ("enabled", "false", 1),
- ("enabled", "1", 1),
- ("enabled", "0", 1),
- ("scanner_type", ScannerType.CLASSIFIER, 1),
- ("scanner_type", f"{ScannerType.CLASSIFIER},{ScannerType.MONITOR}", 2),
- ("emits_signals", "true", 1),
+ ("enabled", "enabled", ["enabled-scanner"]),
+ ("enabled", "disabled", ["disabled-scanner"]),
+ ("enabled", "enabled,disabled", ["disabled-scanner", "enabled-scanner"]),
+ ("enabled", "true", ["enabled-scanner"]),
+ ("enabled", "false", ["disabled-scanner"]),
+ ("enabled", "1", ["enabled-scanner"]),
+ ("enabled", "0", ["disabled-scanner"]),
+ ("scanner_type", ScannerType.CLASSIFIER, ["classifier-scanner"]),
+ (
+ "scanner_type",
+ f"{ScannerType.CLASSIFIER},{ScannerType.MONITOR}",
+ ["classifier-scanner", "monitor-scanner"],
+ ),
+ ("emits_signals", "true", ["loud"]),
]
)
- def test_filterset(self, field: str, value: str, expected_count: int) -> None:
+ def test_filterset(self, field: str, value: str, expected_names: list[str]) -> None:
if field == "enabled":
self._create_scanner(name="enabled-scanner")
self._create_scanner(name="disabled-scanner", enabled=False)
@@ -563,7 +568,7 @@ class TestReplayScannerViewSet(_VisionAPITestCase):
self._create_scanner(name="loud", emits_signals=True)
resp = self.client.get(f"{self.scanners_url}?{field}={value}")
self.assertEqual(resp.status_code, 200)
- self.assertEqual(len(resp.json()["results"]), expected_count)
+ self.assertEqual(sorted(r["name"] for r in resp.json()["results"]), expected_names)
@parameterized.expand(
[
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index 5fa67f100996..1346d7da926f 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -2443,7 +2443,7 @@ export type VisionScannersListParams = {
*/
emits_signals?: boolean
/**
- * Filter by enabled state. Accepts a comma-separated list of `enabled`/`disabled`.
+ * Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, or the boolean form `true`/`false`. Omit to list every scanner.
*/
enabled?: string
/**
diff --git a/products/replay_vision/mcp/tools.yaml b/products/replay_vision/mcp/tools.yaml
index 31803dc0e6e8..24498488baf6 100644
--- a/products/replay_vision/mcp/tools.yaml
+++ b/products/replay_vision/mcp/tools.yaml
@@ -396,6 +396,12 @@ tools:
(numeric rubric), or `summarizer` (free-text summary, embedded for downstream search). Each scanner returns
its current configuration, enabled state, sampling settings, `last_swept_at` timestamp, and its credit
figures (`credits_per_observation`, `estimated_monthly_credits`, `credits_this_month`).
+ param_overrides:
+ enabled:
+ description: >
+ Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, or the
+ boolean form `true` / `false`. Omit to list every scanner.
+ cast: boolean-string
vision-scanners-observations-create-task-create:
operation: vision_scanners_observations_create_task_create
enabled: false
diff --git a/products/signals/skills/signals-scout-replay-vision/SKILL.md b/products/signals/skills/signals-scout-replay-vision/SKILL.md
index 4a016ad9230c..c5ba693ac142 100644
--- a/products/signals/skills/signals-scout-replay-vision/SKILL.md
+++ b/products/signals/skills/signals-scout-replay-vision/SKILL.md
@@ -59,7 +59,7 @@ WHERE event = '$recording_observed'
AND timestamp <= now() + INTERVAL 1 DAY
```
-- **Zero in 30d** — _don't_ conclude "not in use" from the event stream alone. Only _succeeded_ observations write `$recording_observed` (footgun #5), so zero events is ambiguous: either no scanners, or enabled scanners whose every observation is failing / ineligible / quota-skipped — exactly the observing-integrity failure you exist to catch. Do one cheap `vision-scanners-list` (`enabled: true`) check:
+- **Zero in 30d** — _don't_ conclude "not in use" from the event stream alone. Only _succeeded_ observations write `$recording_observed` (footgun #5), so zero events is ambiguous: either no scanners, or enabled scanners whose every observation is failing / ineligible / quota-skipped — exactly the observing-integrity failure you exist to catch. Do one cheap `vision-scanners-list` (`enabled: "enabled"`) check:
- **No enabled scanners** (or the tool is unregistered _and_ the profile shows no scanner config) — replay vision genuinely isn't in play. Write `not-in-use:replay_vision:team{team_id}` ("checked at {timestamp}, no observations in 30d, no enabled scanners") and close out empty. (Re-runs idempotently refresh the same key.)
- **Enabled scanners but zero events** — this is a watch gap, not non-adoption. Jump to the watch-gap pattern (check `status: "failed"` / `"ineligible"` and `vision-quota-retrieve`).
- **Observations earlier in the 30d window but zero in 7d** — this is _not_ a close-out; it's the strongest-shaped watch-gap candidate. Investigate it first.
@@ -232,7 +232,7 @@ When in doubt, write a memory entry instead of filing a report.
Direct calls (read-only):
- `execute-sql` against `events` (`event = '$recording_observed'`) — the primary route. Key properties: `scanner_id`, `scanner_name`, `scanner_type`, `scanner_version`, `session_id`, `emits_signals`, `model_used`, `provider_used`, and the flattened `scanner_output_*` fields (`scanner_output_confidence`, `scanner_output_verdict`, `scanner_output_score`, `scanner_output_tags` (JSON array — `JSONExtract` before `arrayJoin`, footgun #3), `scanner_output_tags_freeform`, `scanner_output_title`, `scanner_output_summary`, `scanner_output_reasoning`). Time-filter on `timestamp` with the upper bound (footgun #1); count reach with `uniq(session_id)` (footgun #2); group/filter by `scanner_id` (footgun #4).
-- `vision-scanners-list` — roster + `enabled` / `emits_signals` / `scanner_type` state. Feature-gated; if absent, lean on the roster SQL above.
+- `vision-scanners-list` — roster + `enabled` / `emits_signals` / `scanner_type` state. The `enabled` filter is a string: send `"enabled"` or `"disabled"` (a boolean works too). Feature-gated; if absent, lean on the roster SQL above.
- `vision-scanners-get` (`id`, **not** `scanner_id`, unlike the `vision-scanners-observations-*` tools) — the one scanner's full row: `enabled`, `scanner_version`, `updated_at`, `last_swept_at`. The **only** place to date a config edit (scanner changes aren't in the activity log).
- `vision-scanners-observations-list` (`scanner_id`, `status`, `verdict`, `tags`, `triggered_by`) — the **only** way to see failed/ineligible observations (footgun #5) and read `error_reason`.
- `vision-observations-list` (`session_id`) — every scanner's observation on one session, for example links.
diff --git a/services/mcp/scripts/generate-tools.ts b/services/mcp/scripts/generate-tools.ts
index c554dd223823..48a097e3671f 100644
--- a/services/mcp/scripts/generate-tools.ts
+++ b/services/mcp/scripts/generate-tools.ts
@@ -454,6 +454,12 @@ function operationIdToPascal(operationId: string): string {
// Schema composition — determine Orval imports and build expressions
// ------------------------------------------------------------------
+/** `param_overrides.cast` value → the helper exported from `@/tools/cast-helpers`. */
+const CAST_HELPERS = {
+ 'string-int': 'castStringToInt',
+ 'boolean-string': 'castBooleanToString',
+} as const
+
interface SchemaComposition {
orvalImports: string[]
toolInputsImports: string[]
@@ -715,7 +721,7 @@ function composeToolSchema(
optionalParamNames.add(paramName)
}
- const castHelper = override.cast === 'string-int' ? 'castStringToInt' : null
+ const castHelper = override.cast ? CAST_HELPERS[override.cast] : null
if (castHelper) {
castHelperImports.add(castHelper)
}
diff --git a/services/mcp/scripts/yaml-config-schema.ts b/services/mcp/scripts/yaml-config-schema.ts
index d9332086221e..d153cec64d9d 100644
--- a/services/mcp/scripts/yaml-config-schema.ts
+++ b/services/mcp/scripts/yaml-config-schema.ts
@@ -93,11 +93,13 @@ export const ToolConfigSchema = z
* - `'string-int'` — casts strings that look like a base-10 integer
* (e.g. `"123"`, `"-7"`) to a number. Anything else passes through
* unchanged so zod still rejects with its honest error.
+ * - `'boolean-string'` — casts a boolean to `"true"` / `"false"` for a
+ * string param that reads as a boolean to an agent (e.g. `enabled`).
*
* Mutually exclusive with `input_schema` and `schema_ref` (those
* fully replace the schema; cast composes with the existing one).
*/
- cast: z.enum(['string-int']).optional(),
+ cast: z.enum(['string-int', 'boolean-string']).optional(),
/**
* Alternate key names accepted for this param and normalized to it
* before validation — for identifier params agents guess different
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 026ba1266084..01bf32ccf03f 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -102271,7 +102271,7 @@ export namespace Schemas {
*/
emits_signals?: boolean;
/**
- * Filter by enabled state. Accepts a comma-separated list of `enabled`/`disabled`.
+ * Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, or the boolean form `true`/`false`. Omit to list every scanner.
*/
enabled?: string;
/**
diff --git a/services/mcp/src/generated/replay_vision/api.ts b/services/mcp/src/generated/replay_vision/api.ts
index 78b30ad916a5..99f624c5ecd5 100644
--- a/services/mcp/src/generated/replay_vision/api.ts
+++ b/services/mcp/src/generated/replay_vision/api.ts
@@ -237,7 +237,9 @@ export const VisionScannersListQueryParams = () => zod.object({
enabled: zod
.string()
.optional()
- .describe('Filter by enabled state. Accepts a comma-separated list of `enabled`\/`disabled`.'),
+ .describe(
+ 'Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, or the boolean form `true`\/`false`. Omit to list every scanner.'
+ ),
experiment_id: zod.string().optional().describe('Filter to scanners whose targeting watches the given experiment.'),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
diff --git a/services/mcp/src/tools/cast-helpers.ts b/services/mcp/src/tools/cast-helpers.ts
index 808e2a6580c4..ba733795b678 100644
--- a/services/mcp/src/tools/cast-helpers.ts
+++ b/services/mcp/src/tools/cast-helpers.ts
@@ -30,6 +30,21 @@ export const castStringToInt = (v: unknown): unknown => {
return v
}
+/**
+ * Cast a boolean to its lowercase string form; pass everything else through.
+ *
+ * Some string query params read as booleans to an agent — a filter named
+ * `enabled` is the clearest case — so agents send `true` where the schema
+ * wants a string. The backend filters already accept `true` / `false` as
+ * aliases, so the only thing standing between the call and a result is the
+ * tool boundary. Anything that isn't a boolean passes through unchanged, so
+ * zod still rejects true type mismatches.
+ *
+ * Wired up declaratively via `param_overrides: { enabled: { cast: 'boolean-string' } }`
+ * in product `tools.yaml` files — see services/mcp/scripts/generate-tools.ts.
+ */
+export const castBooleanToString = (v: unknown): unknown => (typeof v === 'boolean' ? String(v) : v)
+
/**
* Normalize alternate key spellings to a canonical param name before validation.
*
diff --git a/services/mcp/src/tools/generated/replay_vision.ts b/services/mcp/src/tools/generated/replay_vision.ts
index 3d162ec65094..f5667cef2a8f 100644
--- a/services/mcp/src/tools/generated/replay_vision.ts
+++ b/services/mcp/src/tools/generated/replay_vision.ts
@@ -4,6 +4,7 @@ import { z } from 'zod'
import type { Schemas } from '@/api/generated'
import * as orvalSchemas from '@/generated/replay_vision/api'
import { withUiApp } from '@/resources/ui-apps'
+import { castBooleanToString } from '@/tools/cast-helpers'
import { withPostHogUrl, withAgentNote, type WithPostHogUrl, type WithAgentNote } from '@/tools/tool-utils'
import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
@@ -439,7 +440,16 @@ const visionScannersInlineScanCreate = (): ToolBase<ReturnType<typeof VisionScan
const VisionScannersListSchema = () => {
const VisionScannersListQueryParams = orvalSchemas.VisionScannersListQueryParams()
- return VisionScannersListQueryParams
+ return VisionScannersListQueryParams.extend({
+ enabled: z
+ .preprocess(
+ castBooleanToString,
+ VisionScannersListQueryParams.shape['enabled'].describe(
+ 'Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, or the boolean form `true` / `false`. Omit to list every scanner.'
+ )
+ )
+ .optional(),
+ })
}
const visionScannersList = (): ToolBase<
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-list.json
index cc841b039d8a..6cebc911c4f5 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-list.json
@@ -10,7 +10,7 @@
"type": "boolean"
},
"enabled": {
- "description": "Filter by enabled state. Accepts a comma-separated list of `enabled`/`disabled`.",
+ "description": "Filter by enabled state. Accepts `enabled`, `disabled`, a comma-separated list of both, or the boolean form `true` / `false`. Omit to list every scanner.",
"type": "string"
},
"experiment_id": {
diff --git a/services/mcp/tests/unit/cast-helpers.test.ts b/services/mcp/tests/unit/cast-helpers.test.ts
index ef908bb894ac..8e2910cd688c 100644
--- a/services/mcp/tests/unit/cast-helpers.test.ts
+++ b/services/mcp/tests/unit/cast-helpers.test.ts
@@ -1,16 +1,16 @@
/**
- * Unit tests for the narrow string→primitive casts used by
+ * Unit tests for the narrow input casts used by
* `param_overrides: { ...: { cast: '...' } }` in tools.yaml.
*
- * The intent is to be permissive about the *one* shape LLM agents
- * commonly mis-emit (stringified integer ids) and strict about
- * everything else, so genuine type mismatches still surface as
- * honest zod rejections instead of silently casting to 0/1.
+ * The intent is to be permissive about the shapes LLM agents commonly
+ * mis-emit (a stringified integer id, a boolean for a string filter)
+ * and strict about everything else, so genuine type mismatches still
+ * surface as honest zod rejections instead of silently casting to 0/1.
*/
import { describe, expect, it } from 'vitest'
import { z } from 'zod'
-import { castStringToInt } from '../../src/tools/cast-helpers'
+import { castBooleanToString, castStringToInt } from '../../src/tools/cast-helpers'
describe('castStringToInt', () => {
const schema = z.preprocess(castStringToInt, z.number().int())
@@ -56,3 +56,26 @@ describe('castStringToInt', () => {
expect(wrapped.parse('1')).toBe(1)
})
})
+
+describe('castBooleanToString', () => {
+ const schema = z.preprocess(castBooleanToString, z.string())
+
+ it.each([
+ [true, 'true'],
+ [false, 'false'],
+ ] as const)('casts the boolean %s to its lowercase string form', (input, expected) => {
+ expect(schema.parse(input)).toBe(expected)
+ })
+
+ it('passes through plain strings untouched', () => {
+ expect(schema.parse('enabled')).toBe('enabled')
+ })
+
+ it.each([
+ ['number', 1],
+ ['null', null],
+ ['empty array', []],
+ ] as const)('rejects non-boolean, non-string input: %s', (_label, input) => {
+ expect(() => schema.parse(input)).toThrow()
+ })
+})
diff --git a/services/mcp/tests/unit/replay-vision-enabled-cast.test.ts b/services/mcp/tests/unit/replay-vision-enabled-cast.test.ts
new file mode 100644
index 000000000000..cb2b60dd0633
--- /dev/null
+++ b/services/mcp/tests/unit/replay-vision-enabled-cast.test.ts
@@ -0,0 +1,33 @@
+/**
+ * Regression test for the boolean→string cast on `vision-scanners-list`.
+ *
+ * A filter named `enabled` reads as a boolean to an agent, so production
+ * traces show `enabled: true` on almost every scout run, which the MCP
+ * layer rejected with `parameter "enabled" must be of type string`. The
+ * backend filter already accepts `true` / `false`, so the fix is the
+ * declarative `param_overrides: { enabled: { cast: 'boolean-string' } }`
+ * in `products/replay_vision/mcp/tools.yaml`.
+ */
+import { describe, expect, it } from 'vitest'
+import type { z } from 'zod'
+
+import { GENERATED_TOOLS } from '@/tools/generated/replay_vision'
+import type { ToolBase, ZodObjectAny } from '@/tools/types'
+
+describe('vision-scanners-list enabled filter', () => {
+ const schema = (GENERATED_TOOLS['vision-scanners-list'] as () => ToolBase<ZodObjectAny>)().schema as z.ZodTypeAny
+ const parse = (input: unknown): Record<string, unknown> => schema.parse(input) as Record<string, unknown>
+
+ it.each([
+ [true, 'true'],
+ [false, 'false'],
+ ] as const)('casts the boolean %s the backend accepts as a string', (input, expected) => {
+ expect(parse({ enabled: input }).enabled).toBe(expected)
+ })
+
+ // z.preprocess() does not carry the inner .optional() into the advertised schema,
+ // so the codegen re-applies it. A filter that became required would break every caller.
+ it('stays optional', () => {
+ expect(parse({}).enabled).toBeUndefined()
+ })
+})