: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(signals): canonical scout self-improvement via agent-feedback (#72189)
Andrew Maguire86ad4e578119
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.mdindex 73e0c2906278..7fdc8eaed842 100644--- a/products/signals/backend/scout_harness/AGENTS.md+++ b/products/signals/backend/scout_harness/AGENTS.md@@ -50,8 +50,15 @@ it is exercised via the `run_signals_scout` management command (see `../managemeat `edit_report`, and a signal-channel custom scout keeps the scratchpad-only path). Apristine canonical scout never seesit — applying such a suggestion would mark the seeded row diverged and cut it off from- upstream sync; canonical-skill defects route upstream via the operational-friction- (`agent-feedback`) section instead. A _report-channel_ custom scout's run identity also+ upstream sync. Canonical scouts get the _canonical-improvement_ section instead+ (`_CANONICAL_IMPROVEMENT`): skill-content gaps observed in the wild route upstream to the+ PostHog team via the `agent-feedback` MCP tool with `feedback_type="scout"` plus structured+ fields (`scout_skill_name`, `scout_skill_version`, `scout_category`) so fleet-wide feedback+ aggregates per skill/version, deduped across runs via `reported:<skill-name>:<topic>`+ scratchpad entries. The section's generalization rules are load-bearing privacy-wise — the+ feedback leaves the customer's project, so it must carry the pattern, never the project's+ data (no PII, values, URLs, numbers, or custom event/property names); tool/harness friction+ still routes via the shared operational-friction section. A _report-channel_ custom scout's run identity alsocarries a **skill authors** line (`LoadedSkill.authors`, rendered by `_skill_authors_line`):creator + recent editors resolved server-side from the skill's version rows, which theescalation guidance points `suggested_reviewers` at (creator first, via `scout-members-list`) —diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.pyindex f24ca82a02b1..e67fabe22206 100644--- a/products/signals/backend/scout_harness/prompt.py+++ b/products/signals/backend/scout_harness/prompt.py@@ -32,9 +32,11 @@ class SignalScoutRunSummary(BaseModel):# in its skill's `allowed_tools`) has already done the research and authors a full `SignalReport`# directly. The bootstrap, scratchpad, recency, business-knowledge, friction, and output sections are# identical for both; only the channel-specific sections differ. `build_run_prompt` composes the right-# set from the constants below. Orthogonal to the channel fork, a *custom* (team-authored) scout on-# either channel additionally gets the self-improvement section (`_self_improvement_section`), which-# on the report channel also invites escalating strong suggestions as inbox reports about the scout.+# set from the constants below. Orthogonal to the channel fork, every scout gets an origin-matched+# improvement channel: a *custom* (team-authored) scout gets the self-improvement section+# (`_self_improvement_section`), which on the report channel also invites escalating strong suggestions+# as inbox reports about the scout; a *canonical* scout gets `_CANONICAL_IMPROVEMENT`, routing+# generalized skill-content gaps upstream to the PostHog team via `agent-feedback`._BASE_PROMPT_INTRO = """You are a Signals scout agent for PostHog.@@ -243,7 +245,8 @@ _GROUND_RULES = """# Ground rules# Appended only for a *custom* (team-authored) scout — see `build_run_prompt`. A canonical scout# never sees this section: its skill body is a seeded row that upstream sync keeps current, and# nudging a team to edit it would mark the row diverged and cut it off from canonical updates.-# Canonical-skill defects route upstream via the operational-friction section instead.+# Canonical scouts get the _CANONICAL_IMPROVEMENT section instead, routing skill-content gaps+# upstream via `agent-feedback` `feedback_type="scout"`._SELF_IMPROVEMENT_HEAD = """# Suggest improvements to your own skillThis scout's skill was authored by your team, and you are the only one who sees where its instructions steer a real run wrong. When THIS run produced concrete evidence that the skill misdirected you or wasted your budget — it pointed you at a tool, event, or surface that doesn't exist on this project, a default threshold or window you had to correct again, a recurring pitfall it never warns about — record the suggestion so the humans who own this scout can review it:@@ -282,6 +285,25 @@ def _self_improvement_section(*, can_emit_report: bool, can_edit_report: bool) -return "\n".join(parts)+# The canonical counterpart of the self-improvement section: a *canonical* scout's skill body is+# PostHog-owned and kept current by upstream sync, so its improvement channel points upstream —+# `agent-feedback` with `feedback_type: "scout"` plus the structured skill fields — never at the+# team-local `improve:` scratchpad flow (which would nudge the team into diverging the seeded row).+# The feedback leaves the customer's project (it reaches the PostHog team's telemetry), which is why+# the generalization rules below are the load-bearing part: the pattern travels, the instance never+# does. Channel-agnostic on purpose — `agent-feedback` is an always-available MCP tool, so no+# per-tool fail-closed gating is needed.+_CANONICAL_IMPROVEMENT = """# Suggest improvements to your canonical skill++Your skill is a canonical PostHog-authored skill that runs on many projects, and your runs are the only place its real-world gaps show up. When THIS run produced concrete evidence that the skill itself has a gap — its detection rules produced a false positive, its instructions steered you past a real issue, its discriminator doesn't hold for this kind of project, an investigation pattern it mandates wasted most of your budget, or an instruction is ambiguous in practice — report it upstream via the `agent-feedback` MCP tool so the PostHog team can improve the skill for every project it runs on:++- Set `feedback_type` = `"scout"`, `scout_skill_name` exactly as listed under *Your run identity*, `scout_skill_version` as a bare number — the numeric part of the version there (`7` for `v7`, never the `v` prefix) — and `scout_category` to the closest match (`false_positive`, `missed_detection`, `discriminator_gap`, `wasted_investigation`, `instruction_ambiguity`, or `other`). All three are required or the submission is rejected. Put the specific skill change you'd suggest in `suggested_improvement`.+- **Generalize — this project's data must not travel.** The feedback leaves this project, so describe the *pattern*, never the *instance*: no person, account, or company data; no property values, URLs, or project-specific numbers; not even this project's custom event or property names — they are the customer's schema, so describe their shape instead ("a project whose 404 event is custom-named", not the name itself). If you can't state the improvement without project specifics, keep it as a scratchpad note instead of submitting it.+- **Don't re-report a known gap.** Keep a `reported:<your-skill-name>:<topic>` scratchpad entry for each gap you've submitted (stable key; the dates AND the skill version you reported against go in the content — same rules as your other keys). Your step-1 scratchpad search surfaces them: only re-submit when you have materially new evidence, appending a fresh dated line when you do. A skill version bump where the gap still reproduces IS materially new evidence — feedback is aggregated per version, so re-submit against the current version and update the entry rather than staying quiet on a stale one. When a later skill version fixes the gap, `forget` the entry.+- Routing: this channel is only for the content of your canonical skill body. A problem with the tools, the harness, or these shared instructions goes through the operational-friction section above, like any other run.+- The bar is a concrete failure or waste observed this run — generic polish ("the wording could be clearer") is noise, don't send it. At most one submission per run, near close-out, and mention it in your summary. It is never a substitute for finishing the run."""++_OPERATIONAL_FRICTION = """# Report operational frictionYou run this tooling end to end on a schedule, so your experience is how PostHog makes the scout system better over time. If something gets in your way as you work — a tool you needed was missing, a tool returned wrong, confusing, or unusable data, an error you couldn't recover from, the project profile lacked something you expected, or these instructions sent you down the wrong path — proactively report it via the `agent-feedback` MCP tool when it's available to you this run.@@ -418,7 +440,9 @@ def build_run_prompt(skill: LoadedSkill, *, run_id: str, team_id: int, started_a(team-authored) scout gets the self-improvement section inviting evidence-backed `improve:`scratchpad suggestions for its own skill body — and, when it holds report tools, escalatingrecurring or material suggestions as inbox reports about the scout itself; a canonical scout- gets neither, so the harness never nudges a team into diverging a seeded row from upstream sync.+ instead gets the canonical-improvement section routing generalized skill-content gaps upstream+ via `agent-feedback` (`feedback_type="scout"`), so the harness never nudges a team into+ diverging a seeded row from upstream sync.`run_id` is the UUID of the `SignalScoutRun` row the harness inserted beforespawning the sandbox. The agent passes it back when it calls@@ -453,11 +477,15 @@ def build_run_prompt(skill: LoadedSkill, *, run_id: str, team_id: int, started_aintro = _BASE_PROMPT_INTROsections = _SIGNAL_TAIL_SECTIONSemit_tool = "scout-emit-signal"+ # Slot the origin-matched improvement channel between friction reporting and the output format+ # (the last element of every tail): a custom scout suggests changes to its team-owned body via+ # `improve:` entries (see the note on _SELF_IMPROVEMENT_HEAD); a canonical scout routes skill-content+ # gaps upstream via `agent-feedback` `feedback_type="scout"` (see the note on _CANONICAL_IMPROVEMENT).if skill.origin == "custom":- # Slot the self-improvement invitation between friction reporting and the output format- # (the last element of every tail). Custom scouts only — see the note on _SELF_IMPROVEMENT_HEAD.- self_improvement = _self_improvement_section(can_emit_report=can_emit_report, can_edit_report=can_edit_report)- sections = [*sections[:-1], self_improvement, sections[-1]]+ improvement = _self_improvement_section(can_emit_report=can_emit_report, can_edit_report=can_edit_report)+ else:+ improvement = _CANONICAL_IMPROVEMENT+ sections = [*sections[:-1], improvement, sections[-1]]tail = _render_tail(sections, schema_json=schema_json)# Report-channel scouts only: the authors line exists to steer `suggested_reviewers`, and a# signal-channel scout has no reviewers field — member names/emails are PII that shouldn'tdiff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.pyindex 19d95a188e1b..00ca36835d24 100644--- a/products/signals/backend/test/test_scout_harness.py+++ b/products/signals/backend/test/test_scout_harness.py@@ -357,6 +357,13 @@ class TestPromptBuilder(BaseTest):("custom_report_scout_emit_only", "signals-scout-errors", {}, ["emit_report"], True),# No stored canonical_hash (pre-hash-tracking legacy row): unprovable, stays canonical.("canonical_scout_no_hash", "signals-scout-general", {"seeded_by": HARNESS_SEEDED_BY}, [], False),+ (+ "canonical_report_scout",+ "signals-scout-general",+ {"seeded_by": HARNESS_SEEDED_BY},+ ["emit_report", "edit_report"],+ False,+ ),("diverged_canonical_scout","signals-scout-general",@@ -405,7 +412,19 @@ class TestPromptBuilder(BaseTest):if _name == "custom_report_scout_emit_only":# The emit-only variant must never name the edit tool it lacks (fails closed).assert "scout-edit-report" not in prompt- # The upstream friction channel is origin-independent: canonical defects still route there.+ # The canonical-improvement channel is the exact inverse of the self-improvement gate: a+ # canonical scout routes skill-content gaps upstream via agent-feedback, while a custom or+ # diverged scout must never be told to send its team-owned skill body to the PostHog team.+ assert ("Suggest improvements to your canonical skill" in prompt) is not expect_section+ assert ('`feedback_type` = `"scout"`' in prompt) is not expect_section+ # The structured fields and the reported: dedupe key are what make fleet-wide feedback+ # aggregable per skill/version and non-repetitive across runs — they must ride with the section.+ assert ("scout_skill_name" in prompt) is not expect_section+ assert ("reported:<your-skill-name>:<topic>" in prompt) is not expect_section+ # The generalization rule is the privacy boundary: the feedback leaves the customer's+ # project, so dropping this line silently re-opens the customer-data-travels failure mode.+ assert ("this project's data must not travel" in prompt) is not expect_section+ # The upstream friction channel is origin-independent: harness/tool defects still route there.assert "agent-feedback" in promptdef test_pristine_seeded_row_stays_canonical(self) -> None:@@ -428,6 +447,8 @@ class TestPromptBuilder(BaseTest):started_at=datetime(2026, 5, 1, 12, 34, 56, tzinfo=UTC),)assert "Suggest improvements to your own skill" not in prompt+ # The pristine canonical scout routes skill-content gaps upstream instead.+ assert "Suggest improvements to your canonical skill" in prompt# A canonical skill body is PostHog-owned — the run identity must not name the seeding# row's incidental `created_by` as a skill author.assert "skill authors" not in promptdiff --git a/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md b/products/signals/skills/authoring-scouts/references/dedupe-and-memory.mdindex 57c73d404ba2..860883336dd6 100644--- a/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md+++ b/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md@@ -33,6 +33,7 @@ Re-using a key rewrites the entry in place (the idempotent refresh — use it to| `not-in-use:` | Close-out memo for "product/surface not in use on this team". || `mcp-gap:` | Scout-noticed gap in the MCP surface worth raising later. || `improve:` | Custom scouts only: an evidence-backed suggested change to this scout's own skill body, written for the scout's owner to review and apply (or reject). Keyed `improve:<skill-name>:<topic>` — skill name, not domain, since scratchpad keys are team-wide and two scouts sharing a domain would clobber each other. The harness prompt invites these on custom scouts; canonical scouts never write them (applying one would diverge the seeded row). On the report channel, a suggestion that re-confirms across runs (or a single material failure) also gets escalated as an inbox report about the scout itself, with the `report_id` stashed in this entry as the pointer. The scout clears its own entry once a later run confirms the suggestion was addressed. |+| `reported:` | Canonical scouts only: a record that a gap in the scout's own canonical skill body was already fed back upstream to the PostHog team via `agent-feedback` (`feedback_type: "scout"`). Keyed `reported:<skill-name>:<topic>`, dates in the content, so future runs don't re-submit a known gap without materially new evidence. Cleared once a later skill version fixes the gap. || `report:` | A report this scout authored — stores the `report_id`, keyed `report:<domain>:<entity>`, so the next run edits/dedups against it instead of re-filing. See [`report-contract.md`](report-contract.md). || `reviewer:` | A resolved owner (bare lowercase GitHub login), keyed `reviewer:<domain>:<area>`, so the next run sets `suggested_reviewers` without re-resolving. |diff --git a/products/signals/skills/exploring-scouts/SKILL.md b/products/signals/skills/exploring-scouts/SKILL.mdindex 6cb15c1f3163..a9905d2a6a48 100644--- a/products/signals/skills/exploring-scouts/SKILL.md+++ b/products/signals/skills/exploring-scouts/SKILL.md@@ -195,6 +195,7 @@ Each entry's `key` carries a category prefix that tells you _what kind_ of learn| `not-in-use:` | A product/surface this team doesn't use (close-out memo) || `mcp-gap:` | A tooling gap a scout noticed worth raising later || `improve:` | A custom scout's suggested change to its own skill body, awaiting owner review |+| `reported:` | A canonical scout's record of a skill gap already fed back upstream to PostHog || `report:` | A report a scout authored — stores the `report_id` so later runs edit/dedup against it || `reviewer:` | A resolved owner (GitHub login) for an area, cached for `suggested_reviewers` routing |@@ -210,6 +211,7 @@ A custom scout on the report channel escalates recurring or material suggestionsWhen assessing a custom scout, search `{"text": "improve:"}` and surface these to the user: an entry re-confirmed across several runs is the highest-signal edit the owner can make.Reviewing and applying them is a write operation — hand off to the `authoring-scouts` skill.Canonical scouts never write `improve:` entries (their skill bodies are synced from PostHog's fleet), so an `improve:` entry under a canonical scout's domain is itself worth flagging.+Instead, a canonical scout routes skill-content gaps upstream to the PostHog team via the `agent-feedback` MCP tool (`feedback_type: "scout"`), generalized so no project data travels, and keeps a `reported:<skill-name>:<topic>` entry as its local record of what it already submitted — so a `reported:` entry tells you a gap has been raised with PostHog, not with this team.## Workflow: see what scouts have writtendiff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex c330e659a7f1..94b424431eec 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -970,7 +970,7 @@"feature_flag": "agent-platform"},"agent-feedback": {- "description": "Send feedback about anything PostHog to the PostHog team. Set `feedback_type` to route it: `product` (any PostHog product or feature — insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.; put the area in `product_area`), `mcp` (this MCP server itself — a tool, input schema, response format, error, or these instructions; set `category`), `docs`, or `other`. ALL sentiments are welcome via `sentiment` (`positive`/`neutral`/`negative`/`mixed`) — praise and feature requests are useful signal, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you worked around, a feature request, an unhelpful error, or something that worked really well. Keep `summary` to one sentence and write the free-text fields as clear, concise bullet points, quoting the product surface, tool name, parameter, or error text where possible. Include a concrete `suggested_improvement` whenever you can name one. Do not include user PII or sensitive query content. The user can also ask you to send feedback directly (e.g. 'make a PostHog feedback for this'). IMPORTANT: submitting feedback does NOT mean your work is done — keep going and finish the user's task using the other available tools. This tool is a side channel to the PostHog team, not a way to end the conversation.",+ "description": "Send feedback about anything PostHog to the PostHog team. Set `feedback_type` to route it: `product` (any PostHog product or feature — insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.; put the area in `product_area`), `mcp` (this MCP server itself — a tool, input schema, response format, error, or these instructions; set `category`), `docs`, `scout` (reserved for scheduled scout runs reporting an improvement opportunity in the canonical PostHog scout skill steering the run; set `scout_skill_name`, `scout_skill_version`, and `scout_category`, and generalize — describe the pattern, never the project's data), or `other`. ALL sentiments are welcome via `sentiment` (`positive`/`neutral`/`negative`/`mixed`) — praise and feature requests are useful signal, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you worked around, a feature request, an unhelpful error, or something that worked really well. Keep `summary` to one sentence and write the free-text fields as clear, concise bullet points, quoting the product surface, tool name, parameter, or error text where possible. Include a concrete `suggested_improvement` whenever you can name one. Do not include user PII or sensitive query content. The user can also ask you to send feedback directly (e.g. 'make a PostHog feedback for this'). IMPORTANT: submitting feedback does NOT mean your work is done — keep going and finish the user's task using the other available tools. This tool is a side channel to the PostHog team, not a way to end the conversation.","category": "Feedback","feature": "feedback","summary": "Send feedback about any PostHog product, this MCP, or the docs.",diff --git a/services/mcp/schema/tool-definitions.json b/services/mcp/schema/tool-definitions.jsonindex 33f786fcf926..85b336522055 100644--- a/services/mcp/schema/tool-definitions.json+++ b/services/mcp/schema/tool-definitions.json@@ -14,7 +14,7 @@}},"agent-feedback": {- "description": "Send feedback about anything PostHog to the PostHog team. Set `feedback_type` to route it: `product` (any PostHog product or feature — insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.; put the area in `product_area`), `mcp` (this MCP server itself — a tool, input schema, response format, error, or these instructions; set `category`), `docs`, or `other`. ALL sentiments are welcome via `sentiment` (`positive`/`neutral`/`negative`/`mixed`) — praise and feature requests are useful signal, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you worked around, a feature request, an unhelpful error, or something that worked really well. Keep `summary` to one sentence and write the free-text fields as clear, concise bullet points, quoting the product surface, tool name, parameter, or error text where possible. Include a concrete `suggested_improvement` whenever you can name one. Do not include user PII or sensitive query content. The user can also ask you to send feedback directly (e.g. 'make a PostHog feedback for this'). IMPORTANT: submitting feedback does NOT mean your work is done — keep going and finish the user's task using the other available tools. This tool is a side channel to the PostHog team, not a way to end the conversation.",+ "description": "Send feedback about anything PostHog to the PostHog team. Set `feedback_type` to route it: `product` (any PostHog product or feature — insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.; put the area in `product_area`), `mcp` (this MCP server itself — a tool, input schema, response format, error, or these instructions; set `category`), `docs`, `scout` (reserved for scheduled scout runs reporting an improvement opportunity in the canonical PostHog scout skill steering the run; set `scout_skill_name`, `scout_skill_version`, and `scout_category`, and generalize — describe the pattern, never the project's data), or `other`. ALL sentiments are welcome via `sentiment` (`positive`/`neutral`/`negative`/`mixed`) — praise and feature requests are useful signal, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you worked around, a feature request, an unhelpful error, or something that worked really well. Keep `summary` to one sentence and write the free-text fields as clear, concise bullet points, quoting the product surface, tool name, parameter, or error text where possible. Include a concrete `suggested_improvement` whenever you can name one. Do not include user PII or sensitive query content. The user can also ask you to send feedback directly (e.g. 'make a PostHog feedback for this'). IMPORTANT: submitting feedback does NOT mean your work is done — keep going and finish the user's task using the other available tools. This tool is a side channel to the PostHog team, not a way to end the conversation.","category": "Feedback","feature": "feedback","summary": "Send feedback about any PostHog product, this MCP, or the docs.",diff --git a/services/mcp/schema/tool-inputs.json b/services/mcp/schema/tool-inputs.jsonindex 47e5b283a070..c14652efaa5a 100644--- a/services/mcp/schema/tool-inputs.json+++ b/services/mcp/schema/tool-inputs.json@@ -406,8 +406,8 @@},"feedback_type": {"type": "string",- "enum": ["product", "mcp", "docs", "other"],- "description": "What this feedback is about. \"product\" = any PostHog product or feature (insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.). \"mcp\" = this MCP server itself — a tool, its input schema, response format, an error, or these instructions. \"docs\" = PostHog documentation. \"other\" = anything that doesn't fit the above."+ "enum": ["product", "mcp", "docs", "scout", "other"],+ "description": "What this feedback is about. \"product\" = any PostHog product or feature (insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.). \"mcp\" = this MCP server itself — a tool, its input schema, response format, an error, or these instructions. \"docs\" = PostHog documentation. \"scout\" = a canonical PostHog scout skill's content — reserved for scheduled scout runs reporting an improvement opportunity in their own PostHog-authored skill (set `scout_skill_name`, `scout_skill_version`, and `scout_category`). \"other\" = anything that doesn't fit the above."},"sentiment": {"type": "string",@@ -433,6 +433,28 @@"other"]},+ "scout_skill_name": {+ "description": "For scout feedback (`feedback_type: \"scout\"`) only: the canonical scout skill the feedback is about (e.g. \"signals-scout-web-analytics\"), exactly as named in the run identity. Required for scout feedback — without it the feedback cannot be aggregated per skill.",+ "type": "string"+ },+ "scout_skill_version": {+ "description": "For scout feedback (`feedback_type: \"scout\"`) only: the skill version the run executed (from the run identity). Feedback is only actionable against the version that produced it — the skill may have moved since.",+ "type": "integer",+ "minimum": -9007199254740991,+ "maximum": 9007199254740991+ },+ "scout_category": {+ "description": "For scout feedback (`feedback_type: \"scout\"`) only: the single category that best describes the skill gap. \"false_positive\" = the skill's detection rules surfaced something that wasn't real; \"missed_detection\" = a real issue the skill's instructions steered you past; \"discriminator_gap\" = the skill's signal-vs-baseline discriminator doesn't hold for a class of projects; \"wasted_investigation\" = an investigation pattern the skill mandates burned budget without payoff; \"instruction_ambiguity\" = an instruction that is ambiguous in practice. Omit for non-scout feedback.",+ "type": "string",+ "enum": [+ "false_positive",+ "missed_detection",+ "discriminator_gap",+ "wasted_investigation",+ "instruction_ambiguity",+ "other"+ ]+ },"task_completed": {"description": "Were you able to complete the user's task? Be honest — \"false\" is just as useful as \"true\". Most relevant when `feedback_type` is \"mcp\".","type": "boolean"diff --git a/services/mcp/src/schema/tool-inputs.ts b/services/mcp/src/schema/tool-inputs.tsindex 5789f0bc9032..e46cfced0172 100644--- a/services/mcp/src/schema/tool-inputs.ts+++ b/services/mcp/src/schema/tool-inputs.ts@@ -187,9 +187,9 @@ export const FeedbackSubmitSchema = z.object({'A one-sentence headline capturing the feedback (e.g. "session replay scrubber jumps backwards when you click the timeline", "query-trends descriptions made it hard to choose between trends and funnels", or "the new SQL editor autocomplete is excellent").'),feedback_type: z- .enum(['product', 'mcp', 'docs', 'other'])+ .enum(['product', 'mcp', 'docs', 'scout', 'other']).describe(- 'What this feedback is about. "product" = any PostHog product or feature (insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.). "mcp" = this MCP server itself — a tool, its input schema, response format, an error, or these instructions. "docs" = PostHog documentation. "other" = anything that doesn\'t fit the above.'+ 'What this feedback is about. "product" = any PostHog product or feature (insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.). "mcp" = this MCP server itself — a tool, its input schema, response format, an error, or these instructions. "docs" = PostHog documentation. "scout" = a canonical PostHog scout skill\'s content — reserved for scheduled scout runs reporting an improvement opportunity in their own PostHog-authored skill (set `scout_skill_name`, `scout_skill_version`, and `scout_category`). "other" = anything that doesn\'t fit the above.'),sentiment: z.enum(['positive', 'neutral', 'negative', 'mixed'])@@ -218,6 +218,32 @@ export const FeedbackSubmitSchema = z.object({.describe('For MCP feedback (`feedback_type: "mcp"`) only: the single category that best describes the dominant theme. Pick "missing_tool" if a capability was absent, "tool_description" if the tool docs were unclear, "tool_input_schema" if input args were confusing, "tool_output_format" if the response was hard to consume, "instructions_clarity" if these MCP instructions were unclear, "tool_correctness" if a tool returned wrong data, "error_message" if an error was unhelpful, "performance" if latency was the issue. Omit for product, docs, or other feedback.'),+ scout_skill_name: z+ .string()+ .optional()+ .describe(+ 'For scout feedback (`feedback_type: "scout"`) only: the canonical scout skill the feedback is about (e.g. "signals-scout-web-analytics"), exactly as named in the run identity. Required for scout feedback — without it the feedback cannot be aggregated per skill.'+ ),+ scout_skill_version: z+ .number()+ .int()+ .optional()+ .describe(+ 'For scout feedback (`feedback_type: "scout"`) only: the skill version the run executed (from the run identity). Feedback is only actionable against the version that produced it — the skill may have moved since.'+ ),+ scout_category: z+ .enum([+ 'false_positive',+ 'missed_detection',+ 'discriminator_gap',+ 'wasted_investigation',+ 'instruction_ambiguity',+ 'other',+ ])+ .optional()+ .describe(+ 'For scout feedback (`feedback_type: "scout"`) only: the single category that best describes the skill gap. "false_positive" = the skill\'s detection rules surfaced something that wasn\'t real; "missed_detection" = a real issue the skill\'s instructions steered you past; "discriminator_gap" = the skill\'s signal-vs-baseline discriminator doesn\'t hold for a class of projects; "wasted_investigation" = an investigation pattern the skill mandates burned budget without payoff; "instruction_ambiguity" = an instruction that is ambiguous in practice. Omit for non-scout feedback.'+ ),task_completed: z.boolean().optional()@@ -252,6 +278,21 @@ export const FeedbackSubmitSchema = z.object({.string().optional().describe("Any additional context that doesn't fit the other fields. Keep it to clear, concise bullet points."),+}).superRefine((data, ctx) => {+ // Scout feedback without its join keys can't be aggregated per skill/version downstream,+ // so reject it at validation time instead of recording an unattributable event.+ if (data.feedback_type !== 'scout') {+ return+ }+ for (const field of ['scout_skill_name', 'scout_skill_version', 'scout_category'] as const) {+ if (data[field] === undefined) {+ ctx.addIssue({+ code: 'custom',+ path: [field],+ message: `${field} is required when feedback_type is "scout".`,+ })+ }+ }})const SavedMetricAttachItemSchema = z.object({diff --git a/services/mcp/src/templates/sections/agent-feedback.md b/services/mcp/src/templates/sections/agent-feedback.mdindex 2d9a50879212..e73ca5c40599 100644--- a/services/mcp/src/templates/sections/agent-feedback.md+++ b/services/mcp/src/templates/sections/agent-feedback.md@@ -7,6 +7,7 @@ Set `feedback_type` to route it:- `product` — any PostHog product or feature: insights, session replay, feature flags, the data warehouse, web analytics, error tracking, experiments, etc. Put the area in `product_area` (e.g. "session replay").- `mcp` — this MCP server itself: an unclear tool description, a confusing input schema, a hard-to-consume response, wrong results, an unhelpful error, a missing tool, or these instructions. Set `category` for MCP feedback.- `docs` — PostHog documentation.+- `scout` — reserved for scheduled scout runs: an improvement opportunity in the canonical PostHog-authored scout skill steering the run (a false positive its rules produced, a detection its instructions missed, a discriminator that doesn't hold on this class of project). Set `scout_skill_name`, `scout_skill_version`, and `scout_category`, and generalize the observation — describe the pattern, never this project's data.- `other` — anything that doesn't fit the above.**All sentiments are welcome** — set `sentiment` to `positive`, `neutral`, `negative`, or `mixed`. Unlike a bug tracker, praise and feature requests are useful signal too, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you had to work around, a feature request, an unhelpful error, or something that worked really well and is worth reinforcing.diff --git a/services/mcp/src/tools/feedback/submit.ts b/services/mcp/src/tools/feedback/submit.tsindex 446086d315eb..e08b4676213e 100644--- a/services/mcp/src/tools/feedback/submit.ts+++ b/services/mcp/src/tools/feedback/submit.ts@@ -36,6 +36,9 @@ export const submitFeedbackHandler: ToolBase<typeof schema, Result>['handler'] =feedback_sentiment: params.sentiment,feedback_product_area: params.product_area,feedback_category: params.category,+ feedback_scout_skill_name: params.scout_skill_name,+ feedback_scout_skill_version: params.scout_skill_version,+ feedback_scout_category: params.scout_category,feedback_task_completed: params.task_completed,feedback_tools_used: params.tools_used,feedback_friction_points: params.friction_points,diff --git a/services/mcp/tests/unit/__snapshots__/instructions/exec-command-reference-full.txt b/services/mcp/tests/unit/__snapshots__/instructions/exec-command-reference-full.txtindex 82b8a50d3103..476135352541 100644--- a/services/mcp/tests/unit/__snapshots__/instructions/exec-command-reference-full.txt+++ b/services/mcp/tests/unit/__snapshots__/instructions/exec-command-reference-full.txt@@ -247,6 +247,7 @@ Set `feedback_type` to route it:- `product` — any PostHog product or feature: insights, session replay, feature flags, the data warehouse, web analytics, error tracking, experiments, etc. Put the area in `product_area` (e.g. "session replay").- `mcp` — this MCP server itself: an unclear tool description, a confusing input schema, a hard-to-consume response, wrong results, an unhelpful error, a missing tool, or these instructions. Set `category` for MCP feedback.- `docs` — PostHog documentation.+- `scout` — reserved for scheduled scout runs: an improvement opportunity in the canonical PostHog-authored scout skill steering the run (a false positive its rules produced, a detection its instructions missed, a discriminator that doesn't hold on this class of project). Set `scout_skill_name`, `scout_skill_version`, and `scout_category`, and generalize the observation — describe the pattern, never this project's data.- `other` — anything that doesn't fit the above.**All sentiments are welcome** — set `sentiment` to `positive`, `neutral`, `negative`, or `mixed`. Unlike a bug tracker, praise and feature requests are useful signal too, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you had to work around, a feature request, an unhelpful error, or something that worked really well and is worth reinforcing.diff --git a/services/mcp/tests/unit/__snapshots__/instructions/tools-instructions.txt b/services/mcp/tests/unit/__snapshots__/instructions/tools-instructions.txtindex 0839819a481d..5b49a49e43d2 100644--- a/services/mcp/tests/unit/__snapshots__/instructions/tools-instructions.txt+++ b/services/mcp/tests/unit/__snapshots__/instructions/tools-instructions.txt@@ -135,6 +135,7 @@ Set `feedback_type` to route it:- `product` — any PostHog product or feature: insights, session replay, feature flags, the data warehouse, web analytics, error tracking, experiments, etc. Put the area in `product_area` (e.g. "session replay").- `mcp` — this MCP server itself: an unclear tool description, a confusing input schema, a hard-to-consume response, wrong results, an unhelpful error, a missing tool, or these instructions. Set `category` for MCP feedback.- `docs` — PostHog documentation.+- `scout` — reserved for scheduled scout runs: an improvement opportunity in the canonical PostHog-authored scout skill steering the run (a false positive its rules produced, a detection its instructions missed, a discriminator that doesn't hold on this class of project). Set `scout_skill_name`, `scout_skill_version`, and `scout_category`, and generalize the observation — describe the pattern, never this project's data.- `other` — anything that doesn't fit the above.**All sentiments are welcome** — set `sentiment` to `positive`, `neutral`, `negative`, or `mixed`. Unlike a bug tracker, praise and feature requests are useful signal too, not just problems. Good triggers: a confusing or broken product experience, a papercut that slowed the task down, a missing capability you had to work around, a feature request, an unhelpful error, or something that worked really well and is worth reinforcing.diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/agent-feedback.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/agent-feedback.jsonindex fcc5e32fb9c6..cca886222c6d 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/agent-feedback.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/agent-feedback.json@@ -21,8 +21,8 @@"type": "string"},"feedback_type": {- "description": "What this feedback is about. \"product\" = any PostHog product or feature (insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.). \"mcp\" = this MCP server itself — a tool, its input schema, response format, an error, or these instructions. \"docs\" = PostHog documentation. \"other\" = anything that doesn't fit the above.",- "enum": ["product", "mcp", "docs", "other"],+ "description": "What this feedback is about. \"product\" = any PostHog product or feature (insights, session replay, feature flags, the data warehouse, web analytics, error tracking, etc.). \"mcp\" = this MCP server itself — a tool, its input schema, response format, an error, or these instructions. \"docs\" = PostHog documentation. \"scout\" = a canonical PostHog scout skill's content — reserved for scheduled scout runs reporting an improvement opportunity in their own PostHog-authored skill (set `scout_skill_name`, `scout_skill_version`, and `scout_category`). \"other\" = anything that doesn't fit the above.",+ "enum": ["product", "mcp", "docs", "scout", "other"],"type": "string"},"friction_points": {@@ -33,6 +33,28 @@"description": "The PostHog product or area this is about, in free text (e.g. \"session replay\", \"insights\", \"data warehouse\", \"feature flags\", \"docs\"). Most useful for product feedback; for MCP feedback the tool name belongs in `details`/`friction_points` instead.","type": "string"},+ "scout_category": {+ "description": "For scout feedback (`feedback_type: \"scout\"`) only: the single category that best describes the skill gap. \"false_positive\" = the skill's detection rules surfaced something that wasn't real; \"missed_detection\" = a real issue the skill's instructions steered you past; \"discriminator_gap\" = the skill's signal-vs-baseline discriminator doesn't hold for a class of projects; \"wasted_investigation\" = an investigation pattern the skill mandates burned budget without payoff; \"instruction_ambiguity\" = an instruction that is ambiguous in practice. Omit for non-scout feedback.",+ "enum": [+ "false_positive",+ "missed_detection",+ "discriminator_gap",+ "wasted_investigation",+ "instruction_ambiguity",+ "other"+ ],+ "type": "string"+ },+ "scout_skill_name": {+ "description": "For scout feedback (`feedback_type: \"scout\"`) only: the canonical scout skill the feedback is about (e.g. \"signals-scout-web-analytics\"), exactly as named in the run identity. Required for scout feedback — without it the feedback cannot be aggregated per skill.",+ "type": "string"+ },+ "scout_skill_version": {+ "description": "For scout feedback (`feedback_type: \"scout\"`) only: the skill version the run executed (from the run identity). Feedback is only actionable against the version that produced it — the skill may have moved since.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },"sentiment": {"description": "The overall tone. Use \"negative\" for something broken or blocking, \"mixed\" for mostly-fine-but-with-a-concrete-problem, \"neutral\" for a suggestion or feature request with no strong sentiment, and \"positive\" for praise or something that worked well. All sentiments are welcome — positive feedback is encouraged, not just problems.","enum": ["positive", "neutral", "negative", "mixed"],diff --git a/services/mcp/tests/unit/feedback-submit.test.ts b/services/mcp/tests/unit/feedback-submit.test.tsnew file mode 100644index 000000000000..5c97caf5e89d--- /dev/null+++ b/services/mcp/tests/unit/feedback-submit.test.ts@@ -0,0 +1,65 @@+/**+ * The agent-feedback handler enumerates schema fields by hand when it builds the+ * `mcp feedback submitted` analytics payload, so a field added to+ * `FeedbackSubmitSchema` can silently never reach the event downstream consumers+ * aggregate on. This pins the scout-feedback fields (skill name / version /+ * category) — the join keys for per-skill fleet-wide aggregation — to the+ * `feedback_scout_*` event properties.+ */+import { describe, expect, it, vi } from 'vitest'++import { FeedbackSubmitSchema } from '@/schema/tool-inputs'+import { submitFeedbackHandler } from '@/tools/feedback/submit'+import type { Context } from '@/tools/types'++describe('agent-feedback submit handler', () => {+ it('forwards scout feedback fields into the analytics event', async () => {+ const trackEvent = vi.fn().mockResolvedValue(undefined)+ const context = { trackEvent } as unknown as Context++ const result = await submitFeedbackHandler(context, {+ summary: 'discriminator misfires on young projects',+ feedback_type: 'scout',+ sentiment: 'neutral',+ scout_skill_name: 'signals-scout-web-analytics',+ scout_skill_version: 7,+ scout_category: 'discriminator_gap',+ suggested_improvement: 'gate the baseline comparison on >=7 days of history',+ })++ expect(trackEvent).toHaveBeenCalledTimes(1)+ expect(trackEvent).toHaveBeenCalledWith(+ 'mcp feedback submitted',+ expect.objectContaining({+ feedback_type: 'scout',+ feedback_scout_skill_name: 'signals-scout-web-analytics',+ feedback_scout_skill_version: 7,+ feedback_scout_category: 'discriminator_gap',+ })+ )+ expect(result.received).toBe(true)+ })++ it.each([+ ['scout_skill_name', { scout_skill_version: 7, scout_category: 'discriminator_gap' }],+ ['scout_skill_version', { scout_skill_name: 'signals-scout-web-analytics', scout_category: 'other' }],+ ['scout_category', { scout_skill_name: 'signals-scout-web-analytics', scout_skill_version: 7 }],+ ])('rejects scout feedback missing %s', (_missing, scoutFields) => {+ const result = FeedbackSubmitSchema.safeParse({+ summary: 'discriminator misfires on young projects',+ feedback_type: 'scout',+ sentiment: 'neutral',+ ...scoutFields,+ })+ expect(result.success).toBe(false)+ })++ it('accepts non-scout feedback without scout fields', () => {+ const result = FeedbackSubmitSchema.safeParse({+ summary: 'the SQL editor autocomplete is excellent',+ feedback_type: 'product',+ sentiment: 'positive',+ })+ expect(result.success).toBe(true)+ })+})