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): tell scouts to hyperlink the PostHog ids they reference (#82153)

Radu Raicea53e8615d876c
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.md
index 31f0e6b2130a..543d5cf24626 100644
--- a/products/signals/backend/scout_harness/AGENTS.md
+++ b/products/signals/backend/scout_harness/AGENTS.md
@@ -11,7 +11,7 @@ In production it is driven by `SignalsScoutCoordinatorWorkflow` (periodic tick e
- `runner.py`
Per-run entrypoint (`arun_signals_scout` / `run_signals_scout`). Inserts the `SignalScoutRun` row, builds the prompt + toolset, spawns the sandbox session, pumps the agent loop until budget exhaustion or natural completion, finalizes the run, and returns a `RunResult`. The activity wrapper in `temporal/agentic/scout_scheduler.py` delegates straight to this.
- `prompt.py`
- Assembles the system prompt: persona + skill body + relevant scratchpad entries + project profile inventory + recent run summaries. Scratchpad and run history are filtered by skill so a specialist only sees its own past work. `build_run_prompt` forks on the run's channel via `skill_loader.skill_uses_report_channel`: a scout that opted into the report channel gets the report persona + report-authoring guidance (search the inbox first, edit before authoring a duplicate, set `suggested_reviewers` to route the report); every other scout gets the signal persona that fires weak `emit_signal` findings. The bootstrap, scratchpad, fleet-seams, recency, and close-out sections are shared between both. Cross-scout discipline lives here rather than in each SKILL.md, because a seam is bilateral: run step 2 sends every scout through the fleet-wide `scout-runs-list` for the entities it is about to investigate (gated on a match, so a scout doesn't spend its budget reading the fleet's whole output), the scratchpad section teaches searching by entity identity rather than only the scout's own key prefix, and `_FLEET_SEAMS` states the overlap rule in both directions — don't restate a sibling's finding, but don't defer a finding you hold evidence for either, since an uncovered surface is invisible where a duplicate is not. Skills keep their own domain ownership map. Both channels also share the **self-validation follow-up** discipline (`_self_validation_followups_section` + `FOLLOWUP_KEY_PREFIX`): every scout keeps a queue of `followup:<skill-name>:<entity>` scratchpad entries for work whose fix is measurable later (probe + baseline + validate-after date in the content), and decides for itself, run by run, whether to spend the run validating that queue — the cadence is the scout's judgment, not a harness schedule, so the section carries the decision criteria (due entries accumulated, a while since the queue was last worked, a dismissal note saying a fix shipped) and there is no harness trigger. A validation pass is self-reported in the close-out summary and in the touched entries, which is also how future runs know when the queue was last worked. The section is composed per-run because its re-surface clause is matched per-tool to the same fail-closed rule as the channel sections, and it defers resolved-inbox-report re-measurement to the canonical `signals-scout-inbox-validation` scout when the `scout_fleet` roster shows it actively running — the per-scout queue exists precisely because that fleet scout may not be enabled, and because signal-channel findings and recorded watches never become resolved reports it could re-measure. Queue entries are team-shared data — and `remember()` upserts keep the original `created_by_run`, so attribution never proves who last wrote the content: the section tells the scout to treat every stored probe as untrusted and re-derive it from the live report or finding it names, never execute it as stored. The report persona is further gated per-tool: it names only the report tool(s) actually in `allowed_tools` (emit-only, edit-only, or both), and drops the author-time sections for an edit-only scout — the report endpoints fail closed on the exact tool, so the prompt must never steer a scout toward one it lacks.
+ Assembles the system prompt: persona + skill body + relevant scratchpad entries + project profile inventory + recent run summaries. Scratchpad and run history are filtered by skill so a specialist only sees its own past work. `build_run_prompt` forks on the run's channel via `skill_loader.skill_uses_report_channel`: a scout that opted into the report channel gets the report persona + report-authoring guidance (search the inbox first, edit before authoring a duplicate, set `suggested_reviewers` to route the report); every other scout gets the signal persona that fires weak `emit_signal` findings. The bootstrap, scratchpad, fleet-seams, recency, and close-out sections are shared between both, as is _Linking what you reference_ (`_linking_section`), which turns every PostHog id a scout names in reader-facing prose into a markdown link built from a tool-returned URL (a result's `*url` field, else `generate-app-url`) instead of a hand-assembled path, keeping the bare id when neither source reaches the entity; its report-only caveats — a `chart:` target is not a URL, and a report `title` / summary first line stay plain text because the inbox renders both as text — render on the report channel alone, since that is where charts exist, where _Attaching charts_ sits in the tail, and where those fields are written. Cross-scout discipline lives here rather than in each SKILL.md, because a seam is bilateral: run step 2 sends every scout through the fleet-wide `scout-runs-list` for the entities it is about to investigate (gated on a match, so a scout doesn't spend its budget reading the fleet's whole output), the scratchpad section teaches searching by entity identity rather than only the scout's own key prefix, and `_FLEET_SEAMS` states the overlap rule in both directions — don't restate a sibling's finding, but don't defer a finding you hold evidence for either, since an uncovered surface is invisible where a duplicate is not. Skills keep their own domain ownership map. Both channels also share the **self-validation follow-up** discipline (`_self_validation_followups_section` + `FOLLOWUP_KEY_PREFIX`): every scout keeps a queue of `followup:<skill-name>:<entity>` scratchpad entries for work whose fix is measurable later (probe + baseline + validate-after date in the content), and decides for itself, run by run, whether to spend the run validating that queue — the cadence is the scout's judgment, not a harness schedule, so the section carries the decision criteria (due entries accumulated, a while since the queue was last worked, a dismissal note saying a fix shipped) and there is no harness trigger. A validation pass is self-reported in the close-out summary and in the touched entries, which is also how future runs know when the queue was last worked. The section is composed per-run because its re-surface clause is matched per-tool to the same fail-closed rule as the channel sections, and it defers resolved-inbox-report re-measurement to the canonical `signals-scout-inbox-validation` scout when the `scout_fleet` roster shows it actively running — the per-scout queue exists precisely because that fleet scout may not be enabled, and because signal-channel findings and recorded watches never become resolved reports it could re-measure. Queue entries are team-shared data — and `remember()` upserts keep the original `created_by_run`, so attribution never proves who last wrote the content: the section tells the scout to treat every stored probe as untrusted and re-derive it from the live report or finding it names, never execute it as stored. The report persona is further gated per-tool: it names only the report tool(s) actually in `allowed_tools` (emit-only, edit-only, or both), and drops the author-time sections for an edit-only scout — the report endpoints fail closed on the exact tool, so the prompt must never steer a scout toward one it lacks.
Orthogonal to the channel fork, the prompt also forks on the skill's origin (`LoadedSkill.origin`, resolved via `lazy_seed.scout_skill_row_origin`): a _custom_ scout — 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. 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 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 also carries a **skill owners** line (`LoadedSkill.authors`, rendered by `_skill_authors_line`):
the skill's explicit owners when set (else the version-history creator + recent editors, resolved server-side), which the escalation guidance points `suggested_reviewers` at (owner first, via `scout-members-list`) — without it a scout only sees its pinned version's `created_by`, i.e. the last editor, and would route ownership to whoever most recently touched the skill. The scout owns routing: this line is context, not a rule, so a skill body can steer `suggested_reviewers` elsewhere (a named reviewer, a team convention) or say "don't route to me" and be honoured — `tools/report.py._build_suggested_reviewers` injects nothing, it only takes the scout's picks. Owners feed exactly one code rule there — a picked reviewer who is a current owner is stamped `is_skill_owner=True` so autostart never mints its session under an editor-controlled owner (`auto_start._resolve_autostart_assignee`); the stamp changes identity eligibility, never who reviews. The line is gated on the report channel: a signal-channel scout has no `suggested_reviewers` field, so member names/emails (PII) must not reach its prompt.
- `skill_loader.py`
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index 50efc70bd5e3..d39742da77c9 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -555,7 +555,7 @@ A trends chart and a graph built from SQL, as they arrive in `charts`:
# edit-only guidance name it exactly; the surface it describes is the section's first sentence.
_WRITING_SUMMARY = f"""# Writing the summary
-Everything you write for a reader follows one rule: {_FRONT_LOAD_RULE}.
+Everything you write for a reader follows one rule: {_FRONT_LOAD_RULE}. Whatever you name by id, link it, per *Linking what you reference*.
Your close-out `summary` renders in the scout's run history **collapsed to the first ~2 lines** until expanded, so applied here that means one or two sentences stating the outcome (what was found, with the key number, or that the run was quiet), a blank line, then two to five short bullets for what you checked, what you skipped and why, and what you wrote to memory.
@@ -693,6 +693,30 @@ You run this tooling end to end on a schedule, so your experience is how PostHog
- **At most one submission per run, near close-out, mentioned in your summary.** This is a side report to the PostHog team, never a way to end your turn or skip work: finish the run (emit / remember / summary) exactly as you would otherwise.
- Never put customer PII or sensitive query content in a feedback field."""
+_LINKING_HEAD = """# Linking what you reference
+
+A bare id leaves the reader copying a string and guessing which page it belongs to, so every PostHog entity you name in something a person reads (a finding `description`, a report `summary`, an evidence `description`, your close-out summary, a scratchpad entry) carries a markdown link, `[Checkout funnel](<url>)`, whose URL came from a tool rather than from your own assembly. Link an entity on first mention rather than every time, and link what a reader would open (an insight, dashboard, session recording, feature flag, experiment, error issue, survey, person, notebook), not every id that passed through a tool result.
+
+- **Take the link off the tool result when it has one.** A result carrying a `*url` field (`_posthogUrl` and friends) already holds the canonical link, so surface it verbatim rather than rewriting or stripping it.
+- **Otherwise call `generate-app-url`** and use the `url` it returns verbatim. Never assemble a path around an id you retyped: a wrong slug reads as a working link and drops the reader on a 404.
+- **When neither source reaches the entity itself, keep the bare id.** Some entities have no detail page in the URL catalog (an insight alert, for one: `alert-get` returns its url, the catalog has only the `/alerts` list). Don't substitute a link to the list page the entity sits on, which reads as a link to the thing and drops the reader somewhere they still have to search.
+- **Full URLs only** (origin plus path), because a bare path is not clickable in the inbox or in Slack. Take the origin from the link the tool returned rather than from memory, since this project may not sit on the host you assume, and never include `/-/`.
+- **The anchor text names the entity**, so the sentence still reads without the URL. Keep the id itself in the prose or a `code` span wherever a reader may need to paste it into a query."""
+
+# Both caveats are report-channel-only concerns. Charts render on the report channel alone, so the
+# collision the first warns about (writing a real URL where a `chart:` target belongs, or the
+# reverse) can only happen there, and *Attaching charts* is in that tail alone, so naming it from
+# the signal channel would dangle. The second names report fields (`title`, the report `summary`)
+# the signal channel never writes.
+_LINKING_REPORT_CLAUSES = """
+- **A `chart:` target is not a URL.** `[Daily signups](chart:signups-drop)` places a chart (see *Attaching charts*); swapping in a link draws nothing, and pointing a `chart:` target at a page the reader could open is a broken chart reference instead.
+- **A report `title` and the first line of its `summary` stay plain text.** The inbox renders the title as text and lifts the summary's first line out verbatim as the card headline, so a markdown link in either shows up as literal brackets beside a raw URL. Name the entity in words there, and link it where the body picks it up again."""
+
+
+def _linking_section(*, report_channel: bool) -> str:
+ return f"{_LINKING_HEAD}{_LINKING_REPORT_CLAUSES}" if report_channel else _LINKING_HEAD
+
+
_WRITING_STYLE = """# Writing style
- We use American English and the Oxford comma.
@@ -735,6 +759,7 @@ def _signal_tail_sections(
_FINDING_SCHEMA,
_TAGGING,
_WRITING_DESCRIPTION_SIGNAL,
+ _linking_section(report_channel=False),
_WRITING_STYLE,
_WRITING_SUMMARY,
_BUSINESS_KNOWLEDGE,
@@ -806,6 +831,7 @@ def _report_tail_sections(
_RECENCY_LENS,
*([structured_output_section] if structured_output_section else []),
*channel_sections,
+ _linking_section(report_channel=True),
_WRITING_STYLE,
_WRITING_SUMMARY,
_BUSINESS_KNOWLEDGE,
diff --git a/products/signals/skills/authoring-scouts/references/report-contract.md b/products/signals/skills/authoring-scouts/references/report-contract.md
index ccf2cc2847d0..945efb13d9e4 100644
--- a/products/signals/skills/authoring-scouts/references/report-contract.md
+++ b/products/signals/skills/authoring-scouts/references/report-contract.md
@@ -27,16 +27,23 @@ A weak or partial observation belongs in the scratchpad, where a future run (wit
Judges the report for safety, then persists it at the judged status.
-| Field | Type | Notes |
-| --------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| `run_id` | string, required | The current run's id — the run you're executing in, same as every `scout-*` tool. |
-| `title` | string, ≤300, non-empty | The inbox headline. One specific, quantified line. |
-| `summary` | string | The report body prose — one tight passage a busy human can act on: a **quantified hook** (what's happening, with numbers), the **pattern** that makes it signal rather than noise, the suspected-cause **hypothesis**, and the **recommendation**. Cite entity ids inline so the reader pivots straight to source. |
-| `evidence` | list, 1–50 | Each `{description, source_id}`. Becomes a bound signal row backing the report. `source_id` is the citable entity id. Hard cap of **50** — summarize/trim before calling; a longer list fails validation before the report is judged or persisted. |
-| `actionability_explanation` | string | One sentence justifying the actionability call below. |
-| `actionability` | enum | `immediately_actionable` / `requires_human_input` / `not_actionable`. You make this call — the channel does not re-research it. |
-| `already_addressed` | bool, default `false` | Set when the underlying issue is already handled and you're filing for the record. |
-| `charts` | list, ≤20, optional | Queries the inbox draws on the report — the report's full set, replacing any it already had. Each `{chart_id, title, query, caption?, size?}`. See _Attaching charts_ below. |
+| Field | Type | Notes |
+| --------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `run_id` | string, required | The current run's id — the run you're executing in, same as every `scout-*` tool. |
+| `title` | string, ≤300, non-empty | The inbox headline. One specific, quantified line. |
+| `summary` | string | The report body prose — one tight passage a busy human can act on: a **quantified hook** (what's happening, with numbers), the **pattern** that makes it signal rather than noise, the suspected-cause **hypothesis**, and the **recommendation**. Cite entities inline as markdown links so the reader pivots straight to source (see below). |
+| `evidence` | list, 1–50 | Each `{description, source_id}`. Becomes a bound signal row backing the report. `source_id` is the citable entity id. Hard cap of **50** — summarize/trim before calling; a longer list fails validation before the report is judged or persisted. |
+| `actionability_explanation` | string | One sentence justifying the actionability call below. |
+| `actionability` | enum | `immediately_actionable` / `requires_human_input` / `not_actionable`. You make this call — the channel does not re-research it. |
+| `already_addressed` | bool, default `false` | Set when the underlying issue is already handled and you're filing for the record. |
+| `charts` | list, ≤20, optional | Queries the inbox draws on the report — the report's full set, replacing any it already had. Each `{chart_id, title, query, caption?, size?}`. See _Attaching charts_ below. |
+
+**Cite each entity as a link, not a bare id.** In `summary` and in `evidence` descriptions, write
+the entity you name as a markdown link: reuse the url the returning tool attached (`_posthogUrl`
+and friends), else build one with `generate-app-url`, and keep the bare id when neither reaches
+the entity itself. Two spots stay plain text, because the inbox renders them as text: `title`, and
+the summary's first line, which the inbox lifts out as the card headline. The harness prompt
+(_Linking what you reference_) carries the full rule.
**Status is decided for you, from safety × actionability:**
diff --git a/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md b/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md
index 5691baa6ff39..13cddbb99376 100644
--- a/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md
+++ b/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md
@@ -79,8 +79,12 @@ characters behind a "Show more" toggle. Front-load, structure, no walls:
5. **Recommendation** — a closing `Recommend: …` line naming the next action (which insight to
open, what to check).
-Cite the insight `short_id` and dashboard id inline so a human pivots straight to the source,
-and close with the notebook URL: "Full write-up with charts: `<notebook-url>`."
+Cite the insight and dashboard inline as markdown links so a human pivots straight to the
+source, and close by linking the notebook: "Full write-up with charts: [notebook](url)."
+The harness prompt (_Linking what you reference_) carries the link rule: reuse the url the
+returning tool attached (`notebooks-create` returns the notebook's), else `generate-app-url`.
+Keep the title and the summary's first line plain text, because the inbox renders both as
+text: a link there shows up as literal markdown.
### Charts on the report
@@ -286,27 +290,33 @@ repository: NO_REPO
evidence:
- source_id: 9aBcDeF
description: >
- 'Daily signups' (insight 9aBcDeF on dashboard Growth/41233): yesterday 412 vs 8-same-weekday
- median 1,048 (MAD 95) → robust z = 4.8. Prior 7 same-weekdays all within ±1.5 z. Latest
- complete day only; today's partial bucket excluded.
+ [Daily signups](https://us.posthog.com/project/41233/insights/9aBcDeF), on the
+ [Growth dashboard](https://us.posthog.com/project/41233/dashboard/8123): yesterday 412 vs
+ 8-same-weekday median 1,048 (MAD 95) → robust z = 4.8. Prior 7 same-weekdays all within
+ ±1.5 z. Latest complete day only; today's partial bucket excluded.
- source_id: aB12cD34
description: >
- Write-up with the -63d chart, the per-weekday baseline, and the segment attribution:
- https://us.posthog.com/project/41233/notebooks/aB12cD34
+ [Write-up](https://us.posthog.com/project/41233/notebooks/aB12cD34) with the -63d chart,
+ the per-weekday baseline, and the segment attribution.
summary: |
- Daily signups dropped to 412 yesterday (2026-06-06) against an ~1,048 same-weekday baseline
- (robust z = 4.8, MAD 95) on insight 9aBcDeF, pinned to the Growth dashboard (41233).
+ Daily signups dropped to 412 yesterday (2026-06-06) against an ~1,048 same-weekday baseline (robust z = 4.8, MAD 95).
+ The scored series is [Daily signups](https://us.posthog.com/project/41233/insights/9aBcDeF),
+ pinned to the [Growth dashboard](https://us.posthog.com/project/41233/dashboard/8123).
**Pattern** — a single complete-day drop of ~60%, well outside the weekday rhythm: the last 8
same weekdays were all within ±1.5 z, so it's not seasonality, and it's not a pipeline gap (other
insights are unaffected at the same timestamp).
**Hypothesis** — likely a broken signup flow or a tracking regression from a recent deploy.
- Recommend: open insight 9aBcDeF, check whether the drop is broad or segment-specific, and
- correlate with today's deploys. Full write-up with charts:
- https://us.posthog.com/project/41233/notebooks/aB12cD34.
+ Recommend: open the insight, check whether the drop is broad or segment-specific, and correlate
+ with today's deploys. Full write-up with charts:
+ [notebook](https://us.posthog.com/project/41233/notebooks/aB12cD34).
```
-Why it's good: quantified title and hook with the baseline and z, seasonality and pipeline-gap
-explicitly ruled out, partial bucket excluded, actionable recommendation, the notebook cited in
-evidence and linked from the summary, `requires_human_input` (a human decides the fix) with P1
-justified by business impact, and a reviewer set so it routes to an owner.
+(Example urls are what the fixture project's tools returned; take yours from a tool result or
+`generate-app-url`, never from this file.)
+
+Why it's good: quantified title and hook with the baseline and z, a plain-text headline line with
+every entity linked in the body below it, seasonality and pipeline-gap explicitly ruled out,
+partial bucket excluded, actionable recommendation, the notebook cited in evidence and linked from
+the summary, `requires_human_input` (a human decides the fix) with P1 justified by business
+impact, and a reviewer set so it routes to an owner.