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.

fix(signals): handle unavailable scout activity history (#106509)

posthog[bot]7e18c7961f79
diff --git a/docs/internal/activity-logging.md b/docs/internal/activity-logging.md
index 1f266b10bd48..1e21c5b4eb48 100644
--- a/docs/internal/activity-logging.md
+++ b/docs/internal/activity-logging.md
@@ -198,9 +198,18 @@ Explicit logging at a bulk-write site should read its before-values from the wri
- `GET /api/projects/:id/activity_log/` - the list the side panel reads.
- `GET /api/projects/:id/advanced_activity_logs/` - filters, field discovery, and export.
- Access control: resource `activity_log`, default level `viewer`.
-- Entitlement: the advanced endpoint is gated by `AvailableFeature.AUDIT_LOGS` and applies the entitlement's lookback window (`get_activity_log_lookback_restriction` in `posthog/models/activity_logging/retention.py`). The plain list the side panel reads is not gated the same way. Writes always happen.
+- Entitlement: both list endpoints are gated by `AvailableFeature.AUDIT_LOGS` on Cloud and apply the entitlement's lookback window (`get_activity_log_lookback_restriction` in `posthog/models/activity_logging/retention.py`). Writes always happen.
- `activity_visibility_restrictions` hides selected rows from non-staff users (login events of impersonated sessions).
+Scheduled scouts already carry `activity_log:read`. MCP hides `advanced-activity-logs-list` when the Cloud organization lacks the Audit Logs entitlement.
+MCP supplies bounded reader instructions only when its filtered catalog advertises `advanced-activity-logs-list`, and adds SQL instructions only when `execute-sql` is also advertised.
+Tools-mode clients receive these instructions inline. Exec clients receive them in the command reference; Claude web/desktop loads them from the analytics guide, with an inline fallback when guide loading is disabled.
+The universal scout skills carry only availability and stop guidance, so they do not send clients searching for readers they cannot access.
+The SQL table enforces the same entitlement, retention, and access controls; it is not a bypass.
+When a reader is unavailable, stop using that reader for the run and record the limitation. Other advertised, authorized readers remain usable: per-object endpoints such as feature-flag activity do not share the project-wide Audit Logs entitlement gate. Skip only checks that have no available reader.
+To audit scheduled scout writes, use the server-derived `scout:<skill_name>` client tag and the run window. The tag identifies a scout, not a run; inspect actors, items, and timestamps when runs overlap.
+Do not infer that no configuration change occurred from missing access.
+
A scene that wants its own paginated history registers its URL in `activityLogLogic.tsx`.
Most scenes do not need this; the side panel and deep links work without it.
diff --git a/products/signals/skills/signals-scout-ai-observability/SKILL.md b/products/signals/skills/signals-scout-ai-observability/SKILL.md
index 2900289c0fc3..f351335e648c 100644
--- a/products/signals/skills/signals-scout-ai-observability/SKILL.md
+++ b/products/signals/skills/signals-scout-ai-observability/SKILL.md
@@ -27,6 +27,12 @@ You are a focused AI observability scout. Spot meaningful changes in this team's
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a localized, validated regression you'd stand behind as a standalone inbox item a human will act on. A regression that's still moving (or recovering then relapsing) that the inbox already covers is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, and the edit rules); this body adds only the AI-observability-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: is AI observability even in use?
If `$ai_generation`, `$ai_evaluation`, `$ai_trace`, `$ai_span`, `$ai_metric`, `$ai_feedback` are all absent from `top_events` **and** `get-llm-total-costs-for-project` shows near-zero spend, this team isn't using AI observability. Write one scratchpad entry:
diff --git a/products/signals/skills/signals-scout-csp-violations/SKILL.md b/products/signals/skills/signals-scout-csp-violations/SKILL.md
index 982daadbfcab..4a16036be32c 100644
--- a/products/signals/skills/signals-scout-csp-violations/SKILL.md
+++ b/products/signals/skills/signals-scout-csp-violations/SKILL.md
@@ -26,6 +26,12 @@ CSP violations are unusual on the noise/signal spectrum: a single user with a mi
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for an aggregated cluster (a fresh blocked domain, a standing enforced block, a deploy-correlated directive burst) you'd stand behind as a standalone inbox item a human will act on. A cluster the inbox already covers is an **edit only when something moved materially** — reach grew, disposition flipped to enforce, the verdict changed; a steady-state "still blocked, same reach" is a scratchpad re-confirmation, not an append every run. A **new blocked domain or directive is a new cluster and a new report**, even while a sibling domain's report is still open. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, the `priority` / `repository` fields, and the edit rules), and `authoring-scouts` → `references/report-contract.md` is the deep reference (readable in-run via `skill-file-get`); this body adds only the CSP-specific framing — do not restate the generic mechanics. (Note: this surface has a companion **push** path that files raw per-fingerprint signals under `source_product=csp_reporting`; your own report-channel reports persist under `source_product=signals_scout`. Both live in the same inbox — see Decide for how they interact.)
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: is CSP reporting even active?
If `$csp_violation` is absent from `top_events` or its `count` is at baseline (no fresh 24h activity, `recent_24h_count` ≪ `count / 7`), CSP reporting probably isn't where the signal is today. Cheap scratchpad entry + close out:
diff --git a/products/signals/skills/signals-scout-data-pipelines/SKILL.md b/products/signals/skills/signals-scout-data-pipelines/SKILL.md
index 03996e6f2e57..4f659da974bc 100644
--- a/products/signals/skills/signals-scout-data-pipelines/SKILL.md
+++ b/products/signals/skills/signals-scout-data-pipelines/SKILL.md
@@ -28,6 +28,12 @@ You are a focused data pipelines scout. A pipeline is a promise that data flows
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a localized, validated delivery contradiction you'd stand behind as a standalone inbox item a human will act on. A contradiction the inbox already covers (a destination still watcher-disabled, a batch export still failing, a flow still erroring for its recipients) is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, and the edit rules); this body adds only the pipeline-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: are pipelines even in use?
Read `recent_hog_functions` and `recent_hog_flows` off `scout-project-profile-get`, and count exports with one cheap query:
diff --git a/products/signals/skills/signals-scout-data-warehouse/SKILL.md b/products/signals/skills/signals-scout-data-warehouse/SKILL.md
index b501f3de59c0..2e9d4312cf8f 100644
--- a/products/signals/skills/signals-scout-data-warehouse/SKILL.md
+++ b/products/signals/skills/signals-scout-data-warehouse/SKILL.md
@@ -28,6 +28,12 @@ You also own a second, lower-priority lane: **optimization opportunities**. Once
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a localized, validated import contradiction you'd stand behind as a standalone inbox item a human will act on. A gap the inbox already covers (a source still in Error, a schema still stale behind its cadence, a webhook channel still dead) is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, and the edit rules); this body adds only the warehouse-import-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: are imports even armed?
One SQL count over the schema metadata tells you whether imports are in play:
diff --git a/products/signals/skills/signals-scout-error-tracking/SKILL.md b/products/signals/skills/signals-scout-error-tracking/SKILL.md
index cee0485ab6ad..04a8dfacf3f8 100644
--- a/products/signals/skills/signals-scout-error-tracking/SKILL.md
+++ b/products/signals/skills/signals-scout-error-tracking/SKILL.md
@@ -25,6 +25,12 @@ The relationship between `count` and `distinct_users` on `$exception` is the mos
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a localized, validated issue you'd stand behind as a standalone inbox item a human will act on. An issue that's still firing (or resolved-then-relapsing) that the inbox already covers is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, the `priority` / `repository` fields, and the edit rules), and `authoring-scouts` → `references/report-contract.md` is the deep reference (readable in-run via `skill-file-get`); this body adds only the error-tracking-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: is error tracking even loud?
If `$exception` is absent from `top_events` or its `count` is at baseline (no fresh 24h activity, `recent_24h_count` ≪ `count / 7`), error tracking probably isn't where the signal is today. Cheap scratchpad entry + close out:
diff --git a/products/signals/skills/signals-scout-experiments/SKILL.md b/products/signals/skills/signals-scout-experiments/SKILL.md
index 039b4abf286b..30b90654432a 100644
--- a/products/signals/skills/signals-scout-experiments/SKILL.md
+++ b/products/signals/skills/signals-scout-experiments/SKILL.md
@@ -30,6 +30,12 @@ Validity findings are time-sensitive: every day an SRM goes unnoticed is a day o
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a localized, validated validity threat you'd stand behind as a standalone inbox item a human will act on. A threat the inbox already covers (an SRM that's still skewed, a stall that hasn't recovered, a zombie bundle that only grew) is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, and the edit rules); this body adds only the experiments-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: are experiments even active?
Read `recent_experiments` off `scout-project-profile-get`. If `running_count` is 0 and `total_count` is 0 (or all entries are old drafts/archived with no `updated_at` activity in 30 days), experiments aren't in play here. Write one scratchpad entry:
diff --git a/products/signals/skills/signals-scout-feature-flags/SKILL.md b/products/signals/skills/signals-scout-feature-flags/SKILL.md
index 79ed1233e1e2..2253c9bcc38a 100644
--- a/products/signals/skills/signals-scout-feature-flags/SKILL.md
+++ b/products/signals/skills/signals-scout-feature-flags/SKILL.md
@@ -32,6 +32,12 @@ One mechanical fact anchors everything: **deactivating a flag does not stop `$fe
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a localized, validated contradiction you'd stand behind as a standalone inbox item a human will act on. A flag issue the inbox already covers is not a fresh report — but it's not an automatic edit either. **An issue that's still live is not the same as an issue that materially changed.** Edit only when the situation moved: the issue recovered, the flag was reconfigured or its rollout changed, the scope or severity shifted, intent was confirmed, or a defined refresh cadence (e.g. daily) has elapsed. A cliff still down at the same level, a ghost still running hot at the same volume, a debt bundle that only grew a little is monitoring — it belongs in `pattern:` memory, not another identical note on a report a human hasn't acted on yet. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, and the edit rules); this body adds only the feature-flag-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: are flags even in use?
Read `recent_feature_flags` off `scout-project-profile-get`. Two caveats before shortcutting: `total_count` excludes deleted flags, and `top_events` is only the top 50 by volume — so confirm the traffic side with one cheap count rather than trusting either alone:
diff --git a/products/signals/skills/signals-scout-replay-vision/SKILL.md b/products/signals/skills/signals-scout-replay-vision/SKILL.md
index e776e65379fd..b4b634db4602 100644
--- a/products/signals/skills/signals-scout-replay-vision/SKILL.md
+++ b/products/signals/skills/signals-scout-replay-vision/SKILL.md
@@ -31,6 +31,12 @@ You are a focused Replay Vision scout. A **scanner** is a standing LLM probe a t
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a validated, cross-session shift you'd stand behind as a standalone inbox item. A shift on a scanner you've reported before that's still moving is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, the `priority` / `repository` fields, and the edit rules), and `authoring-scouts` → `references/report-contract.md` is the deep reference (readable in-run via `skill-file-get`); this body adds only the replay-vision-specific framing.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## The push/pull boundary (read first — it defines what you author)
Scanners can have `emits_signals: true`. Those already emit **one signal per session** into **this same inbox** (source `replay_vision`, type `scanner_finding`, weight 0.5 — they corroborate across sessions before a report promotes). That is the _push_ path. **You are the pull path.** Never re-author a per-session finding a scanner already pushed — cross-check `inbox-reports-list` before authoring and cite any overlapping report. The push path emits under the `replay_vision` source product, so filter on it; when it returns nothing, also scan recent reports unfiltered (and the `session_replay` source) and match on the scanner name and example `session_id`s, since a per-session finding can reach the inbox clustered under a neighboring surface. Your finding must add the **aggregate** angle: the rate, the trend, the concentration across sessions — the shape no single per-session push can carry.
diff --git a/products/signals/skills/signals-scout-session-replay/SKILL.md b/products/signals/skills/signals-scout-session-replay/SKILL.md
index 656f9375269d..05d5de591864 100644
--- a/products/signals/skills/signals-scout-session-replay/SKILL.md
+++ b/products/signals/skills/signals-scout-session-replay/SKILL.md
@@ -32,6 +32,12 @@ Two mechanical facts anchor everything. First, **recording capture is config-gat
You author reports directly via the report channel (`scout-emit-report` / `scout-edit-report`): you've done the research, so you own each report 1:1 end-to-end rather than firing weak signals for a pipeline to cluster. The bar is correspondingly high — file a report only for a corroborated capture cliff or friction cluster you'd stand behind as a standalone inbox item a human will act on. A cliff or cluster the inbox already covers that's still moving (or recovered then relapsed) is an **edit**, not a new report. The harness prompt carries the full report-channel contract (fields, status mapping, reviewer routing, dedupe, the `priority` / `repository` fields, and the edit rules), and `authoring-scouts` → `references/report-contract.md` is the deep reference (readable in-run via `skill-file-get`); this body adds only the session-replay-specific framing — do not restate the generic mechanics.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Replay SQL footguns (read first)
Four mechanical traps that produce silently-wrong results — every replay query in this skill is shaped around them:
diff --git a/products/signals/skills/signals-scout-surveys/SKILL.md b/products/signals/skills/signals-scout-surveys/SKILL.md
index 26f98304923a..2ddffeed5094 100644
--- a/products/signals/skills/signals-scout-surveys/SKILL.md
+++ b/products/signals/skills/signals-scout-surveys/SKILL.md
@@ -32,6 +32,12 @@ You author reports directly via the report channel (`scout-emit-report` / `scout
When in doubt, write a memory entry instead of filing a report. Surveys are personal data; the panic radius for a wrong "users hate feature X" report is high.
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: are surveys even active?
If `surveys-get-all` (with `archived: false`) returns an empty list **and** `surveys-global-stats` shows zero events in the last 30 days, surveys aren't active on this project. Write one scratchpad entry:
diff --git a/products/signals/skills/signals-scout-web-vitals/SKILL.md b/products/signals/skills/signals-scout-web-vitals/SKILL.md
index d7fbefa1b669..0ea99e2b9c59 100644
--- a/products/signals/skills/signals-scout-web-vitals/SKILL.md
+++ b/products/signals/skills/signals-scout-web-vitals/SKILL.md
@@ -86,6 +86,12 @@ substring(replaceRegexpAll(replaceRegexpAll(properties.$pathname, '[0-9]+', ':id
'[^0-9A-Za-z/_:.-]', ''), 1, 200) AS path
```
+## Activity-history availability
+
+Activity history is optional. Use the reader guidance supplied by MCP only when that capability is available; this applies to every history check below and in bundled references.
+
+If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+
## Quick close-out: is web vitals capture even on?
`$web_vitals` is opt-in (`capture_performance` in the SDK). Absence is **configuration,
diff --git a/products/signals/skills/working-with-scouts/SKILL.md b/products/signals/skills/working-with-scouts/SKILL.md
index bdf7b9cebb2a..d90f2aac90ca 100644
--- a/products/signals/skills/working-with-scouts/SKILL.md
+++ b/products/signals/skills/working-with-scouts/SKILL.md
@@ -112,19 +112,15 @@ Report triage mechanics live in `inbox-exploration`; what matters here is how ac
## Auditing what a scout changed
A scout that holds `write_scopes` (granted via `authoring-scouts`) changes real objects in the project, and each change lands in the project's **activity log** like any other edit.
-The row names the scout's **acting user**, the person whose identity the run mints its token as, and carries a small "via MCP" tag next to the timestamp.
-The row does not name the scout, the run, the skill, or the scopes it held.
-A scout editing a dashboard and the same person editing one from an MCP client produce identical rows.
-So auditing a run is a reconstruction from the run window, not a lookup by scout.
+The row names the scout's **acting user**, the person whose identity the run mints its token as, and carries the server-derived `scout:<skill_name>` client tag.
+The tag identifies the scout but not the run or the scopes it held.
+Auditing one run still requires its time window and a cross-check against its close-out.
To reconstruct one run's changes:
1. **Read the run** (`posthog:scout-runs-retrieve`) for `started_at`, `completed_at`, `metadata.write_scopes` (present only when the run actually held a grant), and the close-out `summary`. The run prompt asks a granted scout to name every object it changed.
-2. **Bracket the window** (`posthog:advanced-activity-logs-list`) with `start_date` and `end_date` around the run, `clients: ["mcp"]`, and `scopes` for the objects the grant covers.
- Raise `page_size`: the tool defaults to 10 rows and the endpoint takes up to 1000, so the default can hide most of a run behind one page.
- A non-null `next` means rows are missing, and the tool cannot send that cursor back, so page through with `page` instead, which also returns the total `count`.
-3. **Read the actor off the returned rows** instead of filtering by it up front. `users` takes user UUIDs, and the acting user is derived rather than configured (the scout skill's earliest known version author, then the config's `enabled_by`, then its `created_by`), so it is easier to confirm than to predict.
- The rows name the actor but carry no UUID, so resolve one from the email they show (`posthog:org-members-list`, which searches on name and email and needs `organization_member:read`), then add `users` to drop other people's rows.
+2. **Check history availability.** Follow the reader guidance supplied by MCP when activity history is available. If a reader is unavailable or access is denied, record that limitation and stop using that reader for the run; do not retry its discovery or probe endpoints to bypass the restriction. Other advertised, authorized readers, including per-object history, remain usable. Skip only checks that have no available reader.
+3. **Confirm attribution.** The run window can include the acting user's other writes. History that cannot distinguish those writes does not establish which changes the scout made.
4. **Cross-check against the close-out.** A row the summary does not mention, or a change the summary claims with no row behind it, is the thing to look at.
Which `scopes` value each granted scope writes under:
@@ -145,11 +141,8 @@ The scope-named objects themselves still log nothing: a skill body edit (includi
Four caveats change what the answer means:
-- **The window is not an attribution.** The same filter also catches the acting user's own MCP writes in that window, from Claude Code, Cursor, or any other MCP client. Narrow by scope and timestamp, then read the rows.
-- **The advanced log is gated twice.** `advanced-activity-logs-list` and `advanced-activity-logs-filters` need `activity_log:read` on the credential, and on PostHog Cloud they also need the organization's audit-logs entitlement. Self-hosted is never gated on it.
- Without the entitlement the MCP server drops both tools from the toolset rather than failing them, so they read as tools that do not exist; a call that still reaches the backend gets a 402 asking for a paid plan. Neither outcome means you built the filter wrong.
- With the entitlement, results are trimmed to the plan's lookback, so an older run can fall outside the window.
- The plain side-panel feed is gated on neither, but it is a weak substitute: it filters only by user, scope, and item, so it cannot isolate MCP writes. It still shows the "via MCP" tag, so on a short run window you can read an object's own feed and narrow by eye.
+- **The window is not an attribution.** Without a scout tag, the window can include the acting user's other writes. Even with a tag, overlapping runs of the same scout can share it. Compare actors, items, and timestamps with the close-out.
+- **History access is optional.** Permissions, the Cloud Audit Logs entitlement, and the plan's retention window can make history unavailable. Missing history does not establish that a run made no changes. Defer conclusions that depend on it and continue independent checks; a confirmed access restriction is not a missing-tool defect.
- **A dry run drops the grant, not the floor.** A scout on `emit: false` never holds the granted scopes, so it writes no rows under the scopes in the table above.
It keeps `notebook:write`, the floor write every scout holds, so a dry run can still create, edit, or delete a notebook.
Keep `Notebook` in the filter for a dry-run window.
@@ -228,5 +221,5 @@ Every few weeks (or when someone says "are the scouts even worth it?"), run a ca
| "The scouts are too noisy / too quiet" | Calibration pass above; then the steering ladder against the specific offender |
| "Write / edit / retune a scout" | `authoring-scouts` |
| "Why did the scout stop flagging X?" | Scratchpad first (`noise:` / `addressed:` / `dedupe:` / `allowlist:`), then notes, then config |
-| "What did this scout change?" | "Auditing what a scout changed" above: the run window, then `advanced-activity-logs-list` |
+| "What did this scout change?" | "Auditing what a scout changed" above: the run window and available history |
| "Did that fix actually hold?" | `posthog:inbox-report-checks-list` on the resolved report; mechanics in `authoring-scouts` |
diff --git a/services/mcp/src/lib/instructions-formatter.ts b/services/mcp/src/lib/instructions-formatter.ts
index cbab358786f7..8bac086a54e4 100644
--- a/services/mcp/src/lib/instructions-formatter.ts
+++ b/services/mcp/src/lib/instructions-formatter.ts
@@ -8,6 +8,8 @@ import {
type ToolInfo,
} from '@/lib/instructions'
import { formatPrompt } from '@/lib/utils'
+import ACTIVITY_HISTORY from '@/templates/sections/activity-history.md'
+import ACTIVITY_HISTORY_SQL from '@/templates/sections/activity-history-sql.md'
import AGENT_FEEDBACK from '@/templates/sections/agent-feedback.md'
import ANALYSIS_ARTIFACTS from '@/templates/sections/analysis-artifacts.md'
import BASIC_FUNCTIONALITY from '@/templates/sections/basic-functionality.md'
@@ -136,6 +138,16 @@ export class InstructionsFormatter {
return [ANALYSIS_ARTIFACTS, ...(ctx.notebookCellsEnabled ? [NOTEBOOK_PYTHON] : [])]
}
+ private activityHistorySections(ctx: InstructionsContext): string[] {
+ if (!ctx.tools?.some(({ name }) => name === 'advanced-activity-logs-list')) {
+ return []
+ }
+ return [
+ ACTIVITY_HISTORY,
+ ...(ctx.tools.some(({ name }) => name === 'execute-sql') ? [ACTIVITY_HISTORY_SQL] : []),
+ ]
+ }
+
/** Build the system prompt for tools-mode clients (each tool registered separately). */
buildToolsInstructions(ctx: InstructionsContext): string {
return this.compose(
@@ -148,6 +160,7 @@ export class InstructionsFormatter {
SCHEMA_WORKFLOW,
CATALOG_TRUST_DISCOVERY,
...this.artifactSections(ctx),
+ ...this.activityHistorySections(ctx),
...envContextSections(ctx),
URL_PATTERNS,
AGENT_FEEDBACK,
@@ -227,6 +240,7 @@ export class InstructionsFormatter {
SCHEMA_WORKFLOW,
CATALOG_TRUST_DISCOVERY,
...this.artifactSections(ctx),
+ ...this.activityHistorySections(ctx),
EXAMPLES,
],
ctx,
@@ -302,6 +316,7 @@ export class InstructionsFormatter {
// URL patterns live behind `learn urls` to protect the schema budget;
// with learn unavailable there is no topic to load, so stay inline.
...(learnSection ? [] : [URL_PATTERNS]),
+ ...(learnSection ? [] : this.activityHistorySections(ctx)),
],
renderCtx,
{
@@ -335,6 +350,7 @@ export class InstructionsFormatter {
SCHEMA_WORKFLOW,
CATALOG_TRUST_DISCOVERY,
...this.artifactSections(ctx),
+ ...this.activityHistorySections(ctx),
...envContextSections(ctx),
URL_PATTERNS,
AGENT_FEEDBACK,
diff --git a/services/mcp/src/templates/sections/activity-history-sql.md b/services/mcp/src/templates/sections/activity-history-sql.md
new file mode 100644
index 000000000000..357ca6289530
--- /dev/null
+++ b/services/mcp/src/templates/sections/activity-history-sql.md
@@ -0,0 +1 @@
+For SQL history reads, use `execute-sql` over `system.activity_logs` only when schema discovery exposes that table. Use scope, item, and `created_at` bounds, select only needed columns, and cap results with `LIMIT 10`. Treat a full page as partial history. SQL enforces the same entitlement, retention, and access controls; it is not a bypass. If the table is unavailable or access is denied, stop using this table for the run; do not probe endpoints to bypass the restriction. Other advertised, authorized history readers, including per-object readers, remain usable.
diff --git a/services/mcp/src/templates/sections/activity-history.md b/services/mcp/src/templates/sections/activity-history.md
new file mode 100644
index 000000000000..f4d79c36352a
--- /dev/null
+++ b/services/mcp/src/templates/sections/activity-history.md
@@ -0,0 +1,7 @@
+### Activity history
+
+Use `advanced-activity-logs-list` for configuration history. Read its schema once before the first history check, then pass `start_date`, `end_date`, relevant `scopes`/`item_ids`, `page_size: 10`, and only needed `fields`. Request `detail.changes` only for a specific candidate. A non-null `next` means incomplete history; narrow the window or paginate with `page` within the investigation budget before ruling out an edit.
+
+To audit a scout run, bracket its start and completion times and filter `clients: ["scout:<skill_name>"]` using the scout's actual skill name from its config. Include `Notebook` alongside the resource types covered by its write grant. Inspect actors, items, and timestamps: the tag identifies the scout, not an individual run, so overlapping runs can share it. If the tag is unknown, omit the client filter and treat attribution as uncertain.
+
+Access controls and the plan's retention window still apply. If access is denied, stop using this reader for the run and record the limitation. Other advertised, authorized history readers, including per-object readers, remain usable. Missing history does not prove that no configuration change occurred.
diff --git a/services/mcp/tests/unit/activity-logs-selectable-fields.test.ts b/services/mcp/tests/unit/activity-logs-selectable-fields.test.ts
index fb309adb275d..768ee752a653 100644
--- a/services/mcp/tests/unit/activity-logs-selectable-fields.test.ts
+++ b/services/mcp/tests/unit/activity-logs-selectable-fields.test.ts
@@ -1,5 +1,6 @@
-import { describe, expect, it } from 'vitest'
+import { describe, expect, it, vi } from 'vitest'
+import { getToolsFromContext } from '@/tools'
import { GENERATED_TOOLS } from '@/tools/generated/platform_features'
import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
@@ -35,6 +36,49 @@ function mockContext(): Context {
describe('advanced-activity-logs-list selectable fields', () => {
const listTool = GENERATED_TOOLS['advanced-activity-logs-list'] as () => ToolBase<ZodObjectAny>
+ it.each(['Team', 'FeatureFlag', 'Experiment', 'Survey'])(
+ 'lets a project-scoped scout query bounded %s history through the runtime catalog',
+ async (scope) => {
+ const context = mockContext()
+ context.stateManager.getAiConsentGiven = async () => true
+ context.stateManager.getApiKey = async () => ({
+ scopes: ['activity_log:read', 'internal_run:read', 'signal_scout_internal:write'],
+ scoped_teams: [1],
+ scoped_organizations: [],
+ })
+ const request = vi.spyOn(context.api, 'request')
+ const tools = await getToolsFromContext(context, {
+ tools: ['advanced-activity-logs-list'],
+ scopedTeams: [1],
+ availableFeatures: ['audit_logs'],
+ isCloud: true,
+ })
+ const tool = tools.find((candidate) => candidate.name === 'advanced-activity-logs-list')
+ expect(tool).toBeTruthy()
+ expect(tool!.annotations).toMatchObject({ readOnlyHint: true, destructiveHint: false })
+
+ const query = {
+ scopes: [scope],
+ item_ids: ['42'],
+ start_date: '2026-01-01T00:00:00Z',
+ end_date: '2026-01-02T00:00:00Z',
+ page_size: 10,
+ }
+ const params = tool!.schema.parse({ ...query, fields: ['activity', 'created_at'] })
+ const result = await tool!.handler(context, params)
+
+ expect(request).toHaveBeenCalledExactlyOnceWith({
+ method: 'GET',
+ path: '/api/projects/1/advanced_activity_logs/',
+ query: expect.objectContaining(query),
+ })
+ expect(result).toMatchObject({
+ results: [{ activity: 'updated', created_at: FULL_ENTRY.created_at }],
+ })
+ expect(result).not.toHaveProperty('results.0.detail')
+ }
+ )
+
it('narrows each result to the requested fields when `fields` is passed', async () => {
const result: any = await listTool().handler(mockContext(), {
fields: ['user.email', 'activity', 'created_at'],
diff --git a/services/mcp/tests/unit/instructions-formatter.test.ts b/services/mcp/tests/unit/instructions-formatter.test.ts
index 0830bbc085d9..e429bed679ff 100644
--- a/services/mcp/tests/unit/instructions-formatter.test.ts
+++ b/services/mcp/tests/unit/instructions-formatter.test.ts
@@ -512,6 +512,69 @@ describe('InstructionsFormatter', () => {
})
})
+ describe('activity history guidance', () => {
+ const surfaces: {
+ name: string
+ render: (formatter: InstructionsFormatter, ctx: InstructionsContext) => string
+ inline: boolean
+ }[] = [
+ { name: 'tools', render: (f, ctx) => f.buildToolsInstructions(ctx), inline: true },
+ { name: 'exec', render: (f, ctx) => f.buildExecCommandReference(ctx), inline: true },
+ {
+ name: 'Claude analytics guide',
+ render: (f, ctx) =>
+ f.buildClaudeExecLearnGuides(ctx).find((entry) => entry.id === 'analytics')!.content,
+ inline: true,
+ },
+ {
+ name: 'Claude without guides',
+ render: (f, ctx) => f.buildClaudeExecCommandReference(ctx, { learnEnabled: false }),
+ inline: true,
+ },
+ {
+ name: 'Claude with guides',
+ render: (f, ctx) => f.buildClaudeExecCommandReference(ctx),
+ inline: false,
+ },
+ ]
+
+ it.each(
+ surfaces.flatMap((surface) =>
+ [
+ { capability: 'neither reader', tools: [], history: false, sql: false },
+ { capability: 'SQL only', tools: ['execute-sql'], history: false, sql: false },
+ {
+ capability: 'activity reader only',
+ tools: ['advanced-activity-logs-list'],
+ history: true,
+ sql: false,
+ },
+ {
+ capability: 'both readers',
+ tools: ['advanced-activity-logs-list', 'execute-sql'],
+ history: true,
+ sql: true,
+ },
+ ].map((capability) => ({ ...surface, ...capability }))
+ )
+ )('$name exposes only supported history procedures: $capability', ({ render, inline, tools, history, sql }) => {
+ const result = render(new InstructionsFormatter(), {
+ ...fullCtx,
+ tools: tools.map((name) => ({ name, category: 'Platform Features' })),
+ })
+
+ expect(result.includes('### Activity history')).toBe(inline && history)
+ expect(result.includes('`system.activity_logs`')).toBe(inline && sql)
+ if (inline && history) {
+ expect(result).toContain('`start_date`, `end_date`')
+ expect(result).toContain('`page_size: 10`')
+ expect(result).toContain('`clients: ["scout:<skill_name>"]`')
+ expect(result).toContain('If access is denied, stop using this reader')
+ expect(result).toContain('Other advertised, authorized history readers, including per-object readers')
+ }
+ })
+ })
+
// Mirrors the single-exec wiring in `src/mcp.ts`. When the client honors the MCP
// `instructions` field, that payload carries exactly one thing — the tool-domain index
// (including the `query` domain) — because clients hard-truncate it. Everything else,