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): filter scorer observations by score (#80993)

coryslaterfe608baa379c
diff --git a/products/replay_vision/backend/api/observations.py b/products/replay_vision/backend/api/observations.py
index 25f556afcc6d..c0dd4c0ca870 100644
--- a/products/replay_vision/backend/api/observations.py
+++ b/products/replay_vision/backend/api/observations.py
@@ -69,6 +69,26 @@ def _jsonb_typeof(expr: Any) -> Func:
return Func(expr, function="JSONB_TYPEOF", output_field=CharField())
+def _annotate_output_number(qs: QuerySet[ReplayObservation], key: str, alias: str) -> QuerySet[ReplayObservation]:
+ """Annotate `alias` with `scanner_result.model_output.<key>` as a float, null when the value isn't numeric.
+
+ CASE-guard the cast so schema drift or a manual fixup (a `score` stored as a string) can't 500 the query.
+ """
+ type_alias = f"{alias}_type"
+ value_jsonb = KeyTransform(key, KeyTransform("model_output", "scanner_result"))
+ value_text = KeyTextTransform(key, KeyTextTransform("model_output", "scanner_result"))
+ return qs.annotate(
+ **{
+ type_alias: _jsonb_typeof(value_jsonb),
+ alias: Case(
+ When(**{type_alias: "number"}, then=Cast(value_text, FloatField())),
+ default=Value(None),
+ output_field=FloatField(),
+ ),
+ }
+ )
+
+
class ScannerSnapshotSerializer(serializers.Serializer):
"""Mirrors `temporal.types.ScannerSnapshot` for OpenAPI generation."""
@@ -440,6 +460,9 @@ _ALL_ORDER_KEYS = OBSERVATION_ORDER_FIELDS + _JSONB_ORDER_KEYS + ("recording_sub
# Derived from the scanner output schema so the filter can never drift from what monitors emit.
_MONITOR_VERDICTS = frozenset(get_args(MonitorVerdict))
+# Annotation alias for the scorer score bounds; kept apart from the ordering aliases so both can apply at once.
+_SCORE_FILTER_ALIAS = "_filter_score"
+
class _ObservationOrderByFilter(OrderByFilter):
"""Observation-specific ordering: plain columns + JSONB-backed keys with numeric casts and nulls-last."""
@@ -460,30 +483,13 @@ class _ObservationOrderByFilter(OrderByFilter):
# labeled sessions cluster together (asc: incorrect then correct; desc: correct then incorrect).
return self._order_nulls_last(qs, "label__is_correct", descending)
if key == "result_score":
- # CASE-guard the cast so a non-numeric `score` (schema drift, manual fixup) doesn't 500 the query.
- score_jsonb = KeyTransform("score", KeyTransform("model_output", "scanner_result"))
- score_text = KeyTextTransform("score", KeyTextTransform("model_output", "scanner_result"))
- qs = qs.annotate(
- _score_type=_jsonb_typeof(score_jsonb),
- _order_score=Case(
- When(_score_type="number", then=Cast(score_text, FloatField())),
- default=Value(None),
- output_field=FloatField(),
- ),
+ return self._order_nulls_last(
+ _annotate_output_number(qs, "score", "_order_score"), "_order_score", descending
)
- return self._order_nulls_last(qs, "_order_score", descending)
if key == "result_confidence":
- confidence_jsonb = KeyTransform("confidence", KeyTransform("model_output", "scanner_result"))
- confidence_text = KeyTextTransform("confidence", KeyTextTransform("model_output", "scanner_result"))
- qs = qs.annotate(
- _confidence_type=_jsonb_typeof(confidence_jsonb),
- _order_confidence=Case(
- When(_confidence_type="number", then=Cast(confidence_text, FloatField())),
- default=Value(None),
- output_field=FloatField(),
- ),
+ return self._order_nulls_last(
+ _annotate_output_number(qs, "confidence", "_order_confidence"), "_order_confidence", descending
)
- return self._order_nulls_last(qs, "_order_confidence", descending)
if key == "scanner_version":
version_jsonb = KeyTransform("scanner_version", "scanner_snapshot")
version_text = KeyTextTransform("scanner_version", "scanner_snapshot")
@@ -529,6 +535,20 @@ class ReplayObservationFilter(django_filters.FilterSet):
error_key="verdict",
help_text="Filter monitor observations by verdict. Accepts a comma-separated list (e.g. `yes,inconclusive`).",
)
+ min_score = django_filters.NumberFilter(
+ method="_filter_min_score",
+ help_text=(
+ "Filter scorer observations to those scoring at or above this value. Rows with no numeric score "
+ "(other scanner types, failed or in-flight runs) are excluded."
+ ),
+ )
+ max_score = django_filters.NumberFilter(
+ method="_filter_max_score",
+ help_text=(
+ "Filter scorer observations to those scoring at or below this value. Rows with no numeric score "
+ "(other scanner types, failed or in-flight runs) are excluded."
+ ),
+ )
tags = django_filters.CharFilter(
method="_filter_tags",
help_text=(
@@ -594,7 +614,9 @@ class ReplayObservationFilter(django_filters.FilterSet):
return [
OpenApiParameter(
name,
- str,
+ # Numeric filters must not surface as strings, or the generated clients type them
+ # differently here than on the list endpoint drf-spectacular discovers on its own.
+ float if isinstance(field, django_filters.NumberFilter) else str,
OpenApiParameter.QUERY,
required=False,
description=str(field.extra.get("help_text", "")),
@@ -622,6 +644,26 @@ class ReplayObservationFilter(django_filters.FilterSet):
parsed = parsed.replace(hour=23, minute=59, second=59, microsecond=999999)
return queryset.filter(created_at__lte=parsed)
+ def _scored(self, queryset: QuerySet[ReplayObservation]) -> QuerySet[ReplayObservation]:
+ # min_score and max_score can arrive together, and re-annotating the same alias raises.
+ if _SCORE_FILTER_ALIAS in queryset.query.annotations:
+ return queryset
+ return _annotate_output_number(queryset, "score", _SCORE_FILTER_ALIAS)
+
+ # Both bounds look up the annotation `_scored` adds, via a literal key in a `**` dict: a plain
+ # keyword can't be used because django-stubs resolves those against the model's real fields.
+ # The key is spelled out rather than built from `_SCORE_FILTER_ALIAS` so no variable reaches a
+ # filter lookup; rename the alias and these two have to move with it.
+ def _filter_min_score(
+ self, queryset: QuerySet[ReplayObservation], _name: str, value: float
+ ) -> QuerySet[ReplayObservation]:
+ return self._scored(queryset).filter(**{"_filter_score__gte": value})
+
+ def _filter_max_score(
+ self, queryset: QuerySet[ReplayObservation], _name: str, value: float
+ ) -> QuerySet[ReplayObservation]:
+ return self._scored(queryset).filter(**{"_filter_score__lte": value})
+
def _filter_tags(
self, queryset: QuerySet[ReplayObservation], _name: str, value: str
) -> QuerySet[ReplayObservation]:
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index bcb97cc9bdf0..605333d98aba 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -1489,6 +1489,8 @@ class TestReplayObservationViewSet(_VisionAPITestCase):
("status=bogus", "status"),
("triggered_by=hack", "triggered_by"),
("verdict=maybe", "verdict"),
+ ("min_score=low", "min_score"),
+ ("max_score=high", "max_score"),
("order_by=garbage", "order_by"),
("order_by=-result_score_typo", "order_by"),
]
@@ -1551,6 +1553,62 @@ class TestReplayObservationViewSet(_VisionAPITestCase):
sessions = [r["session_id"] for r in resp.json()["results"]]
self.assertEqual(sessions, ["sess-1", "sess-0", "sess-2"])
+ def _create_scorer_with_scores(self, scores: list[Any]) -> ReplayScanner:
+ scorer = self._create_scanner(
+ name="frustration",
+ scanner_type=ScannerType.SCORER,
+ scanner_config={"prompt": "p", "scale": {"min": 0, "max": 10}},
+ )
+ for idx, score in enumerate(scores):
+ ReplayObservation.objects.create(
+ scanner=scorer,
+ session_id=f"sess-{idx}",
+ scanner_snapshot=_snapshot_for(scorer),
+ triggered_by=ObservationTrigger.SCHEDULE,
+ status=ObservationStatus.SUCCEEDED,
+ completed_at=timezone.now(),
+ scanner_result={
+ "model_output": {"scanner_type": "scorer", "score": score, "reasoning": "r", "confidence": 0.5},
+ "signals_count": 0,
+ },
+ )
+ return scorer
+
+ @parameterized.expand(
+ [
+ ("at_least", "min_score=7", ["sess-1", "sess-3"]),
+ ("at_most", "max_score=3", ["sess-0", "sess-2"]),
+ ("range", "min_score=3&max_score=7", ["sess-0", "sess-3"]),
+ # Bounds are inclusive, and 10 must not lose to a lexicographic comparison against 7.
+ ("boundary", "min_score=10", ["sess-1"]),
+ ]
+ )
+ def test_filterset_score_bounds(self, _name: str, query: str, expected: list[str]) -> None:
+ scorer = self._create_scorer_with_scores([3.0, 10.0, 0.5, 7.0])
+ resp = self.client.get(f"{self.observations_url(str(scorer.id))}?{query}")
+ self.assertEqual(resp.status_code, 200, resp.json())
+ self.assertEqual(sorted(r["session_id"] for r in resp.json()["results"]), expected)
+
+ def test_filterset_score_bounds_exclude_rows_without_a_numeric_score(self) -> None:
+ # A pending run has no result at all, and schema drift can leave `score` a string; neither may 500 or match.
+ scorer = self._create_scorer_with_scores([5.0, "not-a-number"])
+ ReplayObservation.objects.create(
+ scanner=scorer,
+ session_id="sess-pending",
+ scanner_snapshot=_snapshot_for(scorer),
+ triggered_by=ObservationTrigger.SCHEDULE,
+ )
+ resp = self.client.get(f"{self.observations_url(str(scorer.id))}?min_score=0&max_score=10")
+ self.assertEqual(resp.status_code, 200, resp.json())
+ self.assertEqual([r["session_id"] for r in resp.json()["results"]], ["sess-0"])
+
+ def test_filterset_score_bounds_combine_with_ordering(self) -> None:
+ # Both annotate the score off the same JSONB path; applying them together must not collide.
+ scorer = self._create_scorer_with_scores([3.0, 10.0, 0.5, 7.0])
+ resp = self.client.get(f"{self.observations_url(str(scorer.id))}?min_score=3&order_by=-result_score")
+ self.assertEqual(resp.status_code, 200, resp.json())
+ self.assertEqual([r["session_id"] for r in resp.json()["results"]], ["sess-1", "sess-3", "sess-0"])
+
def test_order_by_scanner_version_numeric(self) -> None:
snap_v1 = {**_snapshot_for(self.scanner), "scanner_version": 1}
snap_v2 = {**_snapshot_for(self.scanner), "scanner_version": 2}
diff --git a/products/replay_vision/frontend/components/ScoreRangeFilterPill.test.ts b/products/replay_vision/frontend/components/ScoreRangeFilterPill.test.ts
new file mode 100644
index 000000000000..7d6a6d2a6588
--- /dev/null
+++ b/products/replay_vision/frontend/components/ScoreRangeFilterPill.test.ts
@@ -0,0 +1,29 @@
+import { scoreRangeLabel, toScoreBound } from './ScoreRangeFilterPill'
+
+describe('toScoreBound', () => {
+ it('passes finite numbers through, including 0', () => {
+ expect(toScoreBound(7)).toBe(7)
+ expect(toScoreBound(0)).toBe(0)
+ expect(toScoreBound(-1.5)).toBe(-1.5)
+ })
+
+ it('maps a cleared input (NaN) to null', () => {
+ // LemonInput type="number" reports an empty field as NaN via valueAsNumber
+ expect(toScoreBound(NaN)).toBeNull()
+ })
+
+ it('maps undefined and non-finite values to null', () => {
+ expect(toScoreBound(undefined)).toBeNull()
+ expect(toScoreBound(Infinity)).toBeNull()
+ expect(toScoreBound(-Infinity)).toBeNull()
+ })
+})
+
+describe('scoreRangeLabel', () => {
+ it('covers all four bound states', () => {
+ expect(scoreRangeLabel(null, null)).toBe('Score')
+ expect(scoreRangeLabel(3, null)).toBe('Score ≥ 3')
+ expect(scoreRangeLabel(null, 8)).toBe('Score ≤ 8')
+ expect(scoreRangeLabel(3, 8)).toBe('Score 3 to 8')
+ })
+})
diff --git a/products/replay_vision/frontend/components/ScoreRangeFilterPill.tsx b/products/replay_vision/frontend/components/ScoreRangeFilterPill.tsx
new file mode 100644
index 000000000000..62144155338c
--- /dev/null
+++ b/products/replay_vision/frontend/components/ScoreRangeFilterPill.tsx
@@ -0,0 +1,91 @@
+import { LemonButton, LemonButtonWithDropdown, LemonInput } from '@posthog/lemon-ui'
+
+/** Compact summary for the pill face, so an active range is readable without opening the dropdown. */
+export function scoreRangeLabel(min: number | null, max: number | null): string {
+ if (min !== null && max !== null) {
+ return `Score ${min} to ${max}`
+ }
+ if (min !== null) {
+ return `Score ≥ ${min}`
+ }
+ if (max !== null) {
+ return `Score ≤ ${max}`
+ }
+ return 'Score'
+}
+
+/** LemonInput type="number" reports an empty field as NaN, so treat anything non-finite as unset. */
+export function toScoreBound(raw: number | undefined): number | null {
+ return typeof raw === 'number' && Number.isFinite(raw) ? raw : null
+}
+
+/**
+ * Bounds filter for a scorer's numeric result. Two open-ended inputs rather than an operator
+ * dropdown, because that covers "at least", "at most", and a range without a mode to pick first.
+ */
+export function ScoreRangeFilterPill({
+ min,
+ max,
+ scaleMin,
+ scaleMax,
+ onChange,
+}: {
+ min: number | null
+ max: number | null
+ /** The scanner's configured scale, used as input bounds and as placeholder hints. */
+ scaleMin?: number
+ scaleMax?: number
+ onChange: (min: number | null, max: number | null) => void
+}): JSX.Element {
+ return (
+ <LemonButtonWithDropdown
+ type="secondary"
+ size="small"
+ data-attr="vision-observations-score-filter"
+ dropdown={{
+ closeOnClickInside: false,
+ overlay: (
+ <div className="p-2 w-56 flex flex-col gap-2">
+ <div className="flex items-center gap-2">
+ <span className="text-muted text-xs w-16">At least</span>
+ <LemonInput
+ type="number"
+ size="small"
+ min={scaleMin}
+ max={scaleMax}
+ placeholder={scaleMin !== undefined ? String(scaleMin) : undefined}
+ value={min ?? undefined}
+ onChange={(value) => onChange(toScoreBound(value), max)}
+ className="flex-1"
+ />
+ </div>
+ <div className="flex items-center gap-2">
+ <span className="text-muted text-xs w-16">At most</span>
+ <LemonInput
+ type="number"
+ size="small"
+ min={scaleMin}
+ max={scaleMax}
+ placeholder={scaleMax !== undefined ? String(scaleMax) : undefined}
+ value={max ?? undefined}
+ onChange={(value) => onChange(min, toScoreBound(value))}
+ className="flex-1"
+ />
+ </div>
+ <LemonButton
+ size="small"
+ fullWidth
+ center
+ onClick={() => onChange(null, null)}
+ disabledReason={min === null && max === null ? 'No score filter set' : undefined}
+ >
+ Clear
+ </LemonButton>
+ </div>
+ ),
+ }}
+ >
+ {scoreRangeLabel(min, max)}
+ </LemonButtonWithDropdown>
+ )
+}
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index ff6f95adbef8..6031034e1e25 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -1785,6 +1785,14 @@ export type VisionObservationsRetrieveParams = {
* When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.
*/
labeled?: string
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number
/**
* Sort observations. Plain keys: created_at, started_at, completed_at, status, recording_subject_email. JSONB keys: result_score (scorer), result_verdict (monitor), result_confidence, scanner_version. Prefix with `-` for descending; nullable keys sort nulls last either way.
*/
@@ -1911,6 +1919,14 @@ export type VisionScannersObservationsListParams = {
* Number of results to return per page.
*/
limit?: number
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number
/**
* The initial index from which to return the results.
*/
@@ -1962,6 +1978,14 @@ export type VisionScannersObservationsRetrieveParams = {
* When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.
*/
labeled?: string
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number
/**
* Sort observations. Plain keys: created_at, started_at, completed_at, status, recording_subject_email. JSONB keys: result_score (scorer), result_verdict (monitor), result_confidence, scanner_version. Prefix with `-` for descending; nullable keys sort nulls last either way.
*/
@@ -2009,6 +2033,14 @@ export type VisionScannersObservationsStatsRetrieveParams = {
* When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.
*/
labeled?: string
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number
/**
* Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.
*/
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.ts b/products/replay_vision/frontend/observations/replayObservationLogic.ts
index bcc615eb5597..e9c05dd98db8 100644
--- a/products/replay_vision/frontend/observations/replayObservationLogic.ts
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.ts
@@ -10,6 +10,7 @@ import type { ReplayObservationApi, VisionObservationsRetrieveParams } from '../
import { scheduleObservationPoll } from '../logics/observationPolling'
import { requestObservationRetry } from '../logics/observationRetry'
import { OBSERVATION_LIST_FILTER_KEYS } from '../replay_scanners/types'
+import { parseNumericParam } from '../utils/urlParams'
import { observationProgressLogic } from './observationProgressLogic'
import { replayObservationSceneLogic } from './replayObservationSceneLogic'
@@ -17,20 +18,28 @@ export interface ReplayObservationLogicProps {
id: string
}
+/** Filters the API types as numbers; the URL only ever carries strings, so these need parsing back. */
+const NUMERIC_FILTER_KEYS: readonly string[] = ['min_score', 'max_score']
+
/** List filters carried in the observation URL; passed to retrieve so prev/next stay within the filtered set. */
export function neighborFilterParams(searchParams: Record<string, unknown>): VisionObservationsRetrieveParams {
- const params: Record<string, string> = {}
+ const params: Record<string, string | number> = {}
for (const key of OBSERVATION_LIST_FILTER_KEYS) {
const value = searchParams[key]
- if (typeof value === 'string' && value) {
+ if (NUMERIC_FILTER_KEYS.includes(key)) {
+ const parsed = parseNumericParam(value)
+ if (parsed !== null) {
+ params[key] = parsed
+ }
+ } else if (typeof value === 'string' && value) {
params[key] = value
}
}
- return params
+ return params as VisionObservationsRetrieveParams
}
/** Canonical link to an observation's detail page, carrying list filters so prev/next honors them. */
-export function observationDetailUrl(id: string, filterParams: Record<string, string>): string {
+export function observationDetailUrl(id: string, filterParams: Record<string, string | number>): string {
return combineUrl(urls.replayVisionObservation(id), filterParams).url
}
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
index c6cd80f3e27a..bd4a99d181c2 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
@@ -14,6 +14,7 @@ import { DateMappingOption } from '~/types'
import { FilterPill } from '../../components/FilterPill'
import { ObservationResultSummary, ObservationStatusTag } from '../../components/ObservationCard'
import { ObservationRetryButton } from '../../components/ObservationRetryButton'
+import { ScoreRangeFilterPill } from '../../components/ScoreRangeFilterPill'
import type { ReplayObservationApi } from '../../generated/api.schemas'
import { observationDetailUrl } from '../../observations/replayObservationLogic'
import {
@@ -90,6 +91,8 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
observationTriggeredByFilter,
observationVerdictFilter,
observationTagFilter,
+ observationMinScoreFilter,
+ observationMaxScoreFilter,
observationSubjectFilter,
observationDateFrom,
observationDateTo,
@@ -112,6 +115,7 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
setObservationTriggeredByFilter,
setObservationVerdictFilter,
setObservationTagFilter,
+ setObservationScoreRange,
setObservationSubjectFilter,
setObservationDateRange,
setObservationBackfillFilter,
@@ -120,6 +124,7 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
} = useActions(logic)
const scannerType = scanner?.scanner_type
const tagFilterOptions = availableTags.map((tag) => ({ value: tag, label: tag }))
+ const scoreScale = scanner?.scanner_type === 'scorer' ? scanner.scanner_config.scale : undefined
const columns: LemonTableColumns<ReplayObservationApi> = [
{
@@ -283,6 +288,15 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
onChange={setObservationVerdictFilter}
/>
)}
+ {scannerType === 'scorer' && (
+ <ScoreRangeFilterPill
+ min={observationMinScoreFilter}
+ max={observationMaxScoreFilter}
+ scaleMin={scoreScale?.min}
+ scaleMax={scoreScale?.max}
+ onChange={setObservationScoreRange}
+ />
+ )}
{scannerType === 'classifier' && tagFilterOptions.length > 0 && (
<FilterPill<string>
label="Tag"
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
index bd9e5af2de0f..ed7e257ccbce 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
@@ -8,7 +8,7 @@ import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { parseCsvParam, parseSortParam } from '../utils/urlParams'
+import { parseCsvParam, parseNumericParam, parseSortParam } from '../utils/urlParams'
import {
buildObservationListParams,
ObservationStatusValue,
@@ -512,6 +512,8 @@ describe('replayScannerLogic', () => {
observationTriggeredByFilter: [] as ObservationTriggeredByValue[],
observationVerdictFilter: [] as ObservationVerdictValue[],
observationTagFilter: [] as string[],
+ observationMinScoreFilter: null as number | null,
+ observationMaxScoreFilter: null as number | null,
observationSubjectFilter: '',
observationDateFrom: null as string | null,
observationDateTo: null as string | null,
@@ -549,6 +551,19 @@ describe('replayScannerLogic', () => {
expect(params.tags).toBe('onboarding,support')
})
+ it('passes score bounds only when set, including a zero bound', () => {
+ expect(buildObservationListParams({ ...emptyValues, observationMinScoreFilter: 7 })).toEqual({
+ min_score: 7,
+ })
+ expect(
+ buildObservationListParams({
+ ...emptyValues,
+ observationMinScoreFilter: 0,
+ observationMaxScoreFilter: 3.5,
+ })
+ ).toEqual({ min_score: 0, max_score: 3.5 })
+ })
+
it('passes date range only when set', () => {
const params = buildObservationListParams({
...emptyValues,
@@ -644,6 +659,21 @@ describe('replayScannerLogic', () => {
})
})
+ describe('parseNumericParam', () => {
+ it.each([
+ [undefined, null],
+ // Number('') is 0, so an absent bound must be rejected before the cast.
+ ['', null],
+ [' ', null],
+ ['abc', null],
+ ['0', 0],
+ ['3.5', 3.5],
+ [7, 7],
+ ])('parses %p as %p', (input, expected) => {
+ expect(parseNumericParam(input)).toBe(expected)
+ })
+ })
+
describe('observationsPage / sort URL sync', () => {
let scannedLogic: ReturnType<typeof replayScannerLogic.build>
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index 366cdc9e2912..072ad5d295d8 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -52,7 +52,13 @@ import { OBSERVE_POLL_GRACE_MS, scheduleObservationPoll, shouldPollObservations
import { requestObservationRetry } from '../logics/observationRetry'
import { refreshVisionQuota } from '../logics/visionQuotaLogic'
import { observationClipboardText } from '../utils/observation'
-import { type UrlSorting, parseCsvParam, parseSortParam, serializeSortParam } from '../utils/urlParams'
+import {
+ type UrlSorting,
+ parseCsvParam,
+ parseNumericParam,
+ parseSortParam,
+ serializeSortParam,
+} from '../utils/urlParams'
import { clampDurationFilter, durationFilterError } from './durationBounds'
import { clearScannerDraft, readScannerDraft, writeScannerDraft } from './scannerDraft'
import {
@@ -126,6 +132,8 @@ interface ObservationListParams {
backfill_id?: string
verdict?: string
tags?: string
+ min_score?: number
+ max_score?: number
recording_subject?: string
date_from?: string
date_to?: string
@@ -158,23 +166,31 @@ interface ObservationFilterValues {
observationTriggeredByFilter: ObservationTriggeredByValue[]
observationVerdictFilter: ObservationVerdictValue[]
observationTagFilter: string[]
+ observationMinScoreFilter: number | null
+ observationMaxScoreFilter: number | null
observationSubjectFilter: string
observationDateFrom: string | null
observationDateTo: string | null
observationBackfillFilter: string | null
}
+type ObservationFilterParamKeys =
+ | 'status'
+ | 'triggered_by'
+ | 'verdict'
+ | 'tags'
+ | 'min_score'
+ | 'max_score'
+ | 'recording_subject'
+ | 'date_from'
+ | 'date_to'
+ | 'backfill_id'
+
/** The filter (non-pagination, non-sort) params shared by the list/stats endpoints and the URL query string. */
function observationFilterParams(
values: ObservationFilterValues
-): Pick<
- ObservationListParams,
- 'status' | 'triggered_by' | 'verdict' | 'tags' | 'recording_subject' | 'date_from' | 'date_to' | 'backfill_id'
-> {
- const params: Pick<
- ObservationListParams,
- 'status' | 'triggered_by' | 'verdict' | 'tags' | 'recording_subject' | 'date_from' | 'date_to' | 'backfill_id'
- > = {}
+): Pick<ObservationListParams, ObservationFilterParamKeys> {
+ const params: Pick<ObservationListParams, ObservationFilterParamKeys> = {}
if (values.observationStatusFilter.length > 0) {
params.status = values.observationStatusFilter.join(',')
}
@@ -187,6 +203,12 @@ function observationFilterParams(
if (values.observationTagFilter.length > 0) {
params.tags = values.observationTagFilter.join(',')
}
+ if (values.observationMinScoreFilter !== null) {
+ params.min_score = values.observationMinScoreFilter
+ }
+ if (values.observationMaxScoreFilter !== null) {
+ params.max_score = values.observationMaxScoreFilter
+ }
if (values.observationSubjectFilter.trim()) {
params.recording_subject = values.observationSubjectFilter.trim()
}
@@ -248,7 +270,9 @@ export interface replayScannerLogicValues {
observationBackfillFilter: string | null
observationDateFrom: string | null
observationDateTo: string | null
- observationDetailLinkParams: Record<string, string>
+ observationDetailLinkParams: Record<string, number | string>
+ observationMaxScoreFilter: number | null
+ observationMinScoreFilter: number | null
observationStats: ObservationStatusStats
observationStatsApi: ObservationStatsApi | null
observationStatsApiLoading: boolean
@@ -384,6 +408,8 @@ export interface replayScannerLogicActions {
backfillId: string | null
dateFrom: string | null
dateTo: string | null
+ maxScore: number | null
+ minScore: number | null
page: number
sort: ObservationsSorting | null
status: ObservationStatusValue[]
@@ -395,6 +421,8 @@ export interface replayScannerLogicActions {
backfillId: string | null
dateFrom: string | null
dateTo: string | null
+ maxScore: number | null
+ minScore: number | null
page: number
sort: ObservationsSorting | null
status: ObservationStatusEnumApi[]
@@ -457,6 +485,13 @@ export interface replayScannerLogicActions {
dateFrom: string | null
dateTo: string | null
}
+ setObservationScoreRange: (
+ minScore: number | null,
+ maxScore: number | null
+ ) => {
+ maxScore: number | null
+ minScore: number | null
+ }
setObservationStatusFilter: (values: ObservationStatusValue[]) => {
values: ObservationStatusEnumApi[]
}
@@ -559,6 +594,8 @@ export interface replayScannerLogicMeta {
observationTriggeredByFilter: ObservationTriggerEnumApi[],
observationVerdictFilter: ObservationVerdictValue[],
observationTagFilter: string[],
+ observationMinScoreFilter: number | null,
+ observationMaxScoreFilter: number | null,
observationSubjectFilter: string,
observationDateFrom: string | null,
observationDateTo: string | null,
@@ -569,13 +606,15 @@ export interface replayScannerLogicMeta {
observationTriggeredByFilter: ObservationTriggerEnumApi[],
observationVerdictFilter: ObservationVerdictValue[],
observationTagFilter: string[],
+ observationMinScoreFilter: number | null,
+ observationMaxScoreFilter: number | null,
observationSubjectFilter: string,
observationDateFrom: string | null,
observationDateTo: string | null,
observationBackfillFilter: string | null,
observationsSort: ObservationsSorting | null,
scanner: ReplayScanner
- ) => Record<string, string>
+ ) => Record<string, number | string>
availableTags: (observationStatsApi: ObservationStatsApi | null) => string[]
observationStats: (observationStatsApi: ObservationStatsApi | null) => ObservationStatusStats
sidePanelContext: (scanner: ReplayScanner, isNew: boolean) => SidePanelSceneContext | null
@@ -625,6 +664,7 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
setObservationTriggeredByFilter: (values: ObservationTriggeredByValue[]) => ({ values }),
setObservationVerdictFilter: (values: ObservationVerdictValue[]) => ({ values }),
setObservationTagFilter: (values: string[]) => ({ values }),
+ setObservationScoreRange: (minScore: number | null, maxScore: number | null) => ({ minScore, maxScore }),
setObservationSubjectFilter: (value: string) => ({ value }),
setObservationDateRange: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }),
setObservationBackfillFilter: (value: string | null) => ({ value }),
@@ -636,6 +676,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
triggeredBy: ObservationTriggeredByValue[]
verdict: ObservationVerdictValue[]
tags: string[]
+ minScore: number | null
+ maxScore: number | null
subject: string
dateFrom: string | null
dateTo: string | null
@@ -920,6 +962,7 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
setObservationTriggeredByFilter: () => 1,
setObservationVerdictFilter: () => 1,
setObservationTagFilter: () => 1,
+ setObservationScoreRange: () => 1,
setObservationSubjectFilter: () => 1,
setObservationDateRange: () => 1,
setObservationsSort: () => 1,
@@ -1019,6 +1062,22 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
restoreObservationsTableState: (_, { tags }) => tags,
},
],
+ observationMinScoreFilter: [
+ null as number | null,
+ {
+ setObservationScoreRange: (_, { minScore }) => minScore,
+ clearObservationFilters: () => null,
+ restoreObservationsTableState: (_, { minScore }) => minScore,
+ },
+ ],
+ observationMaxScoreFilter: [
+ null as number | null,
+ {
+ setObservationScoreRange: (_, { maxScore }) => maxScore,
+ clearObservationFilters: () => null,
+ restoreObservationsTableState: (_, { maxScore }) => maxScore,
+ },
+ ],
observationSubjectFilter: [
'' as string,
{
@@ -1088,6 +1147,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
s.observationTriggeredByFilter,
s.observationVerdictFilter,
s.observationTagFilter,
+ s.observationMinScoreFilter,
+ s.observationMaxScoreFilter,
s.observationSubjectFilter,
s.observationDateFrom,
s.observationDateTo,
@@ -1098,6 +1159,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
triggeredByFilter: ObservationTriggeredByValue[],
verdictFilter: ObservationVerdictValue[],
tagFilter: string[],
+ minScore: number | null,
+ maxScore: number | null,
subjectFilter: string,
dateFrom: string | null,
dateTo: string | null,
@@ -1107,6 +1170,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
triggeredByFilter.length > 0 ||
verdictFilter.length > 0 ||
tagFilter.length > 0 ||
+ minScore !== null ||
+ maxScore !== null ||
subjectFilter.trim().length > 0 ||
dateFrom !== null ||
dateTo !== null ||
@@ -1119,6 +1184,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
s.observationTriggeredByFilter,
s.observationVerdictFilter,
s.observationTagFilter,
+ s.observationMinScoreFilter,
+ s.observationMaxScoreFilter,
s.observationSubjectFilter,
s.observationDateFrom,
s.observationDateTo,
@@ -1131,25 +1198,29 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
observationTriggeredByFilter: ObservationTriggeredByValue[],
observationVerdictFilter: ObservationVerdictValue[],
observationTagFilter: string[],
+ observationMinScoreFilter: number | null,
+ observationMaxScoreFilter: number | null,
observationSubjectFilter: string,
observationDateFrom: string | null,
observationDateTo: string | null,
observationBackfillFilter: string | null,
observationsSort: ObservationsSorting | null,
scanner: ReplayScanner | null
- ): Record<string, string> =>
+ ): Record<string, string | number> =>
buildObservationListParams({
observationStatusFilter,
observationTriggeredByFilter,
observationVerdictFilter,
observationTagFilter,
+ observationMinScoreFilter,
+ observationMaxScoreFilter,
observationSubjectFilter,
observationDateFrom,
observationDateTo,
observationBackfillFilter,
observationsSort,
scanner,
- }) as Record<string, string>,
+ }) as Record<string, string | number>,
],
// Tag options for the observations-list Tag filter pill. Wrapped in an inline arrow with an
// explicit return type so kea-typegen can infer it (it can't from bare function references).
@@ -1535,6 +1606,11 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
setObservationTriggeredByFilter: () => reloadObservationsAndStats(),
setObservationVerdictFilter: () => reloadObservationsAndStats(),
setObservationTagFilter: () => reloadObservationsAndStats(),
+ setObservationScoreRange: async (_, breakpoint) => {
+ // Typed into number inputs — debounce so each keystroke of "10" doesn't fire its own request.
+ await breakpoint(300)
+ reloadObservationsAndStats()
+ },
setObservationBackfillFilter: () => reloadObservationsAndStats(),
setObservationDateRange: () => reloadObservationsAndStats(),
setObservationSubjectFilter: async (_, breakpoint) => {
@@ -1615,6 +1691,7 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
setObservationTriggeredByFilter: writeUrl,
setObservationVerdictFilter: writeUrl,
setObservationTagFilter: writeUrl,
+ setObservationScoreRange: writeUrlReplace,
setObservationDateRange: writeUrl,
setObservationBackfillFilter: writeUrl,
setObservationSubjectFilter: writeUrlReplace,
@@ -1635,6 +1712,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
)
const verdict = parseCsvParam<ObservationVerdictValue>(searchParams.verdict, OBSERVATION_VERDICT_VALUES)
const tags = parseCsvParam<string>(searchParams.tags)
+ const minScore = parseNumericParam(searchParams.min_score)
+ const maxScore = parseNumericParam(searchParams.max_score)
const subjectRaw = searchParams.recording_subject
// String() so a numeric-looking subject (`?recording_subject=12345`) survives the router's coercion.
const subject =
@@ -1650,6 +1729,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
objectsEqual(triggeredBy, values.observationTriggeredByFilter) &&
objectsEqual(verdict, values.observationVerdictFilter) &&
objectsEqual(tags, values.observationTagFilter) &&
+ minScore === values.observationMinScoreFilter &&
+ maxScore === values.observationMaxScoreFilter &&
subject === values.observationSubjectFilter &&
dateFrom === values.observationDateFrom &&
dateTo === values.observationDateTo &&
@@ -1662,6 +1743,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
triggeredBy,
verdict,
tags,
+ minScore,
+ maxScore,
subject,
dateFrom,
dateTo,
@@ -1718,6 +1801,8 @@ const TABLE_URL_PARAM_KEYS = [
'triggered_by',
'verdict',
'tags',
+ 'min_score',
+ 'max_score',
'recording_subject',
'date_from',
'date_to',
diff --git a/products/replay_vision/frontend/replay_scanners/types.ts b/products/replay_vision/frontend/replay_scanners/types.ts
index 3e200c7e4c3a..8d1ddecd64b6 100644
--- a/products/replay_vision/frontend/replay_scanners/types.ts
+++ b/products/replay_vision/frontend/replay_scanners/types.ts
@@ -39,6 +39,8 @@ export const OBSERVATION_LIST_FILTER_KEYS: readonly (keyof VisionObservationsRet
'triggered_by',
'verdict',
'tags',
+ 'min_score',
+ 'max_score',
'session_id',
'recording_subject',
'labeled',
diff --git a/products/replay_vision/frontend/utils/urlParams.ts b/products/replay_vision/frontend/utils/urlParams.ts
index b2e5c09623d9..b866e8953281 100644
--- a/products/replay_vision/frontend/utils/urlParams.ts
+++ b/products/replay_vision/frontend/utils/urlParams.ts
@@ -22,6 +22,18 @@ export function parseCsvParam<T extends string>(value: unknown, validValues?: re
return validValues ? parsed.filter((v) => validValues.includes(v)) : parsed
}
+/** Finite number from a URL param, tolerant of the router already coercing it; null when absent or unparseable. */
+export function parseNumericParam(value: unknown): number | null {
+ if (typeof value === 'number') {
+ return Number.isFinite(value) ? value : null
+ }
+ if (typeof value !== 'string' || value.trim().length === 0) {
+ return null
+ }
+ const parsed = Number(value)
+ return Number.isFinite(parsed) ? parsed : null
+}
+
/** `-`-prefixed sort token, or undefined when the sort matches `defaultSort` (keeps the URL clean). */
export function serializeSortParam(sort: UrlSorting | null, defaultSort?: UrlSorting): string | undefined {
if (!sort || (defaultSort && sort.columnKey === defaultSort.columnKey && sort.order === defaultSort.order)) {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index ff43897c97f4..e5572a8f99f6 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -89264,6 +89264,14 @@ export namespace Schemas {
* When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.
*/
labeled?: string;
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number;
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number;
/**
* Sort observations. Plain keys: created_at, started_at, completed_at, status, recording_subject_email. JSONB keys: result_score (scorer), result_verdict (monitor), result_confidence, scanner_version. Prefix with `-` for descending; nullable keys sort nulls last either way.
*/
@@ -89390,6 +89398,14 @@ export namespace Schemas {
* Number of results to return per page.
*/
limit?: number;
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number;
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number;
/**
* The initial index from which to return the results.
*/
@@ -89441,6 +89457,14 @@ export namespace Schemas {
* When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.
*/
labeled?: string;
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number;
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number;
/**
* Sort observations. Plain keys: created_at, started_at, completed_at, status, recording_subject_email. JSONB keys: result_score (scorer), result_verdict (monitor), result_confidence, scanner_version. Prefix with `-` for descending; nullable keys sort nulls last either way.
*/
@@ -89488,6 +89512,14 @@ export namespace Schemas {
* When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.
*/
labeled?: string;
+ /**
+ * Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ max_score?: number;
+ /**
+ * Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.
+ */
+ min_score?: number;
/**
* Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.
*/
diff --git a/services/mcp/src/generated/replay_vision/api.ts b/services/mcp/src/generated/replay_vision/api.ts
index 5860f0e29244..007234677ad9 100644
--- a/services/mcp/src/generated/replay_vision/api.ts
+++ b/services/mcp/src/generated/replay_vision/api.ts
@@ -511,6 +511,18 @@ export const VisionObservationsRetrieveQueryParams = /* @__PURE__ */ zod.object(
.describe(
'When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.'
),
+ max_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
+ min_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
order_by: zod
.string()
.optional()
@@ -1039,6 +1051,18 @@ export const VisionScannersObservationsListQueryParams = /* @__PURE__ */ zod.obj
'When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.'
),
limit: zod.number().optional().describe('Number of results to return per page.'),
+ max_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
+ min_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
order_by: zod
.string()
@@ -1106,6 +1130,18 @@ export const VisionScannersObservationsRetrieveQueryParams = /* @__PURE__ */ zod
.describe(
'When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.'
),
+ max_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
+ min_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
order_by: zod
.string()
.optional()
@@ -1171,6 +1207,18 @@ export const VisionScannersObservationsStatsRetrieveQueryParams = /* @__PURE__ *
.describe(
'When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.'
),
+ max_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
+ min_score: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.'
+ ),
recent_days: zod
.number()
.optional()
diff --git a/services/mcp/src/tools/generated/replay_vision.ts b/services/mcp/src/tools/generated/replay_vision.ts
index f9a719062b96..fc6c2cd7aa0b 100644
--- a/services/mcp/src/tools/generated/replay_vision.ts
+++ b/services/mcp/src/tools/generated/replay_vision.ts
@@ -342,6 +342,8 @@ const visionObservationsRetrieve = (): ToolBase<
date_from: params.date_from,
date_to: params.date_to,
labeled: params.labeled,
+ max_score: params.max_score,
+ min_score: params.min_score,
order_by: params.order_by,
recording_subject: params.recording_subject,
session_id: params.session_id,
@@ -633,6 +635,8 @@ const visionScannersObservationsGet = (): ToolBase<
date_from: params.date_from,
date_to: params.date_to,
labeled: params.labeled,
+ max_score: params.max_score,
+ min_score: params.min_score,
order_by: params.order_by,
recording_subject: params.recording_subject,
session_id: params.session_id,
@@ -670,6 +674,8 @@ const visionScannersObservationsList = (): ToolBase<
date_to: params.date_to,
labeled: params.labeled,
limit: params.limit,
+ max_score: params.max_score,
+ min_score: params.min_score,
offset: params.offset,
order_by: params.order_by,
recording_subject: params.recording_subject,
@@ -718,6 +724,8 @@ const visionScannersObservationsStats = (): ToolBase<
date_from: params.date_from,
date_to: params.date_to,
labeled: params.labeled,
+ max_score: params.max_score,
+ min_score: params.min_score,
recent_days: params.recent_days,
recording_subject: params.recording_subject,
session_id: params.session_id,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-observations-retrieve.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-observations-retrieve.json
index eff2c7b4352f..9dd496a5543d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-observations-retrieve.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-observations-retrieve.json
@@ -21,6 +21,14 @@
"description": "When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.",
"type": "string"
},
+ "max_score": {
+ "description": "Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
+ "min_score": {
+ "description": "Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
"order_by": {
"description": "Sort observations. Plain keys: created_at, started_at, completed_at, status, recording_subject_email. JSONB keys: result_score (scorer), result_verdict (monitor), result_confidence, scanner_version. Prefix with `-` for descending; nullable keys sort nulls last either way.",
"type": "string"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-get.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-get.json
index 7d2828d327c3..dc88a66fe2b8 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-get.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-get.json
@@ -21,6 +21,14 @@
"description": "When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.",
"type": "string"
},
+ "max_score": {
+ "description": "Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
+ "min_score": {
+ "description": "Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
"order_by": {
"description": "Sort observations. Plain keys: created_at, started_at, completed_at, status, recording_subject_email. JSONB keys: result_score (scorer), result_verdict (monitor), result_confidence, scanner_version. Prefix with `-` for descending; nullable keys sort nulls last either way.",
"type": "string"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-list.json
index 7e3449cd2673..78c86de5b216 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-list.json
@@ -21,6 +21,14 @@
"description": "Number of results to return per page.",
"type": "number"
},
+ "max_score": {
+ "description": "Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
+ "min_score": {
+ "description": "Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
"offset": {
"description": "The initial index from which to return the results.",
"type": "number"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-stats.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-stats.json
index 321330e9d071..90bce0d3a430 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-stats.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-observations-stats.json
@@ -17,6 +17,14 @@
"description": "When true, return only observations that have a shared label (thumbs up or down); when false, only unlabeled observations.",
"type": "string"
},
+ "max_score": {
+ "description": "Filter scorer observations to those scoring at or below this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
+ "min_score": {
+ "description": "Filter scorer observations to those scoring at or above this value. Rows with no numeric score (other scanner types, failed or in-flight runs) are excluded.",
+ "type": "number"
+ },
"recent_days": {
"description": "Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.",
"type": "number"