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): ship a default pre-check for the session replay scout (#115933)

posthog[bot]90c51e5c1824
diff --git a/products/signals/backend/test/test_scout_precheck.py b/products/signals/backend/test/test_scout_precheck.py
index 10d1bfe64de1..825fac07eaae 100644
--- a/products/signals/backend/test/test_scout_precheck.py
+++ b/products/signals/backend/test/test_scout_precheck.py
@@ -19,6 +19,7 @@ from rest_framework import status
from posthog.models import OrganizationMembership, Team, User
from posthog.models.scoping import team_scope
+from posthog.session_recordings.queries.test.session_replay_sql import produce_replay_summary
from products.customer_analytics.backend.facade.testing import create_account
from products.signals.backend.models import SignalReport, SignalScoutConfig, SignalScoutRun
@@ -253,6 +254,37 @@ class TestSkillDefaultPrecheck(ClickhouseTestMixin, BaseTest):
assert result is not None
assert (result.outcome, result.query_source) == (outcome, "skill_default")
+ @parameterized.expand(
+ [
+ # Recordings stopped 20 days ago: a capture cliff the scout must still see.
+ ("capture_cliff", 24 * 20, "run"),
+ ("stale", 24 * 31, "skip"),
+ ("future_dated", -24 * 3, "skip"),
+ ]
+ )
+ def test_session_replay_default_skips_only_without_recent_recordings(self, _name, hours_ago, outcome) -> None:
+ skill = "signals-scout-session-replay"
+ LLMSkill.objects.create(
+ team=self.team, name=skill, description="", body="", metadata={"seeded_by": HARNESS_SEEDED_BY}
+ )
+ SignalScoutConfig.all_teams.create(team=self.team, skill_name=skill)
+ produce_replay_summary(
+ team_id=self.team.pk,
+ session_id="s1",
+ first_timestamp=NOW - timedelta(hours=hours_ago),
+ last_timestamp=NOW - timedelta(hours=hours_ago) + timedelta(minutes=5),
+ ensure_analytics_event_in_session=False,
+ )
+
+ with (
+ patch(ROLLOUT_PERCENT, return_value=100),
+ patch("products.signals.backend.scout_harness.precheck.posthoganalytics.capture"),
+ ):
+ result = evaluate_scout_precheck(self.team.pk, skill)
+
+ assert result is not None
+ assert (result.outcome, result.query_source) == (outcome, "skill_default")
+
def test_project_outside_the_rollout_runs_as_before(self) -> None:
result, capture = self._evaluate(rollout_percent=0)
diff --git a/products/signals/skills/signals-scout-session-replay/SKILL.md b/products/signals/skills/signals-scout-session-replay/SKILL.md
index ec2214241332..7af4328f930b 100644
--- a/products/signals/skills/signals-scout-session-replay/SKILL.md
+++ b/products/signals/skills/signals-scout-session-replay/SKILL.md
@@ -17,6 +17,12 @@ allowed_tools:
metadata:
owner_team: signals
scope: session_replay
+scout-precheck-query: |
+ SELECT 1 AS has_recordings
+ FROM raw_session_replay_events
+ WHERE min_first_timestamp > {now} - INTERVAL 30 DAY
+ AND min_first_timestamp <= {now} + INTERVAL 1 DAY
+ LIMIT 1
---
# Signals scout: session replay
@@ -49,6 +55,8 @@ Four mechanical traps that produce silently-wrong results — every replay query
## Quick close-out: is replay even in use?
+A scheduled run can start with a `<precheck_result>` block. The block means that at least one recording started in the last 30 days, so skip the zero-in-30d close-out. It holds no count, so still run the count below to tell a capture cliff from recordings that flow.
+
One cheap count tells you the posture:
```sql