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): mention activity-summary-search in the scout prompt (#129363)

posthog[bot]02a83dda7e23
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index 02647a84782f..3c30b842f6d8 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -196,6 +196,20 @@ def _governed_metrics_section(project_has_governed_metrics: bool) -> str:
return _GOVERNED_METRICS_NUDGE if project_has_governed_metrics else ""
+_ACTIVITY_SUMMARY_SEARCH_NUDGE = """# Find people who read the work
+
+When you set `suggested_reviewers`, also call `activity-summary-search`. It finds project members by object, topic, or product, including people who open something without editing it. A hit is a lead, so check it against the report. Repeatedly opening the affected object can support a selection when the `reason` says so. This is not ownership evidence, and broad activity alone is still not enough."""
+
+
+def _activity_summary_search_section(activity_summary_search_available: bool) -> str:
+ """The reviewer-search nudge for a run that holds `activity-summary-search`, and nothing for any other run.
+
+ Rendered in the per-run block for the same reason as `_governed_metrics_section`: inside
+ *Suggested reviewers route the report* it would split the shared prefix between teams.
+ """
+ return _ACTIVITY_SUMMARY_SEARCH_NUDGE if activity_summary_search_available else ""
+
+
# The close-out summary tool is a sandbox harness tool, not a PostHog MCP tool, so it is absent from
# the `mcp__posthog__exec` catalog and has to be called under its qualified name.
_TASK_SUMMARY_TOOL = "task_summary_update"
@@ -1586,6 +1600,7 @@ def build_run_prompt(
write_scopes: Sequence[str] | None = None,
tool_allowlist_narrowed: bool = False,
project_has_governed_metrics: bool = False,
+ activity_summary_search_available: bool = False,
mcp_server_names: Sequence[str] | None = None,
business_knowledge_maintained: bool = False,
run_note: str | None = None,
@@ -1662,6 +1677,10 @@ def build_run_prompt(
catalog exists; False renders nothing, so a project that does not use the data catalog pays no
tokens for it. A failed check is False, because an outage must cost steering only.
+ `activity_summary_search_available` is the harness-side check that the team can search activity
+ summaries and the run holds `activity-summary-search`. True renders a reviewer-routing nudge on
+ the report channel; False renders nothing. A failed check is False.
+
`business_knowledge_maintained` must mirror `business_knowledge.is_maintained_for_team`: it
renders the business-knowledge section, which names tools that only exist in the run's toolset
when that product's flag is on. The stricter predicate is deliberate — the section rides on
@@ -1764,6 +1783,7 @@ def build_run_prompt(
for section in (
_governed_metrics_section(project_has_governed_metrics),
_report_tags_in_use_section(report_tags_in_use or []) if report_channel else "",
+ _activity_summary_search_section(activity_summary_search_available) if report_channel else "",
_external_mcp_servers_paragraph(mcp_server_names) if mcp_server_names else "",
write_access_section,
_NARROWED_TOOLS_SECTION if tool_allowlist_narrowed else "",
diff --git a/products/signals/backend/scout_harness/runner.py b/products/signals/backend/scout_harness/runner.py
index b6e3a9c0f8f0..a7d842e7da08 100644
--- a/products/signals/backend/scout_harness/runner.py
+++ b/products/signals/backend/scout_harness/runner.py
@@ -32,6 +32,7 @@ from posthog.temporal.oauth import SCOUT_DEFAULT_WRITE_SCOPES, scout_mcp_scopes,
from products.business_knowledge.backend.logic import is_maintained_for_team
from products.data_catalog.backend.facade.api import approved_metric_names_for_team
from products.mcp_store.backend.facade.api import get_sandbox_mcp_server_names
+from products.signals.backend.activity_summary.search import searchable_config
from products.signals.backend.agent_runtime import STEP_SCOUT, AgentRuntime, resolve_agent_runtime
from products.signals.backend.constants import FIRST_REPORT_SCOUT, FIRST_REPORT_SCOUT_TIMEOUT_SECONDS
from products.signals.backend.facade.source_scouts import refresh_source_scout
@@ -79,7 +80,7 @@ from products.signals.backend.scout_harness.team_limits import (
resolve_background_backoff,
withheld_skills_for_team,
)
-from products.signals.backend.scout_harness.tool_catalogue import scout_tool_access_enabled
+from products.signals.backend.scout_harness.tool_catalogue import scout_held_mcp_tools, scout_tool_access_enabled
from products.signals.backend.scout_harness.trial_launch import (
TrialLaunch,
assert_trial_model_access,
@@ -860,6 +861,26 @@ def _project_has_governed_metrics(team: Team, user_id: int) -> bool:
return False
+ACTIVITY_SUMMARY_SEARCH_TOOL = "activity-summary-search"
+
+
+def _activity_summary_search_available(team: Team, mcp_tool_allowlist: list[str] | None) -> bool:
+ """Whether the run's prompt should name `activity-summary-search` for reviewer routing.
+
+ True only when the team can search and the run holds the tool, so the prompt never names a tool
+ the run cannot call. A failed check is False: the mention is optional steering.
+ """
+ try:
+ if mcp_tool_allowlist is not None and ACTIVITY_SUMMARY_SEARCH_TOOL not in scout_held_mcp_tools(
+ mcp_tool_allowlist
+ ):
+ return False
+ return searchable_config(team) is not None
+ except Exception as error:
+ capture_exception(error)
+ return False
+
+
def _report_tags_in_use(team: Team, *, report_channel: bool) -> list[str]:
"""The team's report tags for the prompt, or none for a signal-channel scout.
@@ -1113,6 +1134,9 @@ async def _spawn_and_run(
report_tags_in_use = await database_sync_to_async(_report_tags_in_use, thread_sensitive=False)(
team, report_channel=report_channel
)
+ activity_summary_search = report_channel and await database_sync_to_async(
+ _activity_summary_search_available, thread_sensitive=False
+ )(team, mcp_tool_allowlist)
prompt = build_run_prompt(
skill,
run_id=str(run_id),
@@ -1121,6 +1145,7 @@ async def _spawn_and_run(
project_timezone=team.timezone,
github_read_access=github_guidance,
project_has_governed_metrics=project_has_governed_metrics,
+ activity_summary_search_available=activity_summary_search,
# Names the external MCP servers the sandbox will mount, so *How to call tools* can carve
# them out of the exec-interface rule; empty renders nothing.
mcp_server_names=mcp_server_names,
diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.py
index 42933031dc1d..23ec1f466745 100644
--- a/products/signals/backend/test/test_scout_harness.py
+++ b/products/signals/backend/test/test_scout_harness.py
@@ -77,6 +77,7 @@ from products.signals.backend.scout_harness.runner import (
SIGNALS_SCOUT_FULL_NETWORK_ENV_NAME,
SIGNALS_SCOUT_SANDBOX_ENV_NAME,
RunResult,
+ _activity_summary_search_available,
_ai_stage,
_background_backoff_props,
_create_run_row,
@@ -517,6 +518,79 @@ class TestPromptCacheablePrefix(SimpleTestCase):
):
assert value not in head, f"{value} interpolated above the per-run block"
+ @parameterized.expand(
+ [
+ ("signal_channel", [], True, False),
+ ("report_emit_only", ["emit_report"], True, True),
+ ("report_both", ["emit_report", "edit_report"], True, True),
+ ("report_edit_only", ["edit_report"], True, True),
+ ("report_both_unavailable", ["emit_report", "edit_report"], False, False),
+ ]
+ )
+ def test_activity_summary_search_nudge_renders_after_the_shared_prefix_only_when_available(
+ self, _name: str, allowed_tools: list[str], available: bool, rendered: bool
+ ) -> None:
+ prompt = build_run_prompt(
+ LoadedSkill(
+ name="signals-scout-reviewer-search",
+ version=1,
+ body="watch",
+ description="d",
+ allowed_tools=allowed_tools,
+ files=[],
+ skill_id="skill-1",
+ origin="custom",
+ authors=[],
+ ),
+ run_id="00000000-0000-0000-0000-000000000abc",
+ team_id=1,
+ started_at=datetime(2026, 5, 1, 12, 34, 56, tzinfo=UTC),
+ activity_summary_search_available=available,
+ )
+
+ assert ("activity-summary-search" in prompt) is rendered
+ if rendered:
+ assert prompt.index("# Find people who read the work") > prompt.index("# Output format")
+
+
+class TestActivitySummarySearchAvailability(SimpleTestCase):
+ @parameterized.expand(
+ [
+ ("unnarrowed", None, True, True, True),
+ ("allowlist_holds_tool", ["activity-summary-search"], True, True, True),
+ ("allowlist_omits_tool", ["insight-get"], True, True, False),
+ ("search_flag_off", None, True, False, False),
+ ("not_enrolled_for_reads", None, False, True, False),
+ ]
+ )
+ def test_resolves_from_the_search_gate_and_the_run_allowlist(
+ self,
+ _name: str,
+ allowlist: list[str] | None,
+ enrolled: bool,
+ flag_on: bool,
+ expected: bool,
+ ) -> None:
+ with (
+ patch(
+ "products.signals.backend.activity_summary.search.readable_config",
+ return_value=MagicMock() if enrolled else None,
+ ),
+ patch("products.signals.backend.activity_summary.search.search_enabled", return_value=flag_on),
+ ):
+ assert _activity_summary_search_available(MagicMock(), allowlist) is expected
+
+ def test_a_failed_gate_check_resolves_false(self) -> None:
+ with (
+ patch(
+ "products.signals.backend.activity_summary.search.readable_config",
+ side_effect=RuntimeError("flag payload unavailable"),
+ ),
+ patch("products.signals.backend.scout_harness.runner.capture_exception") as capture,
+ ):
+ assert _activity_summary_search_available(MagicMock(), None) is False
+ capture.assert_called_once()
+
class TestCheckoutSection(SimpleTestCase):
def test_it_states_that_the_tree_carries_full_history(self) -> None: