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): name the misnamed key when a required id is missing (#93837)

posthog[bot]59265c2ac710
diff --git a/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts b/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts
index 1bf181f1e0e3..edd164e9a35f 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerScout.test.ts
@@ -57,6 +57,10 @@ describe('scannerScout', () => {
for (const template of templates) {
expect(template.body).toContain(scannerId)
expect(template.cron).toMatch(/^\d+ \d+ \* \* \*$/)
+ // vision-scanners-get takes `id`; only the sibling vision-scanners-observations-* tools
+ // take `scanner_id`. Pairing the get call with scanner_id fails validation on the first
+ // move of every scheduled run.
+ expect(template.body).toContain(`\`vision-scanners-get\` with id \`${scannerId}\``)
}
for (const template of templates) {
expect(template.defaultName.trim()).not.toBe('')
diff --git a/products/replay_vision/frontend/replay_scanners/scannerScout.ts b/products/replay_vision/frontend/replay_scanners/scannerScout.ts
index bc407bdd1240..d0dc65de8817 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerScout.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerScout.ts
@@ -110,7 +110,7 @@ Every run leaves exactly one report: your digest. That report is what the team r
## First moves
-1. \`vision-scanners-get\` with scanner_id \`${scannerId}\` — the scanner's current name, type, prompt, and enabled state. If it no longer exists, close out with a one-line summary and no report.
+1. \`vision-scanners-get\` with id \`${scannerId}\` — the scanner's current name, type, prompt, and enabled state. If it no longer exists, close out with a one-line summary and no report.
2. \`scout-runs-list\` filtered to your own skill_name — find your previous successful run. Your window is everything since it (fall back to the last 24 hours on the first run or after a gap).
3. \`scout-scratchpad-search\` (text: \`${scannerId}\`) — baselines, known noise, and \`report:\`/\`dedupe:\` pointers from prior runs. Every entry you write is keyed on that id, so it is what finds them again.
4. \`llma-skill-get\` \`exploring-replay-vision-observations\` — the observation data model, what \`confidence\` and each status mean, and how to cite a finding.
diff --git a/products/replay_vision/mcp/tools.yaml b/products/replay_vision/mcp/tools.yaml
index 3a534d1161b8..9c746255b014 100644
--- a/products/replay_vision/mcp/tools.yaml
+++ b/products/replay_vision/mcp/tools.yaml
@@ -126,11 +126,14 @@ tools:
destructive: false
idempotent: true
enrich_url: '{session_id}'
- title: Get a session's replay vision observation
+ title: Get a replay vision observation
description: >
- Get a single replay vision observation by ID, scoped to the scanners the caller can read. Returns the full
- `scanner_snapshot` (the scanner's configuration at run time) and `scanner_result` (the LLM output, with any
- event citations). Use `vision-observations-list` to find observation IDs for a session first.
+ Get a single replay vision observation, scoped to the scanners the caller can read. `id` is the
+ *observation* id, not a session id and not a scanner id. Returns the full `scanner_snapshot` (the scanner's
+ configuration at run time) and `scanner_result` (the LLM output, with any event citations). A
+ `$recording_observed` event row's `uuid` is the observation id, so pass `toString(uuid)` as `id`. If you
+ only have a session id, call `vision-observations-list` with that `session_id` first and take `id` off the
+ row you want.
agent_note: >
`_posthogUrl` opens the recording this observation analysed.
`scanner_result.model_output.reasoning_segments` interleaves prose with `chip` segments, and a chip's
@@ -320,10 +323,11 @@ tools:
idempotent: true
title: Get replay vision scanner
description: >
- Get a single replay vision scanner by ID. Returns the full configuration including `scanner_config` (the
- type-specific prompt and response schema parameters), the `RecordingsQuery` used to select sessions, and
- operational fields like `enabled`, `sampling_rate`, `provider`, `model`, `emits_signals`, `scanner_version`,
- and `last_swept_at`.
+ Get a single replay vision scanner. The scanner id goes in `id` — the `vision-scanners-observations-*` tools
+ take the same value as `scanner_id`, but this one does not accept that name. Get an id from
+ `vision-scanners-list`. Returns the full configuration including `scanner_config` (the type-specific prompt
+ and response schema parameters), the `RecordingsQuery` used to select sessions, and operational fields like
+ `enabled`, `sampling_rate`, `provider`, `model`, `emits_signals`, `scanner_version`, and `last_swept_at`.
vision-scanners-impact-retrieve:
operation: vision_scanners_impact_retrieve
enabled: true
diff --git a/products/replay_vision/skills/exploring-replay-vision-observations/SKILL.md b/products/replay_vision/skills/exploring-replay-vision-observations/SKILL.md
index d42ff1e5ca2f..742ab88a79ad 100644
--- a/products/replay_vision/skills/exploring-replay-vision-observations/SKILL.md
+++ b/products/replay_vision/skills/exploring-replay-vision-observations/SKILL.md
@@ -63,9 +63,12 @@ Pick the axis that matches the question:
- **Has something already summarized this?** → if the scanner has scout digests attached, read their inbox
reports instead of re-deriving the pattern (`inbox-reports-list`, filtered to the scout named after the
scanner).
-- **The full detail of one finding** → `vision-scanners-observations-get` or `vision-observations-retrieve` —
- returns the frozen `scanner_snapshot` (config at run time) and the complete `scanner_result`, including any
- event citations that link the finding back to specific events in the recording.
+- **The full detail of one finding** → `vision-scanners-observations-get` (`scanner_id` + `id`) or
+ `vision-observations-retrieve` (`id`) — returns the frozen `scanner_snapshot` (config at run time) and the
+ complete `scanner_result`, including any event citations that link the finding back to specific events in the
+ recording. Both need the _observation_ id. A `$recording_observed` row's `uuid` is that id, so pass
+ `toString(uuid)`; if all you have is a session id, call `vision-observations-list` (`session_id`) first and
+ take the `id` off the matching row.
Triage `status` so you don't mistake a non-result for "nothing wrong":
diff --git a/products/signals/skills/signals-scout-replay-vision/SKILL.md b/products/signals/skills/signals-scout-replay-vision/SKILL.md
index 55f96c194954..daa52ca5a4ea 100644
--- a/products/signals/skills/signals-scout-replay-vision/SKILL.md
+++ b/products/signals/skills/signals-scout-replay-vision/SKILL.md
@@ -121,7 +121,7 @@ Patterns to watch — starting points, not a checklist. Compare every candidate
A candidate is an **enabled** scanner whose `obs_7d` dropped well below `obs_prior_7d` (say < ~40%) while recordings kept flowing (the session-replay capture query, or just a steady `$pageview`/session count, confirms the denominator held). Then tell apart "stopped running" from "running but failing" (footgun #5):
-- `vision-scanners-get` (`scanner_id`) — read the scanner row directly. `enabled: false` means an operator turned it off — not a gap. `updated_at` near the drop with a bumped `scanner_version` means a config edit (narrowed query, lowered sampling) — deliberate; cite it as context and stop. `last_swept_at` going stale while `enabled` is true is the schedule itself stalling. (Scanner edits aren't in the activity log, so this row is the **only** place to date them — don't reach for `advanced-activity-logs-list`.)
+- `vision-scanners-get` (`id`, **not** `scanner_id`) — read the scanner row directly. `enabled: false` means an operator turned it off — not a gap. `updated_at` near the drop with a bumped `scanner_version` means a config edit (narrowed query, lowered sampling) — deliberate; cite it as context and stop. `last_swept_at` going stale while `enabled` is true is the schedule itself stalling. (Scanner edits aren't in the activity log, so this row is the **only** place to date them — don't reach for `advanced-activity-logs-list`.)
- `vision-scanners-observations-list` (`scanner_id`, `status: "failed"` then `status: "ineligible"`) — a wall of failures is a broken scanner (model/provider error); a wall of `ineligible` (`too_short`, `no_recording`) is usually a query that now matches sessions it can't observe. Read `error_reason`.
- `vision-quota-retrieve` — the budget is org-wide credits (1 credit = $0.01, priced per model) for the current billing period. `exhausted: true` means every scheduled observation is being skipped org-wide until the period resets; that silences _all_ scanners at once.
@@ -233,9 +233,11 @@ 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-get` (`scanner_id`) — 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-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.
+ A `$recording_observed` event row's `uuid` is the observation id, so on the primary `execute-sql` route select `toString(uuid)` and pass it straight to `vision-observations-retrieve` (`id`).
+ Fall back to this list when you have only a session id, or to pick one scanner's observation out of a session several scanners observed.
- `vision-quota-retrieve` — the org's credit budget for the billing period: `remaining` / `exhausted`.
- `query-session-recordings-list` / `session-recording-get` — resolve `session_id`s to watchable recordings for a finding's example links.
- `read-data-schema` — confirm `$recording_observed` and its `scanner_output_*` properties exist before aggregating.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index d9e44347c183..6cdcb1e203a8 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -11431,11 +11431,11 @@
}
},
"vision-observations-retrieve": {
- "description": "Get a single replay vision observation by ID, scoped to the scanners the caller can read. Returns the full `scanner_snapshot` (the scanner's configuration at run time) and `scanner_result` (the LLM output, with any event citations). Use `vision-observations-list` to find observation IDs for a session first.",
+ "description": "Get a single replay vision observation, scoped to the scanners the caller can read. `id` is the *observation* id, not a session id and not a scanner id. Returns the full `scanner_snapshot` (the scanner's configuration at run time) and `scanner_result` (the LLM output, with any event citations). A `$recording_observed` event row's `uuid` is the observation id, so pass `toString(uuid)` as `id`. If you only have a session id, call `vision-observations-list` with that `session_id` first and take `id` off the row you want.",
"category": "Replay vision",
"feature": "replay_vision",
- "summary": "Get a session's replay vision observation",
- "title": "Get a session's replay vision observation",
+ "summary": "Get a replay vision observation",
+ "title": "Get a replay vision observation",
"required_scopes": ["replay_scanner:read", "session_recording:read"],
"annotations": {
"destructiveHint": false,
@@ -11531,7 +11531,7 @@
}
},
"vision-scanners-get": {
- "description": "Get a single replay vision scanner by ID. Returns the full configuration including `scanner_config` (the type-specific prompt and response schema parameters), the `RecordingsQuery` used to select sessions, and operational fields like `enabled`, `sampling_rate`, `provider`, `model`, `emits_signals`, `scanner_version`, and `last_swept_at`.",
+ "description": "Get a single replay vision scanner. The scanner id goes in `id` — the `vision-scanners-observations-*` tools take the same value as `scanner_id`, but this one does not accept that name. Get an id from `vision-scanners-list`. Returns the full configuration including `scanner_config` (the type-specific prompt and response schema parameters), the `RecordingsQuery` used to select sessions, and operational fields like `enabled`, `sampling_rate`, `provider`, `model`, `emits_signals`, `scanner_version`, and `last_swept_at`.",
"category": "Replay vision",
"feature": "replay_vision",
"summary": "Get replay vision scanner",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 98134c9c372f..540658073c2b 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -12059,11 +12059,11 @@
}
},
"vision-observations-retrieve": {
- "description": "Get a single replay vision observation by ID, scoped to the scanners the caller can read. Returns the full `scanner_snapshot` (the scanner's configuration at run time) and `scanner_result` (the LLM output, with any event citations). Use `vision-observations-list` to find observation IDs for a session first.",
+ "description": "Get a single replay vision observation, scoped to the scanners the caller can read. `id` is the *observation* id, not a session id and not a scanner id. Returns the full `scanner_snapshot` (the scanner's configuration at run time) and `scanner_result` (the LLM output, with any event citations). A `$recording_observed` event row's `uuid` is the observation id, so pass `toString(uuid)` as `id`. If you only have a session id, call `vision-observations-list` with that `session_id` first and take `id` off the row you want.",
"category": "Replay vision",
"feature": "replay_vision",
- "summary": "Get a session's replay vision observation",
- "title": "Get a session's replay vision observation",
+ "summary": "Get a replay vision observation",
+ "title": "Get a replay vision observation",
"required_scopes": ["replay_scanner:read", "session_recording:read"],
"annotations": {
"destructiveHint": false,
@@ -12159,7 +12159,7 @@
}
},
"vision-scanners-get": {
- "description": "Get a single replay vision scanner by ID. Returns the full configuration including `scanner_config` (the type-specific prompt and response schema parameters), the `RecordingsQuery` used to select sessions, and operational fields like `enabled`, `sampling_rate`, `provider`, `model`, `emits_signals`, `scanner_version`, and `last_swept_at`.",
+ "description": "Get a single replay vision scanner. The scanner id goes in `id` — the `vision-scanners-observations-*` tools take the same value as `scanner_id`, but this one does not accept that name. Get an id from `vision-scanners-list`. Returns the full configuration including `scanner_config` (the type-specific prompt and response schema parameters), the `RecordingsQuery` used to select sessions, and operational fields like `enabled`, `sampling_rate`, `provider`, `model`, `emits_signals`, `scanner_version`, and `last_swept_at`.",
"category": "Replay vision",
"feature": "replay_vision",
"summary": "Get replay vision scanner",
diff --git a/services/mcp/src/tools/exec.ts b/services/mcp/src/tools/exec.ts
index c3304a231587..cd39ac2e3e72 100644
--- a/services/mcp/src/tools/exec.ts
+++ b/services/mcp/src/tools/exec.ts
@@ -397,6 +397,35 @@ function looksLikeUnwrappedPayload(
return wrapped.error.issues.every((issue) => issue.path.length > 1 && String(issue.path[0]) === key)
}
+/**
+ * Names the top-level keys a non-strict schema dropped, so a caller told `id` is
+ * missing can see that the key it did send — `scanner_id` — was discarded rather
+ * than read. Without this the caller is told only that a parameter it never used
+ * is missing, has nothing to correct, and retries the same call.
+ *
+ * Reports only that the keys were not accepted. It deliberately does not claim
+ * one of them was meant as the missing parameter: matching `scanner_id` to a
+ * missing `id` by name holds on `vision-scanners-get`, where the value is right
+ * and only the name is wrong, but on a tool keyed by an observation id the same
+ * key carries the wrong value entirely, and advising a rename would send the
+ * caller further off course. Which key to use instead belongs in the tool's
+ * description, where it can say so per tool.
+ *
+ * Returns key names only, never values — the message is returned to the caller
+ * and recorded as the analytics error message.
+ */
+function undeclaredKeys(input: unknown, schema: ZodObjectAny | undefined): string[] {
+ if (!schema || typeof input !== 'object' || input === null || Array.isArray(input)) {
+ return []
+ }
+ const declared = declaredPropertyNames(schema)
+ return Object.keys(input).filter((key) => !declared.has(key))
+}
+
+/** Bound on how many dropped keys the message names, so a caller sending a large
+ * undeclared payload cannot inflate the analytics error message. */
+const MAX_DROPPED_KEYS_NAMED = 5
+
/** Turns a Zod validation failure into a short, field-named message the model
* can act on. Without it, a missing/`undefined` path segment slips through to
* the HTTP layer and the API returns a generic 404 that reads as "entity does
@@ -414,6 +443,9 @@ export function formatInputValidationError(
input?: unknown,
schema?: ZodObjectAny
): string {
+ // A strict schema rejects unknown keys instead of dropping them, and the
+ // `unrecognized_keys` branch below already names them.
+ const keysWereRejected = error.issues.some((issue) => issue.code === 'unrecognized_keys')
const parts = error.issues.map((issue) => {
const path = issue.path.map(String).join('.')
if (issue.code === 'invalid_type') {
@@ -421,6 +453,14 @@ export function formatInputValidationError(
if (looksLikeUnwrappedPayload(issue.path, input, schema)) {
return `missing required parameter: ${path}; the fields you sent belong inside it, so resend them as {"${path}": {...}}`
}
+ const dropped = keysWereRejected ? [] : undeclaredKeys(input, schema)
+ if (dropped.length) {
+ const named = dropped
+ .slice(0, MAX_DROPPED_KEYS_NAMED)
+ .map((key) => `"${key}"`)
+ .join(', ')
+ return `missing required parameter: ${path}; this tool ignored these keys it does not accept: ${named}`
+ }
return `missing required parameter: ${path}`
}
return `parameter "${path}" must be of type ${issue.expected}`
diff --git a/services/mcp/tests/unit/exec.test.ts b/services/mcp/tests/unit/exec.test.ts
index b101f26f68e3..22a0327094d7 100644
--- a/services/mcp/tests/unit/exec.test.ts
+++ b/services/mcp/tests/unit/exec.test.ts
@@ -1637,6 +1637,70 @@ describe('exec tool', () => {
)
})
+ describe('a required parameter missing while undeclared keys were sent', () => {
+ const SOME_UUID = '00000000-0000-4000-8000-000000000000'
+
+ const formatFor = (toolName: string, input: unknown): string => {
+ const tool = GENERATED_TOOL_MAP[toolName]!()
+ const result = tool.schema.safeParse(input, { reportInput: true })
+ expect(result.success).toBe(false)
+ return formatInputValidationError(toolName, result.error!, input, tool.schema)
+ }
+
+ it.each([
+ ['vision-scanners-get', 'scanner_id'],
+ ['vision-observations-retrieve', 'observation_id'],
+ ])('names the key %s dropped, so the caller can see it was not read', (toolName, sentKey) => {
+ expect(formatFor(toolName, { [sentKey]: SOME_UUID })).toBe(
+ `Invalid input for "${toolName}": missing required parameter: id; this tool ignored these keys it does not accept: "${sentKey}"`
+ )
+ })
+
+ it('does not tell the caller to resend a scanner id as an observation id', () => {
+ // `vision-observations-retrieve` does not declare `scanner_id`, and its
+ // `id` has no format constraint. Matching the two by name suffix would
+ // advise reusing a value that identifies a different entity.
+ const message = formatFor('vision-observations-retrieve', { scanner_id: SOME_UUID })
+
+ expect(message).toContain('"scanner_id"')
+ expect(message).not.toContain('resend')
+ expect(message).not.toContain('as "id"')
+ })
+
+ it('does not name a value the caller sent', () => {
+ expect(formatFor('vision-scanners-get', { scanner_id: SOME_UUID })).not.toContain(SOME_UUID)
+ })
+
+ it('stays quiet when every key the caller sent is a real field of the tool', () => {
+ // `vision-scanners-observations-get` declares `scanner_id`, so nothing
+ // was dropped: the caller omitted the observation id rather than
+ // having a key silently discarded.
+ expect(formatFor('vision-scanners-observations-get', { scanner_id: SOME_UUID })).toBe(
+ 'Invalid input for "vision-scanners-observations-get": missing required parameter: id'
+ )
+ })
+
+ it('keeps the bare message for a caller that sent nothing at all', () => {
+ expect(formatFor('vision-scanners-get', {})).toBe(
+ 'Invalid input for "vision-scanners-get": missing required parameter: id'
+ )
+ })
+
+ it('says nothing was ignored when the schema rejected the keys instead', () => {
+ // This tool's schema is strict, so `hash` was refused rather than dropped.
+ expect(formatFor('change-requests-approve-execute', { hash: 'x', confirmation: 'confirm' })).toBe(
+ 'Invalid input for "change-requests-approve-execute": missing required parameter: confirmation_hash; unexpected property: hash'
+ )
+ })
+
+ it('caps how many keys it names so the analytics message stays bounded', () => {
+ const input = Object.fromEntries(Array.from({ length: 30 }, (_, i) => [`junk_${i}`, i]))
+ const message = formatFor('vision-scanners-get', input)
+
+ expect(message.match(/junk_/g)).toHaveLength(5)
+ })
+ })
+
it('fires for the real generated query-logs tool, not just a stand-in schema', () => {
// Guards the assumption behind this whole branch: that the shipped
// tool really does wrap its payload in one required `query` object.