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(replay_vision): blend the what-to-watch feed score (#102610)

Kim Svatos Dugan1e137b954ffc
diff --git a/products/replay_vision/backend/api/scanners.py b/products/replay_vision/backend/api/scanners.py
index 8333a94e400f..47bd2615a5cf 100644
--- a/products/replay_vision/backend/api/scanners.py
+++ b/products/replay_vision/backend/api/scanners.py
@@ -1487,6 +1487,14 @@ class WatchFeedReasonSerializer(serializers.Serializer):
signals_count = serializers.IntegerField(
required=False, allow_null=True, help_text="Signals this observation emitted, for `signal_emitted`."
)
+ problem_types = serializers.ListField(
+ child=serializers.CharField(),
+ required=False,
+ help_text=(
+ "Issue type of each emitted signal (`bug`, `crash`, `design_flaw`, `ux_friction`), one entry per "
+ "signal in the order raised, for `signal_emitted`. Absent on signals scanned before this shipped."
+ ),
+ )
verdict = serializers.CharField(
required=False, allow_null=True, help_text="The monitor's answer, for `unusual_verdict`."
)
diff --git a/products/replay_vision/backend/temporal/__init__.py b/products/replay_vision/backend/temporal/__init__.py
index 409ed14d111b..6d8690935878 100644
--- a/products/replay_vision/backend/temporal/__init__.py
+++ b/products/replay_vision/backend/temporal/__init__.py
@@ -16,6 +16,7 @@ from products.replay_vision.backend.temporal.activities import (
emit_classifier_tags_activity,
emit_observation_event_activity,
emit_observation_signal_activity,
+ emit_observation_signals_activity,
ensure_session_asset_activity,
fetch_session_events_activity,
fetch_session_network_activity,
@@ -97,6 +98,7 @@ ACTIVITIES: list[Callable[..., Any]] = [
emit_classifier_tags_activity,
emit_observation_event_activity,
emit_observation_signal_activity,
+ emit_observation_signals_activity,
cleanup_gemini_file_activity,
find_scanner_candidates_activity,
count_in_flight_applies_activity,
@@ -152,6 +154,7 @@ __all__ = [
"emit_classifier_tags_activity",
"emit_observation_event_activity",
"emit_observation_signal_activity",
+ "emit_observation_signals_activity",
"ensure_session_asset_activity",
"fetch_session_events_activity",
"fetch_session_network_activity",
diff --git a/products/replay_vision/backend/temporal/activities/__init__.py b/products/replay_vision/backend/temporal/activities/__init__.py
index 4541c1a23cf6..94b77eb93788 100644
--- a/products/replay_vision/backend/temporal/activities/__init__.py
+++ b/products/replay_vision/backend/temporal/activities/__init__.py
@@ -20,7 +20,10 @@ from products.replay_vision.backend.temporal.activities.create_observation impor
from products.replay_vision.backend.temporal.activities.embed_observation import embed_observation_activity
from products.replay_vision.backend.temporal.activities.emit_classifier_tags import emit_classifier_tags_activity
from products.replay_vision.backend.temporal.activities.emit_observation_event import emit_observation_event_activity
-from products.replay_vision.backend.temporal.activities.emit_observation_signal import emit_observation_signal_activity
+from products.replay_vision.backend.temporal.activities.emit_observation_signal import (
+ emit_observation_signal_activity,
+ emit_observation_signals_activity,
+)
from products.replay_vision.backend.temporal.activities.ensure_session_asset import ensure_session_asset_activity
from products.replay_vision.backend.temporal.activities.evaluate_prompt_suggestion import (
finalize_evaluation_activity,
@@ -80,6 +83,7 @@ __all__ = [
"emit_classifier_tags_activity",
"emit_observation_event_activity",
"emit_observation_signal_activity",
+ "emit_observation_signals_activity",
"ensure_session_asset_activity",
"fetch_session_events_activity",
"fetch_session_network_activity",
diff --git a/products/replay_vision/backend/temporal/activities/emit_observation_signal.py b/products/replay_vision/backend/temporal/activities/emit_observation_signal.py
index d4e67e6d35b3..be87b4335803 100644
--- a/products/replay_vision/backend/temporal/activities/emit_observation_signal.py
+++ b/products/replay_vision/backend/temporal/activities/emit_observation_signal.py
@@ -25,10 +25,10 @@ def _load_llm_inputs(observation_id: UUID) -> ScannerLlmInputs | None:
return async_to_sync(load_scanner_llm_inputs)(str(observation_id))
-@track_activity(side_effect="signal")
-def emit_observation_signal_activity(inputs: EmitObservationSignalInputs) -> int:
- """Emit the observation's side-mission findings as PostHog Signals; fails soft, returns the emitted count."""
+def _emit_observation_signals(inputs: EmitObservationSignalInputs) -> list[str]:
+ """Emit the observation's side-mission findings as PostHog Signals; fails soft, returns the problem type
+ of each signal it actually emitted, in emission order. Findings below the confidence floor and findings
+ whose emission fails are left out, so the caller's count and types stay in step."""
try:
observation = (
ReplayObservation.objects.filter(pk=inputs.observation_id, team_id=inputs.team_id)
@@ -36,12 +36,12 @@ def emit_observation_signal_activity(inputs: EmitObservationSignalInputs) -> int
.first()
)
if observation is None:
- return 0
+ return []
snapshot = ScannerSnapshot.load_for(inputs.observation_id, observation.scanner_snapshot)
# The scanner's `emits_signals` flag is the per-source authorization — there's no separate
# SignalSourceConfig to consult (the facade allows replay_vision/scanner_finding unconditionally).
if not snapshot.emits_signals:
- return 0
+ return []
# Observation-wide metadata, shared by every finding. `scanner_name`/`scanner_type` come from the
# frozen snapshot (what actually ran); `scanner_id`/`session_id` are immutable on the row. The
# `recording_*` fields are the snapshot time bounds — `recording_start_time` is the REC_T=0 anchor,
@@ -71,7 +71,7 @@ def emit_observation_signal_activity(inputs: EmitObservationSignalInputs) -> int
base_extra["recording_duration"] = meta.duration_seconds
base_extra["recording_active_seconds"] = meta.active_seconds
- emitted = 0
+ emitted_problem_types: list[str] = []
any_failed = False
for index, signal in enumerate(inputs.signals):
if signal.confidence < MIN_SIGNAL_CONFIDENCE:
@@ -96,9 +96,9 @@ def emit_observation_signal_activity(inputs: EmitObservationSignalInputs) -> int
"url": signal.url,
},
)
- emitted += 1
+ emitted_problem_types.append(signal.problem_type)
# Findings go out one network call at a time, so beat between them.
- activity.heartbeat({"emitted": emitted, "index": index})
+ activity.heartbeat({"emitted": len(emitted_problem_types), "index": index})
except Exception:
# One bad finding never blocks the rest; signals are advisory.
any_failed = True
@@ -110,10 +110,26 @@ def emit_observation_signal_activity(inputs: EmitObservationSignalInputs) -> int
if any_failed:
# Per activity, not per finding, so the counter is comparable to the other effects.
record_side_effect_failure("signal")
- return emitted
+ return emitted_problem_types
except Exception:
# Never fail the observation over emission. Counted here because the swallow means
# track_activity sees a success.
record_side_effect_failure("signal")
logger.exception("replay_vision.signal_emission_failed", observation_id=str(inputs.observation_id))
- return 0
+ return []
+
+
+@track_activity(side_effect="signal")
+def emit_observation_signal_activity(inputs: EmitObservationSignalInputs) -> int:
+ """Legacy count-returning entry point. Kept so in-flight workflow histories that scheduled it before the
+ problem-types patch still decode an int on replay; new executions use emit_observation_signals_activity."""
+ return len(_emit_observation_signals(inputs))
+
+
+@track_activity(side_effect="signal")
+def emit_observation_signals_activity(inputs: EmitObservationSignalInputs) -> list[str]:
+ """Emit the observation's side-mission findings and return each emitted signal's problem type, in emission
+ order — the watch feed counts them to name the kinds of issue a session raised."""
+ return _emit_observation_signals(inputs)
diff --git a/products/replay_vision/backend/temporal/types.py b/products/replay_vision/backend/temporal/types.py
index 9456989d788f..f186a387e20e 100644
--- a/products/replay_vision/backend/temporal/types.py
+++ b/products/replay_vision/backend/temporal/types.py
@@ -41,6 +41,9 @@ class ScannerResult(BaseModel, frozen=True):
model_output: AnyScannerOutput
signals_count: int = Field(default=0, ge=0)
+ # The problem type of each signal actually emitted, in emission order and with repeats kept, so the
+ # watch feed can count the kinds of issue a row carries. Empty on non-signal rows and on old rows.
+ signal_problem_types: list[str] = Field(default_factory=list)
verification: VerificationRecord | None = None
diff --git a/products/replay_vision/backend/temporal/workflow.py b/products/replay_vision/backend/temporal/workflow.py
index ca58dd324544..ec61a47c1592 100644
--- a/products/replay_vision/backend/temporal/workflow.py
+++ b/products/replay_vision/backend/temporal/workflow.py
@@ -36,6 +36,7 @@ from products.replay_vision.backend.temporal.activities import (
emit_classifier_tags_activity,
emit_observation_event_activity,
emit_observation_signal_activity,
+ emit_observation_signals_activity,
ensure_session_asset_activity,
fetch_session_events_activity,
fetch_session_network_activity,
@@ -347,25 +348,39 @@ class ApplyScannerWorkflow(PostHogWorkflow):
)
self._advance_phase("finalizing")
signals_count = 0
+ signal_problem_types: list[str] = []
if call_output.signals:
- # The activity fails soft (returns 0 on any error), so there's nothing to retry. The local
- # catch covers Temporal-level failures (timeout, worker loss) — emission is advisory and
- # must never demote an otherwise-successful observation to FAILED.
+ emit_inputs = EmitObservationSignalInputs(
+ team_id=inputs.team_id,
+ observation_id=observation_id,
+ exported_asset_id=asset_result.asset_id,
+ signals=call_output.signals,
+ )
+ # The signals-returning activity reports the problem type of each signal it actually emitted,
+ # so the count derives from that list. A pre-patch history scheduled the count-returning
+ # activity, so the else branch keeps calling it and in-flight scans replay cleanly. Both fail
+ # soft (emit nothing extra on error), so there is nothing to retry; the local catch covers
+ # Temporal-level failures (timeout, worker loss) — emission is advisory and must never demote
+ # an otherwise-successful observation. 30s once truncated the tail on a slow facade, so give
+ # it 2 minutes; retries are safe because each finding carries a deterministic idempotency key.
try:
- signals_count = await wf.execute_activity(
- emit_observation_signal_activity,
- EmitObservationSignalInputs(
- team_id=inputs.team_id,
- observation_id=observation_id,
- exported_asset_id=asset_result.asset_id,
- signals=call_output.signals,
- ),
- # 30s truncated the tail on a slow facade and recorded signals_count=0; retries are
- # safe because each finding carries a deterministic idempotency key.
- start_to_close_timeout=dt.timedelta(minutes=2),
- heartbeat_timeout=dt.timedelta(seconds=30),
- retry_policy=common.RetryPolicy(maximum_attempts=3),
- )
+ if wf.patched("replay-vision-emitted-signal-problem-types"):
+ signal_problem_types = await wf.execute_activity(
+ emit_observation_signals_activity,
+ emit_inputs,
+ start_to_close_timeout=dt.timedelta(minutes=2),
+ heartbeat_timeout=dt.timedelta(seconds=30),
+ retry_policy=common.RetryPolicy(maximum_attempts=3),
+ )
+ signals_count = len(signal_problem_types)
+ else:
+ signals_count = await wf.execute_activity(
+ emit_observation_signal_activity,
+ emit_inputs,
+ start_to_close_timeout=dt.timedelta(minutes=2),
+ heartbeat_timeout=dt.timedelta(seconds=30),
+ retry_policy=common.RetryPolicy(maximum_attempts=3),
+ )
except Exception:
wf.logger.exception("Signal emission activity failed for observation %s", observation_id)
# Persist the billed result first — everything past this point is fail-soft delivery.
@@ -377,6 +392,7 @@ class ApplyScannerWorkflow(PostHogWorkflow):
scanner_result=ScannerResult(
model_output=call_output.model_output,
signals_count=signals_count,
+ signal_problem_types=signal_problem_types,
verification=call_output.verification,
),
),
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index 3e90091a40ac..d9266a99c633 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -4316,6 +4316,24 @@ class TestWatchFeedAPI(_VisionAPITestCase):
self.assertEqual(items[3]["reason"], {"kind": "unviewed_recent"})
assert plain_new and hit and signal and plain_old
+ def test_signal_reason_carries_the_persisted_problem_types(self) -> None:
+ # The card counts what kinds of issue a signal row carries, so the reason must surface one entry
+ # per signal in order, repeats kept — not a deduplicated set.
+ scanner = self._create_scanner(name="m")
+ self._succeeded_observation(
+ scanner,
+ "signal",
+ 10,
+ {
+ "model_output": {"scanner_type": "monitor", "verdict": "no", "reasoning": "r", "confidence": 0.9},
+ "signals_count": 3,
+ "signal_problem_types": ["bug", "bug", "crash"],
+ },
+ )
+ reason = self.client.get(self.feed_url).json()["results"][0]["reason"]
+ self.assertEqual(reason["kind"], "signal_emitted")
+ self.assertEqual(reason["problem_types"], ["bug", "bug", "crash"])
+
def test_minority_verdict_is_the_hit_regardless_of_prompt_polarity(self) -> None:
# "Was the experience good?" answers yes almost always, so its rare "no" is the notable
# one; a majority "yes" must not rank as a hit just for being yes.
@@ -4332,9 +4350,9 @@ class TestWatchFeedAPI(_VisionAPITestCase):
reasons = {item["observation"]["session_id"]: item["reason"]["kind"] for item in items}
self.assertEqual(reasons["good-0"], "unviewed_recent")
- def test_notability_ranks_below_intent_above_heuristics_and_carries_its_sentence(self) -> None:
- # The scan's own judgment must beat keyword friction but never outrank what the user
- # configured the scanner to find, and its sentence must reach the card.
+ def test_high_notability_outranks_a_weak_hit_but_still_beats_friction_and_carries_its_sentence(self) -> None:
+ # The blend lets the scan's own judgment surface: a high notability outranks a bare verdict-yes
+ # hit (weak, no baseline), still beats keyword friction, and its sentence reaches the card.
scanner = self._create_scanner(name="m")
self._succeeded_observation(
scanner,
@@ -4372,11 +4390,11 @@ class TestWatchFeedAPI(_VisionAPITestCase):
items = resp.json()["results"]
self.assertEqual(
[item["observation"]["session_id"] for item in items],
- ["intent-hit", "notable-sess", "friction-sess"],
+ ["notable-sess", "intent-hit", "friction-sess"],
)
- self.assertEqual(items[1]["reason"]["kind"], "notable")
+ self.assertEqual(items[0]["reason"]["kind"], "notable")
self.assertEqual(
- items[1]["reason"]["notability_reason"], "Tried the same export three times and never saw an error."
+ items[0]["reason"]["notability_reason"], "Tried the same export three times and never saw an error."
)
def test_notability_reason_stays_off_rows_that_did_not_rank_on_notability(self) -> None:
diff --git a/products/replay_vision/backend/tests/test_temporal.py b/products/replay_vision/backend/tests/test_temporal.py
index 7499ef23dcb6..b11e638803fc 100644
--- a/products/replay_vision/backend/tests/test_temporal.py
+++ b/products/replay_vision/backend/tests/test_temporal.py
@@ -79,6 +79,7 @@ from products.replay_vision.backend.temporal.activities.emit_observation_event i
from products.replay_vision.backend.temporal.activities.emit_observation_signal import (
SIGNAL_WEIGHT,
emit_observation_signal_activity,
+ emit_observation_signals_activity,
)
from products.replay_vision.backend.temporal.activities.ensure_session_asset import ensure_session_asset_activity
from products.replay_vision.backend.temporal.activities.fetch_session_events import fetch_session_events_activity
@@ -3804,7 +3805,7 @@ class TestEmitObservationSignalActivity:
patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit,
patch(_LOAD_LLM_INPUTS_PATCH, return_value=self._llm_inputs(observation)),
):
- assert emit_observation_signal_activity(self._inputs(observation)) == 1
+ assert emit_observation_signals_activity(self._inputs(observation)) == ["bug"]
assert mock_emit.await_args is not None
kwargs = mock_emit.await_args.kwargs
@@ -3853,7 +3854,7 @@ class TestEmitObservationSignalActivity:
patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit,
patch(_LOAD_LLM_INPUTS_PATCH, return_value=None),
):
- assert emit_observation_signal_activity(self._inputs(observation)) == 1
+ assert emit_observation_signals_activity(self._inputs(observation)) == ["bug"]
assert mock_emit.await_args is not None
extra = mock_emit.await_args.kwargs["extra"]
@@ -3870,7 +3871,7 @@ class TestEmitObservationSignalActivity:
patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit,
patch(_LOAD_LLM_INPUTS_PATCH, side_effect=Exception("redis down")),
):
- assert emit_observation_signal_activity(self._inputs(observation)) == 1
+ assert emit_observation_signals_activity(self._inputs(observation)) == ["bug"]
assert mock_emit.await_args is not None
extra = mock_emit.await_args.kwargs["extra"]
@@ -3888,7 +3889,7 @@ class TestEmitObservationSignalActivity:
patch(_LOAD_LLM_INPUTS_PATCH, return_value=None),
):
# Two emitted; the 0.2-confidence finding is below the floor and skipped.
- assert emit_observation_signal_activity(self._inputs(observation, signals=signals)) == 2
+ assert emit_observation_signals_activity(self._inputs(observation, signals=signals)) == ["bug", "bug"]
calls = mock_emit.await_args_list
assert [c.kwargs["source_id"] for c in calls] == [
@@ -3903,7 +3904,7 @@ class TestEmitObservationSignalActivity:
observation = _make_observation(scanner)
with patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit:
- assert emit_observation_signal_activity(self._inputs(observation, confidence=confidence)) == 0
+ assert emit_observation_signals_activity(self._inputs(observation, confidence=confidence)) == []
mock_emit.assert_not_awaited()
def test_skips_when_the_snapshot_does_not_emit_signals(self) -> None:
@@ -3911,7 +3912,7 @@ class TestEmitObservationSignalActivity:
observation = _make_observation(scanner)
with patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit:
- assert emit_observation_signal_activity(self._inputs(observation)) == 0
+ assert emit_observation_signals_activity(self._inputs(observation)) == []
mock_emit.assert_not_awaited()
def test_skips_when_the_observation_is_missing(self) -> None:
@@ -3920,7 +3921,7 @@ class TestEmitObservationSignalActivity:
inputs = self._inputs(observation, observation_id=uuid.uuid4())
with patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit:
- assert emit_observation_signal_activity(inputs) == 0
+ assert emit_observation_signals_activity(inputs) == []
mock_emit.assert_not_awaited()
@pytest.mark.parametrize(
@@ -3933,7 +3934,7 @@ class TestEmitObservationSignalActivity:
observation = _make_observation(scanner)
with patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock, side_effect=error) as mock_emit:
- assert emit_observation_signal_activity(self._inputs(observation)) == 0
+ assert emit_observation_signals_activity(self._inputs(observation)) == []
mock_emit.assert_awaited_once()
def test_emits_without_any_source_config(self) -> None:
@@ -3942,11 +3943,24 @@ class TestEmitObservationSignalActivity:
observation = _make_observation(scanner)
with patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock) as mock_emit:
- assert emit_observation_signal_activity(self._inputs(observation)) == 1
+ assert emit_observation_signals_activity(self._inputs(observation)) == ["bug"]
mock_emit.assert_awaited_once()
assert not SignalSourceConfig.objects.filter(team=scanner.team).exists()
+ def test_legacy_count_activity_returns_the_emitted_count(self) -> None:
+ # The unpatched workflow branch reads an int count from this legacy entry point; it must equal the
+ # number of problem types the shared helper emitted.
+ scanner = _make_scanner(emits_signals=True)
+ observation = _make_observation(scanner)
+ signals = [self._signal(url="/one"), self._signal(url="/two")]
+
+ with (
+ patch(_EMIT_SIGNAL_PATCH, new_callable=AsyncMock),
+ patch(_LOAD_LLM_INPUTS_PATCH, return_value=None),
+ ):
+ assert emit_observation_signal_activity(self._inputs(observation, signals=signals)) == 2
+
@pytest.mark.asyncio
async def test_apply_scanner_workflow_emits_the_signal_finding() -> None:
@@ -3974,17 +3988,17 @@ async def test_apply_scanner_workflow_emits_the_signal_finding() -> None:
)
],
),
- emit_observation_signal_activity: 1,
+ emit_observation_signals_activity: ["bug"],
},
)
await _run_workflow(_build_inputs(session_id="sess-sig", team_id=99), mocks)
order = [fn for fn, _ in mocks.activity_calls]
- assert order.index(call_scanner_provider_activity) < order.index(emit_observation_signal_activity)
- assert order.index(emit_observation_signal_activity) < order.index(emit_observation_event_activity)
+ assert order.index(call_scanner_provider_activity) < order.index(emit_observation_signals_activity)
+ assert order.index(emit_observation_signals_activity) < order.index(emit_observation_event_activity)
- signal_input = next(arg for fn, arg in mocks.activity_calls if fn is emit_observation_signal_activity)
+ signal_input = next(arg for fn, arg in mocks.activity_calls if fn is emit_observation_signals_activity)
assert signal_input.observation_id == new_observation_id
assert signal_input.exported_asset_id == 42 # threaded from ensure_session_asset_activity
assert signal_input.signals[0].description == "Checkout CTA is broken on /cart"
@@ -3992,6 +4006,8 @@ async def test_apply_scanner_workflow_emits_the_signal_finding() -> None:
succeeded = next(arg for fn, arg in mocks.activity_calls if fn is mark_observation_succeeded_activity)
assert succeeded.scanner_result.signals_count == 1
+ # The distinct problem types ride the row so the watch feed can name the kind of issue.
+ assert succeeded.scanner_result.signal_problem_types == ["bug"]
@pytest.mark.asyncio
@@ -4021,7 +4037,7 @@ async def test_apply_scanner_workflow_succeeds_when_the_signal_activity_fails()
],
),
},
- activity_errors={emit_observation_signal_activity: TimeoutError("start-to-close exceeded")},
+ activity_errors={emit_observation_signals_activity: TimeoutError("start-to-close exceeded")},
)
await _run_workflow(_build_inputs(session_id="sess-sig-fail", team_id=99), mocks)
@@ -4030,3 +4046,47 @@ async def test_apply_scanner_workflow_succeeds_when_the_signal_activity_fails()
assert mark_observation_failed_activity not in called
succeeded = next(arg for fn, arg in mocks.activity_calls if fn is mark_observation_succeeded_activity)
assert succeeded.scanner_result.signals_count == 0
+ assert succeeded.scanner_result.signal_problem_types == []
+
+
+async def test_apply_scanner_workflow_counts_signals_for_pre_patch_histories() -> None:
+ # A workflow whose history predates the problem-types patch scheduled the count-returning activity.
+ # The unpatched branch must keep calling it, derive signals_count from that int, and leave the types
+ # empty — never dispatch the list-returning activity a pre-patch history never recorded.
+ new_observation_id = uuid.uuid4()
+ model_output = MonitorOutput(verdict="yes", reasoning="user hit the broken CTA", confidence=0.9)
+ mocks = _WorkflowMocks(
+ activity_results={
+ create_observation_activity: CreateObservationOutput(
+ observation_id=new_observation_id, was_created=True, scanner_type=ScannerType.MONITOR
+ ),
+ ensure_session_asset_activity: EnsureSessionAssetOutput(asset_id=42),
+ upload_video_to_gemini_activity: UploadedVideo(
+ file_uri="gemini://files/x", mime_type="video/mp4", gemini_file_name="files/x"
+ ),
+ call_scanner_provider_activity: ScannerCallOutput(
+ model_output=model_output,
+ signals=[
+ SignalFinding(
+ problem_type="bug",
+ start_time=30,
+ end_time=35,
+ url="https://app.example.com/cart",
+ description="Checkout CTA is broken on /cart",
+ confidence=0.8,
+ )
+ ],
+ ),
+ emit_observation_signal_activity: 2,
+ },
+ )
+
+ await _run_workflow(_build_inputs(session_id="sess-sig-legacy", team_id=99), mocks, patched=False)
+
+ called = [fn for fn, _ in mocks.activity_calls]
+ assert emit_observation_signal_activity in called
+ assert emit_observation_signals_activity not in called
+ succeeded = next(arg for fn, arg in mocks.activity_calls if fn is mark_observation_succeeded_activity)
+ assert succeeded.scanner_result.signals_count == 2
+ assert succeeded.scanner_result.signal_problem_types == []
diff --git a/products/replay_vision/backend/watch_feed.py b/products/replay_vision/backend/watch_feed.py
index 04d796a5ba4f..2d3caf71e796 100644
--- a/products/replay_vision/backend/watch_feed.py
+++ b/products/replay_vision/backend/watch_feed.py
@@ -36,6 +36,25 @@ NOVEL_SUMMARY_MIN_TOKENS = 8
# viewer could lean on by hammering the broad feed.
NOVEL_SUMMARY_MAX_SIBLINGS = 40
+# Component weights for the blended watchability score. A lone signal outranks a lone anything-else,
+# but a type hit combined with the scan's own notability can outrank a routine signal — the feed is a
+# portfolio of the window's most watchable rows, not signals first and everything after. Retune here.
+WATCH_WEIGHT_SIGNAL = 1.0
+WATCH_WEIGHT_HIT = 0.9
+WATCH_WEIGHT_NOTABILITY = 0.7
+WATCH_WEIGHT_FRICTION = 0.3
+# A row the reader already opened keeps its evidence but drops by this much, so an unviewed peer with
+# comparable evidence comes first while a strong seen row (a signal, a wide outlier) still holds its
+# place above routine unseen rows.
+WATCH_SEEN_PENALTY = 0.5
+# A no-baseline "yes" verdict is the weak conventional something-happened phrasing, so it enters the
+# blend below a verdict the scanner's own window shows to be rare.
+VERDICT_YES_STRENGTH = 0.5
+# The score deviation, in stddevs, at which an outlier counts full strength. The hit fires at
+# OUTLIER_STDDEVS; its strength climbs from there to 1.0 by this many stddevs, so a wider outlier ranks
+# above a marginal one instead of both reading as the same boolean hit.
+OUTLIER_FULL_STDDEVS = 3.0
+
_TOKEN_RE = re.compile(r"[a-z0-9]+")
# Friction language in the model's own prose about the session. Stems, so "retried"/"retrying",
@@ -63,6 +82,7 @@ class _Candidate:
created_at: datetime
viewed: bool
signals_count: int
+ signal_problem_types: tuple[str, ...]
scanner_type: str | None
verdict: str | None
score: float | None
@@ -81,6 +101,10 @@ def _parse_candidate(row: dict[str, Any]) -> _Candidate:
if not isinstance(output, dict):
output = {}
signals_count = result.get("signals_count") if isinstance(result, dict) else 0
+ raw_problem_types = result.get("signal_problem_types") if isinstance(result, dict) else None
+ signal_problem_types = (
+ tuple(pt for pt in raw_problem_types if isinstance(pt, str)) if isinstance(raw_problem_types, list) else ()
+ )
score = output.get("score")
raw_tags = output.get("tags")
raw_freeform = output.get("tags_freeform")
@@ -106,6 +130,7 @@ def _parse_candidate(row: dict[str, Any]) -> _Candidate:
created_at=row["created_at"],
viewed=bool(row.get("feed_viewed")),
signals_count=signals_count if isinstance(signals_count, int) else 0,
+ signal_problem_types=signal_problem_types,
scanner_type=scanner_type,
verdict=verdict,
score=float(score) if isinstance(score, int | float) else None,
@@ -191,8 +216,15 @@ def _max_summary_similarity(candidate: _Candidate, siblings: list[_Candidate]) -
return max(len(candidate.summary_tokens & other) / len(candidate.summary_tokens | other) for other in others)
-def _type_hit(candidate: _Candidate, baseline: _ScannerBaseline, siblings: list[_Candidate]) -> dict[str, Any] | None:
- """The type-specific reason this row stands out for its scanner, or None."""
+def _type_hit(
+ candidate: _Candidate, baseline: _ScannerBaseline, siblings: list[_Candidate]
+) -> tuple[dict[str, Any], float] | None:
+ """The type-specific reason this row stands out for its scanner and how strongly, or None.
+
+ The strength is in (0, 1]: a wide score outlier, a very rare verdict or tag, or a summary unlike
+ its siblings scores near 1; a marginal hit scores near the floor of its rule. It feeds the blended
+ score only — the returned reason dict is unchanged, so the card copy stays the same.
+ """
if candidate.scanner_type == "monitor" and candidate.verdict in ("yes", "no"):
# With a baseline, the notable answer is the scanner's own minority verdict — prompt
# polarity doesn't matter ("did they struggle?" vs "was the experience good?"). Without
@@ -200,13 +232,14 @@ def _type_hit(candidate: _Candidate, baseline: _ScannerBaseline, siblings: list[
if baseline.verdict_shares:
share = baseline.verdict_shares.get(candidate.verdict, 0.0)
if share <= UNUSUAL_VERDICT_MAX_SHARE:
- return {"kind": "unusual_verdict", "verdict": candidate.verdict, "verdict_share": round(share, 3)}
+ reason = {"kind": "unusual_verdict", "verdict": candidate.verdict, "verdict_share": round(share, 3)}
+ return reason, 1.0 - share
elif candidate.verdict == "yes":
- return {"kind": "verdict_yes"}
+ return {"kind": "verdict_yes"}, VERDICT_YES_STRENGTH
if candidate.scanner_type == "summarizer":
similarity = _max_summary_similarity(candidate, siblings)
if similarity is not None and similarity <= NOVEL_SUMMARY_MAX_SIMILARITY:
- return {"kind": "novel_summary"}
+ return {"kind": "novel_summary"}, 1.0 - similarity
if (
candidate.scanner_type == "scorer"
and candidate.score is not None
@@ -216,38 +249,65 @@ def _type_hit(candidate: _Candidate, baseline: _ScannerBaseline, siblings: list[
and baseline.score_stddev > 0
and abs(candidate.score - baseline.score_mean) >= OUTLIER_STDDEVS * baseline.score_stddev
):
- return {"kind": "outlier_score", "score": candidate.score, "window_mean": round(baseline.score_mean, 2)}
+ sigma = abs(candidate.score - baseline.score_mean) / baseline.score_stddev
+ reason = {"kind": "outlier_score", "score": candidate.score, "window_mean": round(baseline.score_mean, 2)}
+ return reason, min(1.0, sigma / OUTLIER_FULL_STDDEVS)
if candidate.scanner_type == "classifier" and baseline.rare_tags:
rare = [(baseline.tag_shares[tag], tag) for tag in set(candidate.tags) if tag in baseline.rare_tags]
if rare:
share, tag = min(rare)
- return {"kind": "rare_tag", "tag": tag, "tag_share": round(share, 3)}
+ return {"kind": "rare_tag", "tag": tag, "tag_share": round(share, 3)}, 1.0 - share
return None
+def _watchability(candidate: _Candidate, hit_strength: float) -> float:
+ """Blend the row's signal, type hit, notability, and friction into one score, then dock a row the
+ reader already opened. Every source contributes at once, so a row wins on the sum of its evidence
+ rather than on a single dominant flag."""
+ signal_strength = 1.0 if candidate.signals_count > 0 else 0.0
+ notability = candidate.notability if candidate.notability is not None else 0.0
+ friction = 1.0 if candidate.friction else 0.0
+ score = (
+ WATCH_WEIGHT_SIGNAL * signal_strength
+ + WATCH_WEIGHT_HIT * hit_strength
+ + WATCH_WEIGHT_NOTABILITY * notability
+ + WATCH_WEIGHT_FRICTION * friction
+ )
+ if candidate.viewed:
+ score -= WATCH_SEEN_PENALTY
+ return score
+
+
def rank_watch_feed_candidates(rows: list[dict[str, Any]]) -> list[WatchFeedEntry]:
"""Rank candidate rows (`id`, `scanner_id`, `created_at`, `scanner_result`, `feed_viewed`) most
- watchable first: signal emitters, then type-specific hits, then unviewed before viewed, then
- the scan's own notability judgment, then prose that reads as friction, then newest.
+ watchable first by a blended score, then newest.
- Signals and type hits encode what the user configured the scanner to find, so a strong hit they
- saw yesterday still outranks unviewed routine rows — seen-state orders rows within those tiers
- rather than above them. Notability and friction are inferred rather than configured, so they stay
- below seen-state: they lift unread rows, never resurface ones a reader already dismissed. The
- notability value also breaks ties inside every tier.
+ The score adds four sources at once — emitted signals, a type-specific hit, the scan's own
+ notability judgment, and prose that reads as friction — each weighted, so a row wins on the sum of
+ its evidence. A type hit plus a high notability can outrank a routine signal, rather than every
+ signal outranking everything else. A row the reader already opened keeps its evidence but is docked,
+ so an unviewed peer comes first while a strong seen row still holds its place above routine unseen
+ rows.
+
+ The displayed reason still names the single strongest source (signal, then hit, then notability,
+ then friction, then seen-state), independent of the score that ordered the row.
"""
candidates = [_parse_candidate(row) for row in rows]
baselines = _baselines(candidates)
by_scanner: dict[UUID, list[_Candidate]] = {}
for candidate in candidates:
by_scanner.setdefault(candidate.scanner_id, []).append(candidate)
- scored: list[tuple[tuple[bool, bool, bool, bool, bool, float, datetime], WatchFeedEntry]] = []
+ scored: list[tuple[tuple[float, datetime], WatchFeedEntry]] = []
for candidate in candidates:
- hit = _type_hit(candidate, baselines[candidate.scanner_id], by_scanner[candidate.scanner_id])
+ hit_result = _type_hit(candidate, baselines[candidate.scanner_id], by_scanner[candidate.scanner_id])
+ hit = hit_result[0] if hit_result is not None else None
+ hit_strength = hit_result[1] if hit_result is not None else 0.0
has_signal = candidate.signals_count > 0
notable = candidate.notability is not None and candidate.notability >= NOTABLE_MIN_SCORE
if has_signal:
reason: dict[str, Any] = {"kind": "signal_emitted", "signals_count": candidate.signals_count}
+ if candidate.signal_problem_types:
+ reason["problem_types"] = list(candidate.signal_problem_types)
elif hit is not None:
reason = hit
elif notable:
@@ -263,16 +323,7 @@ def rank_watch_feed_candidates(rows: list[dict[str, Any]]) -> list[WatchFeedEntr
# score, and gating on `notable` alone would attach the sentence over the copy that row earned.
if candidate.notability_reason and reason["kind"] == "notable":
reason["notability_reason"] = candidate.notability_reason
- sort_key = (
- has_signal,
- hit is not None,
- not candidate.viewed,
- notable,
- candidate.friction,
- # -1.0 keeps an unjudged row (pre-notability, None) below a judged-routine 0.0 in the tiebreak.
- candidate.notability if candidate.notability is not None else -1.0,
- candidate.created_at,
- )
+ sort_key = (_watchability(candidate, hit_strength), candidate.created_at)
scored.append((sort_key, WatchFeedEntry(observation_id=candidate.observation_id, reason=reason)))
scored.sort(key=lambda item: item[0], reverse=True)
return [entry for _, entry in scored]
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index 727312b2d2c5..43b52bf3e479 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -2387,6 +2387,8 @@ export interface WatchFeedReasonApi {
* @nullable
*/
signals_count?: number | null
+ /** Issue type of each emitted signal (`bug`, `crash`, `design_flaw`, `ux_friction`), one entry per signal in the order raised, for `signal_emitted`. Absent on signals scanned before this shipped. */
+ problem_types?: string[]
/**
* The monitor's answer, for `unusual_verdict`.
* @nullable
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
index 541ef319dcc9..216027db930c 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
@@ -9,6 +9,38 @@ describe('WatchFeedCard helpers', () => {
reason: { kind: 'signal_emitted', signals_count: 3 } as WatchFeedReasonApi,
expected: 'The scanner raised 3 signals from this session.',
},
+ {
+ name: 'names a single signal problem type',
+ reason: { kind: 'signal_emitted', signals_count: 1, problem_types: ['bug'] } as WatchFeedReasonApi,
+ expected: 'The scanner raised a bug signal from this session.',
+ },
+ {
+ name: 'names and counts one repeated problem type',
+ reason: {
+ kind: 'signal_emitted',
+ signals_count: 3,
+ problem_types: ['bug', 'bug', 'bug'],
+ } as WatchFeedReasonApi,
+ expected: 'The scanner raised 3 bug signals from this session.',
+ },
+ {
+ name: 'breaks mixed problem types down by count',
+ reason: {
+ kind: 'signal_emitted',
+ signals_count: 2,
+ problem_types: ['bug', 'ux_friction'],
+ } as WatchFeedReasonApi,
+ expected: 'The scanner raised 2 signals from this session: 1 bug signal, 1 UX friction signal.',
+ },
+ {
+ name: 'pluralizes and orders each type in a mixed breakdown',
+ reason: {
+ kind: 'signal_emitted',
+ signals_count: 3,
+ problem_types: ['bug', 'bug', 'ux_friction'],
+ } as WatchFeedReasonApi,
+ expected: 'The scanner raised 3 signals from this session: 2 bug signals, 1 UX friction signal.',
+ },
{
name: 'rounds the score and window average',
reason: { kind: 'outlier_score', score: 9.53846, window_mean: 5.1428 } as WatchFeedReasonApi,
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
index 06d4768fe416..cb234a9fca11 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
@@ -19,6 +19,16 @@ import { ScannerType } from '../types'
const roundScore = (value: number): number => Math.round(value * 100) / 100
+const PROBLEM_TYPE_LABELS: Record<string, string> = {
+ bug: 'bug',
+ crash: 'crash',
+ design_flaw: 'design flaw',
+ ux_friction: 'UX friction',
+}
+
+const problemTypeLabel = (problemType: string): string =>
+ PROBLEM_TYPE_LABELS[problemType] ?? problemType.replace(/_/g, ' ')
+
export function watchReasonCopy(reason: WatchFeedReasonApi): string {
// The scan wrote this sentence while watching the session, so it beats anything derived from the
// reason kind. Absent on observations scanned before notability shipped, which fall through below.
@@ -26,10 +36,37 @@ export function watchReasonCopy(reason: WatchFeedReasonApi): string {
return reason.notability_reason
}
switch (reason.kind) {
- case 'signal_emitted':
- return (reason.signals_count ?? 0) > 1
- ? `The scanner raised ${reason.signals_count} signals from this session.`
- : 'The scanner raised a signal from this session.'
+ case 'signal_emitted': {
+ const total = reason.signals_count ?? 0
+ const problemTypes = reason.problem_types ?? []
+ if (problemTypes.length === 0) {
+ return total > 1
+ ? `The scanner raised ${total} signals from this session.`
+ : 'The scanner raised a signal from this session.'
+ }
+ // Count each problem type, keeping the order the scan first raised them.
+ const order: string[] = []
+ const countByType = new Map<string, number>()
+ for (const problemType of problemTypes) {
+ if (!countByType.has(problemType)) {
+ order.push(problemType)
+ }
+ countByType.set(problemType, (countByType.get(problemType) ?? 0) + 1)
+ }
+ if (order.length === 1) {
+ const label = problemTypeLabel(order[0])
+ return total > 1
+ ? `The scanner raised ${total} ${label} signals from this session.`
+ : `The scanner raised a ${label} signal from this session.`
+ }
+ const breakdown = order
+ .map((problemType) => {
+ const n = countByType.get(problemType) ?? 0
+ return `${n} ${problemTypeLabel(problemType)} signal${n === 1 ? '' : 's'}`
+ })
+ .join(', ')
+ return `The scanner raised ${total} signals from this session: ${breakdown}.`
+ }
case 'unusual_verdict':
return reason.verdict
? `The scanner answered ${reason.verdict}, which is rare for it in this window.`
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index b19488dc251d..65f53222e001 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -95265,6 +95265,8 @@ export namespace Schemas {
* @nullable
*/
signals_count?: number | null;
+ /** Issue type of each emitted signal (`bug`, `crash`, `design_flaw`, `ux_friction`), one entry per signal in the order raised, for `signal_emitted`. Absent on signals scanned before this shipped. */
+ problem_types?: string[];
/**
* The monitor's answer, for `unusual_verdict`.
* @nullable