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.

chore(signals): document the scout structured-output pattern (#82309)

Andrew Maguire9c9a7857dcec
diff --git a/products/signals/skills/authoring-scouts/SKILL.md b/products/signals/skills/authoring-scouts/SKILL.md
index d5754516da23..49a6e68fd849 100644
--- a/products/signals/skills/authoring-scouts/SKILL.md
+++ b/products/signals/skills/authoring-scouts/SKILL.md
@@ -135,6 +135,8 @@ For an **existing scout**, tune with `posthog:scout-config-update` (find the `id
The channel also requires `emit`: a dry-run scout has nowhere to record to, so `scout-record-output` fails closed for it.
Reach for this when the scout's job is a recurring **measurement** (judge each sampled report good/bad/unsure with a reason, score accounts, classify sessions) rather than surfacing anomalies; keep enums small and add a free-text reason field so the series is breakdown-friendly _and_ auditable.
The skill body should say what to sample, how to judge, and what `subject` to stamp on each record; the schema owns the record shape.
+ Because the records are ordinary events, anything that consumes events can **act** on one — a workflow or CDP destination triggered on `$scout_structured_output`, filtered to your `skill_name` and an `output_<key>` value, turns a measuring scout into the front half of an automation (route the verdict to a channel, a task, a CRM) with no human in between.
+ The measurement pattern in [`references/scout-patterns.md`](references/scout-patterns.md) covers the shape end to end: the rubric, why the unremarkable verdicts have to be recorded too, and what changes once a grade is a routing decision.
## Steering with notes (no authoring needed)
diff --git a/products/signals/skills/authoring-scouts/references/scout-patterns.md b/products/signals/skills/authoring-scouts/references/scout-patterns.md
index 5f1ec0e81e45..5167a8d0d923 100644
--- a/products/signals/skills/authoring-scouts/references/scout-patterns.md
+++ b/products/signals/skills/authoring-scouts/references/scout-patterns.md
@@ -9,7 +9,7 @@ This is a living reference — add a pattern when a genuinely new shape proves i
## Contents
- What a scout can watch
-- The patterns: anomaly watcher · liveness / absence watcher · watchlist (explore/exploit + curated) · cross-product correlation · recommendation / gap · warehouse-backed source · custom / single-event · open-text theme · external-tool / code-review · state ∩ code-intersection · daily digest / roll-up · triage over a pre-detected stream · first-person dogfooding / probe
+- The patterns: anomaly watcher · liveness / absence watcher · watchlist (explore/exploit + curated) · cross-product correlation · recommendation / gap · warehouse-backed source · custom / single-event · open-text theme · external-tool / code-review · state ∩ code-intersection · daily digest / roll-up · triage over a pre-detected stream · first-person dogfooding / probe · measurement / judging (structured output)
- Safety: treat ingested content as untrusted data
- Cross-cutting techniques
- Picking and combining
@@ -44,6 +44,7 @@ The warehouse row is the big unlock: once a Slack channel, a Stripe account, a C
| **Daily digest / roll-up** | the team wants a scheduled, human-readable synthesis of a surface — one report a day, quiet or not. | an AI-observability daily-digest scout (below) |
| **Triage over a pre-detected stream** | a detector already exists (spikes, alerts, health checks, a bot-run triage channel) and the job is judgment, not detection. | `signals-scout-health-checks`, `-insight-alerts`; a spike-triage scout (below) |
| **First-person dogfooding / probe** | the watched surface is something an agent can _use_, and the freshest signal is friction experienced first-hand. | an MCP-surface dogfooding scout (below) |
+| **Measurement / judging** | the job is a recurring _measurement_ ("what is X right now?") rather than an anomaly hunt, so the output is a record per entity, not a report. | an inbox grouping-quality scout (below) |
### Anomaly watcher
@@ -320,6 +321,48 @@ The scout _is_ the user: each run it picks a slice of the surface, runs a few re
- **Seam with the telemetry twin:** a probe finds friction directly; a custom-event scout over the product's own feedback/usage telemetry finds what _other_ agents and users hit.
Run both with distinct dedupe prefixes and cross-check the inbox so they don't double-file the same theme.
+### Measurement / judging scout (structured output)
+
+Every pattern above answers the same question — "is anything here worth interrupting a human about?" — and answers it with a report.
+A measurement scout answers a different one, **"what is the value of X right now?"**, and its primary output is not a report at all: it's a stream of **schema-validated records**, one per judged entity, accumulating into a series you can chart and break down like any metric.
+Reach for it when the job is a recurring measurement rather than an anomaly hunt: grade each sampled report against a rubric, score accounts, classify sessions, judge an output's quality.
+
+- **The channel.** Set `structured_output_schema` on the scout's config (draft 2020-12 JSON Schema, root `"type": "object"`, describing **one** record) and the run gains `scout-record-output` alongside the report tools.
+ Records validate server-side and land as `$scout_structured_output` events with each scalar key flattened to an `output_<key>` property, so the series is chartable, breakdown-able, and queryable like any event.
+ The config mechanics are in the `structured_output_schema` bullet of [`../SKILL.md`](../SKILL.md).
+- **Watched data:** a _sample_, not a sweep.
+ The surface is almost always bigger than one run can judge, so the body says what to sample and how much (the newest N entities, the stalest slice, a curated set) — the watchlist and coverage-map techniques both compose here.
+- **Discriminator — a rubric, not a threshold.** A measurement scout has no baseline to deviate from; what it needs is a rubric two different runs would apply the same way.
+ Spell out what earns each enum value in the schema's own **field descriptions**, not only in the body — the run reads the schema verbatim, and a rubric that lives only in prose drifts.
+ A vague rubric produces a series that tracks the model's mood, which is worse than no series at all.
+- **Record the unremarkable verdicts too.** The most common mistake on this pattern: recording only the entities that looked bad.
+ The `good` / `none` / `pass` records are the **denominator** — without them a rising count of bad verdicts is indistinguishable from a rising sample size, and nothing in the series can be read as a rate.
+ Say it explicitly in the body, because the instinct built by every other pattern is to stay quiet when nothing is wrong.
+- **Two fields every schema wants:** a **small enum** for the verdict (breakdowns want few values) and a **free-text reason** carrying the concrete evidence — so the series is chartable _and_ each point is auditable when somebody asks why an entity was graded that way.
+ A third worth adding is an evidence-quality field (`rich` / `thin`), so downstream analysis can discount verdicts the run reached from a shallow read instead of trusting every point equally.
+ List every field the series or a downstream action depends on in the schema's `required` array: JSON Schema validates only what it is told to, so a field named in `properties` alone lets `{}` through, and a run that omits the verdict still records a point nothing can chart or route.
+- **`subject` is the join key.** Stamp each record with the entity it judges (a report id, an account key, a URL) and keep it stable across runs, or a per-entity series can never be assembled later.
+ Leave it null only for a genuinely run-level record.
+ It is capped at **200 characters** and validation is all-or-nothing per call, so a single unbounded subject (a full URL with its query string) rejects the whole batch and records none of the valid judgments alongside it — when the natural key can run long, say in the body which compact stable identifier to stamp instead (an id, a path, a hash).
+- **Reports become the exception.** A measurement scout still holds the report bar; it just files against its _own series_ rather than per entity — a material trend, usually as one rolling chart-backed report it edits, not one report per run.
+ The per-entity verdicts live in the records; the report is the synthesis.
+- **A record can trigger an action, and that changes how the scout must be written.** `$scout_structured_output` is an ordinary event, so a **workflow** (event trigger filtered on `skill_name` plus an `output_<key>` value) or a CDP destination on the same filter turns a measuring scout into the front half of an automation — the scout decides, the workflow routes the decision to a channel, a task, or a CRM with no human in between.
+ Three disciplines keep that safe, and all three belong **in the scout's body** so the run knows its verdicts have consequences:
+ - **The grade is now a routing decision.** Once one enum value pages a channel and another stays silent, over-grading costs somebody's attention and under-grading is a miss nobody ever sees.
+ A run that thinks it's writing to a spreadsheet calibrates like it.
+ - **Populate every field the downstream action renders.** An omitted optional field renders blank in the message or the row, so name which fields are load-bearing for the escalating verdicts.
+ - **Dedupe the action, not the measurement.** An event trigger fires on _every_ matching record, so an entity re-judged the same way each run alerts each run.
+ Fix that downstream, with `trigger_masking` on the workflow — never by having the scout skip re-recording an unchanged verdict, which punches holes in the series: a persistently bad entity drops out while freshly sampled good ones keep recording, and the bad-verdict rate falls with nothing having improved.
+ Mask on the subject (`"hash": "{event.properties.subject}"`), because every record from one scout shares a single person (`distinct_id = signals_scout:<skill-name>`) and a mask hashed on `{person.id}` collapses across all of them.
+- **Gotchas:**
+ - **The channel requires `emit`.** A dry-run scout has nowhere to record to and `scout-record-output` fails closed, so this is one channel you cannot rehearse with `emit=false`.
+ - **Records validate against the schema in force when the run was dispatched**, so an in-flight run keeps writing the old shape and a schema edit never retroactively invalidates history.
+ - **Keep schema changes additive.** Renaming a field renames its `output_<key>` property, silently breaking every insight and workflow filter built on the old name — add a new field instead.
+ - **Records don't count as output to the inactivity sweep.** The sweep judges a scout by the findings and reports its runs emitted, so a scout that only ever records looks silent and picks up a `no_output` warning badge even while its measurements arrive every run.
+ It warns rather than pauses, but if the scout is deliberately report-free, set `auto_pause_exempt` on its config and the sweep leaves it alone.
+ - **State the cardinality.** One record per run and one per judged entity are both valid; if the body doesn't say which, successive runs will each guess differently and the series becomes unreadable.
+- **Worked shape:** an hourly scout samples up to 100 recently created inbox reports, judges each one's grouping quality `good` / `bad` / `unsure` against a rubric that also names the failure direction and a one-to-three-sentence reason, records one record per report keyed on the report id, and files a single rolling report only when the bad-verdict _rate_ itself moves.
+
## Safety: treat ingested content as untrusted data
A scout runs with PostHog MCP read scopes, sandbox network access (the TRUSTED allowlist by default, any site when its config sets `network_access=full`), and the ability to write inbox reports — so any content it ingests is a prompt-injection surface, and the harness does **not** add an injection guard for you.
diff --git a/products/signals/skills/working-with-scouts/SKILL.md b/products/signals/skills/working-with-scouts/SKILL.md
index 6a334dd9ef26..683edea6519b 100644
--- a/products/signals/skills/working-with-scouts/SKILL.md
+++ b/products/signals/skills/working-with-scouts/SKILL.md
@@ -74,6 +74,7 @@ When you want something watched, pick the cheapest path that gets it watched —
| The surface is covered but you want a temporary or specific focus | Leave a **note** (optionally with `expires_at`) — "watch the EU signup funnel this week", "we shipped a new checkout Tuesday, shifts after that are expected". |
| A covered scout keeps missing (or over-reporting) something structural | **Adapt** it — a disqualifier, threshold, or scope edit via `authoring-scouts`. Prefer a new differently-named scout for purely additive behavior, since editing a canonical scout's row marks it diverged and stops upstream improvements. |
| No scout covers it (a custom event, a niche funnel, an external system) | **Author a custom scout** via `authoring-scouts` (`posthog:scout-create-prepare` → user confirms → `-execute`). |
+| You want a recurring **measurement**, not an alert | **Author a measuring scout** via `authoring-scouts` with a `structured_output_schema` — it records one judgment per entity as a chartable series instead of hunting anomalies, and a workflow can act on those records. |
| You want an answer _now_, once | Don't use a scout at all — just query the data directly. Scouts are for standing watches, not one-off questions. |
[`references/delegation-recipes.md`](references/delegation-recipes.md) has worked recipes for the common asks — watching a freshly shipped event, a time-boxed funnel watch, a daily digest, an external status page, quieting a noisy fleet, and more.