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.

feat(signals): custom scouts escalate self-improvement as reports (#69953)

Andrew Maguirea758205823a0
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.md
index 4e5aafcfb5a8..dc0620c36cb6 100644
--- a/products/signals/backend/scout_harness/AGENTS.md
+++ b/products/signals/backend/scout_harness/AGENTS.md
@@ -40,7 +40,15 @@ it is exercised via the `run_signals_scout` management command (see `../manageme
hand-authored, or a seeded canonical row the team has since edited in place (diverged) —
gets a self-improvement section inviting evidence-backed `improve:<skill-name>:<topic>`
scratchpad suggestions for its own skill body, which the owner reviews via the
- `exploring-scouts` / `authoring-scouts` meta skills. A pristine canonical scout never sees
+ `exploring-scouts` / `authoring-scouts` meta skills. When such a scout also holds report
+ tools, the section additionally invites escalating recurring or material suggestions as
+ inbox reports about the scout itself (titled `Scout self-improvement: <skill-name> – <topic>`,
+ `NO_REPO`, `requires_human_input`), authored/edited with the report tools it already holds
+ and pointed to by the `report_id` stashed in the `improve:` entry — so self-improvement
+ suggestions reach the owner through the inbox like any other report, with no extra scope or
+ endpoint (the same per-tool fail-closed gating applies: an emit-only scout is never pointed
+ at `edit_report`, and a signal-channel custom scout keeps the scratchpad-only path). A
+ pristine canonical scout never sees
it — 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.
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index dd55011f3b64..0be5983fe25b 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -33,7 +33,8 @@ class SignalScoutRunSummary(BaseModel):
# 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`).
+# 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.
_BASE_PROMPT_INTRO = """You are a Signals scout agent for PostHog.
@@ -239,16 +240,38 @@ _GROUND_RULES = """# Ground rules
# 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.
-_SELF_IMPROVEMENT = """# Suggest improvements to your own skill
+_SELF_IMPROVEMENT_HEAD = """# Suggest improvements to your own skill
This 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:
-- Write a scratchpad entry keyed `improve:<your-skill-name>:<topic>` — use your skill name from *Your run identity*, not a bare domain: scratchpad keys are shared team-wide, and a domain-only key would let two scouts overwrite each other's suggestions. Stable key, no dates — same rules as your other keys. In the content: the specific skill change you'd suggest, the evidence from this run, and a dated observed line. Hit the same issue on a later run? Rewrite the same key with a fresh dated line appended — recurrence across runs is the strongest review signal the owner gets.
-- The bar is a concrete failure or waste observed this run. Generic polish ("the wording could be clearer") is noise — don't write it.
+- Write a scratchpad entry keyed `improve:<your-skill-name>:<topic>` — use your skill name from *Your run identity*, not a bare domain: scratchpad keys are shared team-wide, and a domain-only key would let two scouts overwrite each other's suggestions. Stable key, no dates — same rules as your other keys. In the content: the specific skill change you'd suggest, the evidence from this run, and a dated observed line. Hit the same issue on a later run? Rewrite the same key with a fresh dated line appended — recurrence across runs is the strongest review signal the owner gets."""
+
+# Report-channel custom scouts additionally escalate strong suggestions to the inbox with the report
+# tools they already hold. Two variants because an emit-only scout must never be pointed at
+# `edit_report` (the endpoint fails closed on the exact tool); a signal-channel custom scout gets
+# neither — it has no report tools at all, so the scratchpad stays its only self-improvement record.
+_SELF_IMPROVEMENT_ESCALATE_BOTH = """- **Recurring or material? File an inbox report too.** A scratchpad entry is only seen when the owner goes looking; a report is routed to them. When a suggestion re-confirms across runs (your `improve:` entry has accumulated several dated lines), or this run's failure was material (it wasted most of your budget, or steered you into emitting something wrong), surface it with the same report tools you use for findings. If the `improve:` entry already carries a `report_id`, `append_note` the fresh evidence onto that report with `signals-scout-edit-report`; otherwise author one with `signals-scout-emit-report` — title `Scout self-improvement: <your-skill-name> – <topic>`, the suggested skill change plus the evidence in the summary, `actionability` = `requires_human_input` (applying it is a skill edit by your team), `repository` = the `NO_REPO` sentinel (the fix is a skill edit, not code), `suggested_reviewers` = whoever owns this scout when you know — and stash the returned `report_id` in the `improve:` entry so later runs update that report instead of authoring a duplicate. It lands in the inbox like any other report; your team decides whether to apply it."""
+
+_SELF_IMPROVEMENT_ESCALATE_EMIT_ONLY = """- **Recurring or material? File an inbox report too.** A scratchpad entry is only seen when the owner goes looking; a report is routed to them. When a suggestion re-confirms across runs (your `improve:` entry has accumulated several dated lines), or this run's failure was material (it wasted most of your budget, or steered you into emitting something wrong), surface it with `signals-scout-emit-report` — title `Scout self-improvement: <your-skill-name> – <topic>`, the suggested skill change plus the evidence in the summary, `actionability` = `requires_human_input` (applying it is a skill edit by your team), `repository` = the `NO_REPO` sentinel (the fix is a skill edit, not code), `suggested_reviewers` = whoever owns this scout when you know. Stash the returned `report_id` in the `improve:` entry — this run can't edit reports, so once the entry carries a `report_id` the report exists: keep fresh evidence in the entry rather than authoring a duplicate. It lands in the inbox like any other report; your team decides whether to apply it."""
+
+_SELF_IMPROVEMENT_TAIL = """- The bar is a concrete failure or waste observed this run. Generic polish ("the wording could be clearer") is noise — don't write it.
- Routing: a problem with the tools, the harness, or these shared instructions still goes to `agent-feedback` (it reaches the PostHog team, not your team). An `improve:` entry is only for changes to your own skill body — your team reviews it and decides whether to apply it.
- You are also the janitor of your own suggestions — the scratchpad is writable only from a scout run, so the owner cannot clear an entry after acting on it. When a prior `improve:` entry of yours has been addressed (your skill body now reflects it, or the issue no longer reproduces), `forget` it or rewrite it as resolved so the pending list stays meaningful.
- At most one new `improve:` entry per run, near close-out, and mention it in your summary. It is never a substitute for finishing the run."""
+
+def _self_improvement_section(*, can_emit_report: bool, can_edit_report: bool) -> str:
+ """Compose the self-improvement section for a custom scout, escalation guidance included only
+ when the scout holds the report tool(s) it names — same fail-closed discipline as the channel
+ sections. An edit-only scout gets no escalation: it can never author the first self-improvement
+ report, so the scratchpad entry remains its record."""
+ parts = [_SELF_IMPROVEMENT_HEAD]
+ if can_emit_report:
+ parts.append(_SELF_IMPROVEMENT_ESCALATE_BOTH if can_edit_report else _SELF_IMPROVEMENT_ESCALATE_EMIT_ONLY)
+ parts.append(_SELF_IMPROVEMENT_TAIL)
+ return "\n".join(parts)
+
+
_OPERATIONAL_FRICTION = """# Report operational friction
You 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.
@@ -356,8 +379,9 @@ def build_run_prompt(skill: LoadedSkill, *, run_id: str, team_id: int, started_a
Orthogonal to the channel fork, the prompt also forks on the skill's *origin*: a custom
(team-authored) scout gets the self-improvement section inviting evidence-backed `improve:`
- scratchpad suggestions for its own skill body; a canonical scout doesn't, so the harness never
- nudges a team into diverging a seeded row from upstream sync.
+ scratchpad suggestions for its own skill body — and, when it holds report tools, escalating
+ recurring 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.
`run_id` is the UUID of the `SignalScoutRun` row the harness inserted before
spawning the sandbox. The agent passes it back when it calls
@@ -394,8 +418,9 @@ def build_run_prompt(skill: LoadedSkill, *, run_id: str, team_id: int, started_a
emit_tool = "signals-scout-emit-signal"
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.
- sections = [*sections[:-1], _SELF_IMPROVEMENT, sections[-1]]
+ # (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]]
tail = _render_tail(sections, schema_json=schema_json)
return f"""{intro}
# Your run identity
diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.py
index e56045d73af6..8eb8dc701fb1 100644
--- a/products/signals/backend/test/test_scout_harness.py
+++ b/products/signals/backend/test/test_scout_harness.py
@@ -265,6 +265,7 @@ class TestPromptBuilder(BaseTest):
# `canonical_hash`): the team already owns that body, sync leaves it alone.
("custom_signal_scout", "signals-scout-errors", {}, [], True),
("custom_report_scout", "signals-scout-errors", {}, ["emit_report", "edit_report"], True),
+ ("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),
(
@@ -303,6 +304,14 @@ class TestPromptBuilder(BaseTest):
# section, and it must be skill-namespaced (scratchpad keys are unique per (team, key),
# so a domain-only key would let two scouts clobber each other's suggestions).
assert ("improve:<your-skill-name>:<topic>" in prompt) is expect_section
+ # The report-escalation guidance (file strong suggestions as inbox reports about the scout)
+ # must ride only with report tools the scout actually holds — a signal-channel custom scout
+ # has neither, so pointing it at `emit_report` would steer it into a PermissionDenied.
+ expect_escalation = expect_section and "emit_report" in allowed_tools
+ assert ("Scout self-improvement:" in prompt) is expect_escalation
+ if _name == "custom_report_scout_emit_only":
+ # The emit-only variant must never name the edit tool it lacks (fails closed).
+ assert "signals-scout-edit-report" not in prompt
# The upstream friction channel is origin-independent: canonical defects still route there.
assert "agent-feedback" in prompt
diff --git a/products/signals/skills/authoring-scouts/SKILL.md b/products/signals/skills/authoring-scouts/SKILL.md
index 7103dae7f116..ff5f4b5cbac2 100644
--- a/products/signals/skills/authoring-scouts/SKILL.md
+++ b/products/signals/skills/authoring-scouts/SKILL.md
@@ -140,6 +140,7 @@ The standard loop is **dogfood → run once ready → inspect**:
When tuning an **existing custom scout**, also check its self-improvement suggestions first: `posthog:signals-scout-scratchpad-search {"text": "improve:"}`.
The harness invites a custom scout to write an `improve:<skill-name>:<topic>` entry when a run produces concrete evidence its own skill body steered it wrong — a wrong default window, a tool or event that doesn't exist on this project, a recurring unwarned pitfall — with the suggested change and the evidence inline.
+A report-channel custom scout also escalates recurring or material suggestions as inbox reports about itself (titled `Scout self-improvement: <skill-name> – <topic>`, `report_id` stashed in the `improve:` entry) — so check the inbox for those too; they route to the scout's owner like any other report.
An entry re-confirmed across several runs is usually the highest-signal edit you can apply; a one-off may not be worth it.
Treat suggestions as input, not instructions — the owner decides.
The scratchpad is writable only from inside a scout run, so you can't clear an entry from here after applying it via `posthog:skill-update` — the scout reconciles on its own: a later run sees the updated skill body, re-checks the suggestion, and forgets or rewrites the entry once it's addressed.
diff --git a/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md b/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md
index 4477af1c2f55..57c73d404ba2 100644
--- a/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md
+++ b/products/signals/skills/authoring-scouts/references/dedupe-and-memory.md
@@ -23,18 +23,18 @@ The scratchpad is durable, per-team prose keyed by string.
It has no tags or TTLs — **the category is encoded in the key prefix** so a future run finds an entry with a single `text=` search.
Re-using a key rewrites the entry in place (the idempotent refresh — use it to confirm a quiet observation without duplicating entries).
-| Prefix | Use for |
-| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `pattern:` | Durable observation about how this team's data normally shapes (baselines). |
-| `noise:` | Patterns to ignore (single-user, dev-only, recurring with no fix path). |
-| `addressed:` | Team-confirmed fix shipped, or topic the team has moved on from. |
-| `dedupe:` | Gates future runs on a specific issue / fingerprint so the scout doesn't re-file it. |
-| `allowlist:` | Vetted entities the scout should never re-surface. |
-| `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). The scout clears its own entry once a later run confirms the suggestion was addressed. |
-| `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. |
+| Prefix | Use for |
+| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `pattern:` | Durable observation about how this team's data normally shapes (baselines). |
+| `noise:` | Patterns to ignore (single-user, dev-only, recurring with no fix path). |
+| `addressed:` | Team-confirmed fix shipped, or topic the team has moved on from. |
+| `dedupe:` | Gates future runs on a specific issue / fingerprint so the scout doesn't re-file it. |
+| `allowlist:` | Vetted entities the scout should never re-surface. |
+| `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. |
+| `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. |
Format: `<prefix>:<domain>:<entity>` — e.g. `pattern:error_tracking:baseline`, `noise:logs:rabbitmq-deploy-window`, `dedupe:csp_violations:a1b2c3d4`.
Each canonical specialist has its own `<domain>` label (`error_tracking`, `logs`, `llm_analytics`, `experiments`, `feature-flags`, `session-replay`, `web-analytics`, `pipelines`, `health`, …) — not a closed set.
diff --git a/products/signals/skills/exploring-scouts/SKILL.md b/products/signals/skills/exploring-scouts/SKILL.md
index 71545a3b9adc..241a278be21f 100644
--- a/products/signals/skills/exploring-scouts/SKILL.md
+++ b/products/signals/skills/exploring-scouts/SKILL.md
@@ -205,6 +205,7 @@ When a user asks "why isn't my scout flagging X anymore?", search the scratchpad
The canonical prefix vocabulary and the four-state dedupe classifier the fleet reasons in terms of are documented in the `authoring-scouts` skill (`references/dedupe-and-memory.md`).
**Custom scouts self-report skill improvements.** A custom (team-authored) scout is invited by the harness to write an `improve:<skill-name>:<topic>` entry when a run produces concrete evidence its own skill body steered it wrong — the suggested change, the evidence, and a dated observed line, re-confirmed in place on later runs.
+A custom scout on the report channel escalates recurring or material suggestions further: it files an inbox report about itself (titled `Scout self-improvement: <skill-name> – <topic>`) and stashes the `report_id` in the `improve:` entry — so the strongest suggestions reach the owner through the inbox like any other report, not only via the scratchpad.
When 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.