: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): frame report scouts' report: key as an inbox pointer (#66629)
Andrew Maguireb499a343e977
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.pyindex 4ae02be0fa9f..cf12db4959bf 100644--- a/products/signals/backend/scout_harness/prompt.py+++ b/products/signals/backend/scout_harness/prompt.py@@ -246,9 +246,9 @@ main failure mode here, so the discipline is **search, then decide**:- **Search first, every time.** Before authoring anything, call`inbox-reports-list` (filter/search by the entity, error, or topic you're about- to report on) and read the closest matches with `inbox-reports-retrieve`. Keep a- `report:<domain>:<entity>` scratchpad entry per report you author so future runs- find it even when the inbox phrasing has drifted.+ to report on) and read the closest matches with `inbox-reports-retrieve` — plus+ your `report:<domain>:<entity>` scratchpad pointer from a prior run (see *The+ `report:` scratchpad entry is a pointer*).- **Edit when it already exists.** If a report covers the issue, prefer`signals-scout-edit-report`: `append_note` to add your fresh evidence (additive,audit-friendly, and works on any report — even one you didn't author), or@@ -268,9 +268,9 @@ main failure mode here, so the discipline is **search, then decide**:- **Search first, every time.** Before authoring anything, call`inbox-reports-list` (filter/search by the entity, error, or topic you're about- to report on) and read the closest matches with `inbox-reports-retrieve`. Keep a- `report:<domain>:<entity>` scratchpad entry per report you author so future runs- find it even when the inbox phrasing has drifted.+ to report on) and read the closest matches with `inbox-reports-retrieve` — plus+ your `report:<domain>:<entity>` scratchpad pointer from a prior run (see *The+ `report:` scratchpad entry is a pointer*).- **Don't duplicate an existing report.** This run can't edit reports, so if onealready covers the issue, leave it alone — record a `remember(...)` note andskip rather than authoring a near-duplicate.@@ -296,6 +296,28 @@ report your evidence bears on, then keep it current:`append_note` appends a second note. If unsure whether an edit landed, re-readthe report rather than re-sending."""+_REPORT_SCRATCHPAD_POINTER = """# The `report:` scratchpad entry is a pointer, not a copy++After you author or edit a report, stash its `report_id` under a stable+`report:<domain>:<entity>` scratchpad key — in the same namespace as your other+scratchpad keys, so your step-1 `scratchpad-search` surfaces it. It is the cheap way+to re-find *your* report next run, keyed on the entity rather than on inbox phrasing.++Treat it as an **index into the inbox, never a copy of the report**:++- **The inbox is the source of truth.** The entry holds an id, not the report's+ state. Always `inbox-reports-retrieve` the live report before you edit it — its+ `title`, `summary`, and `status` may have moved since you wrote the pointer.+- **The pipeline can overwrite what you authored.** When later signals consolidate on+ the same topic, the pipeline may re-research your report and rewrite its `title` /+ `summary`. That's expected — your durable record of "I filed this" is the `report_id`+ in the pointer, so re-find by the pointer (or by entity via `inbox-reports-list`),+ not by remembering the exact title.+- **Don't copy report content into the pointer.** Keep it to the `report_id` plus the+ minimum to recognize the entity. Title, body, and status live in the inbox — read+ them there, fresh, rather than trusting a stale snapshot."""++_SUGGESTED_REVIEWERS_REPORT = """# Suggested reviewers route the reportThis is the single highest-leverage field you set. `suggested_reviewers` (a list of@@ -443,13 +465,23 @@ def _report_tail_sections(*, can_emit: bool, can_edit: bool) -> list[str]:author-time sections (suggested reviewers, writing a report) only when the scout can author."""if can_emit and can_edit:how_a_run_works = f"{_HOW_A_RUN_WORKS_HEAD}\n{_REPORT_STEPS_BOTH}\n{_REPORT_CLOSE_OUT_STEP}"- channel_sections = [_AUTHORING_VS_EDITING_REPORT_BOTH, _SUGGESTED_REVIEWERS_REPORT, _WRITING_REPORT]+ channel_sections = [+ _AUTHORING_VS_EDITING_REPORT_BOTH,+ _REPORT_SCRATCHPAD_POINTER,+ _SUGGESTED_REVIEWERS_REPORT,+ _WRITING_REPORT,+ ]elif can_emit:how_a_run_works = f"{_HOW_A_RUN_WORKS_HEAD}\n{_REPORT_STEPS_EMIT_ONLY}\n{_REPORT_CLOSE_OUT_STEP}"- channel_sections = [_AUTHORING_REPORT_EMIT_ONLY, _SUGGESTED_REVIEWERS_REPORT, _WRITING_REPORT]+ channel_sections = [+ _AUTHORING_REPORT_EMIT_ONLY,+ _REPORT_SCRATCHPAD_POINTER,+ _SUGGESTED_REVIEWERS_REPORT,+ _WRITING_REPORT,+ ]else: # edit-only — no authoring, so no suggested-reviewers / writing-a-report sectionshow_a_run_works = f"{_HOW_A_RUN_WORKS_HEAD}\n{_REPORT_STEPS_EDIT_ONLY}\n{_REPORT_CLOSE_OUT_STEP}"- channel_sections = [_EDITING_REPORT_EDIT_ONLY]+ channel_sections = [_EDITING_REPORT_EDIT_ONLY, _REPORT_SCRATCHPAD_POINTER]return [how_a_run_works,_SCRATCHPAD_KEYS,diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.pyindex ce5b29e8868d..1a534fb441d8 100644--- a/products/signals/backend/test/test_scout_harness.py+++ b/products/signals/backend/test/test_scout_harness.py@@ -189,6 +189,7 @@ class TestPromptBuilder(BaseTest):# signals, it does not author reports.assert "signals-scout-emit-report" not in promptassert "Suggested reviewers route the report" not in prompt+ assert "scratchpad entry is a pointer" not in promptdef test_report_channel_renders_report_persona_and_guidance(self) -> None:LLMSkill.objects.create(@@ -216,6 +217,12 @@ class TestPromptBuilder(BaseTest):assert "inbox-reports-list" in promptassert "Suggested reviewers route the report" in promptassert "suggested_reviewers" in prompt+ # The report channel teaches that the `report:` scratchpad entry is a pointer+ # into the inbox, not a copy of the report — the inbox stays the source of+ # truth, so the scout retrieves the live report before editing. Dropping this+ # discipline re-opens the duplicate / stale-edit failure mode.+ assert "scratchpad entry is a pointer" in prompt+ assert "source of truth" in prompt# Signal-only sections (weak-finding schema, tagging taxonomy) are dropped# for a report scout — it doesn't fire `emit_signal`.assert "signals-scout-emit-signal" not in prompt