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): humanize run skip/fail reasons + surface them better (#67535)

Kim Svatos Dugan50d844602347
diff --git a/products/replay_vision/backend/api/vision_actions.py b/products/replay_vision/backend/api/vision_actions.py
index c2df1f5d9ddf..1b877e6c4db2 100644
--- a/products/replay_vision/backend/api/vision_actions.py
+++ b/products/replay_vision/backend/api/vision_actions.py
@@ -370,6 +370,23 @@ class VisionActionViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
super().perform_destroy(instance)
+# Human-readable copy for the engine's controlled skip/abort reasons (see temporal.vision_actions —
+# _validate skip reasons and SynthesisStatus). Unmapped values fall through to the raw string.
+# Copy stays neutral (no "Skipped —"/"Failed —" prefix): the run's status drives the banner heading,
+# so the abort reasons read correctly under the "failed" banner they actually carry.
+_RUN_REASON_LABELS = {
+ "skipped_empty": "No new observations in this window to summarize.",
+ "skipped_over_budget": "The team is over its AI-credit budget.",
+ "no_delivery": "No delivery destination is configured for this action.",
+ # Alias: runs recorded before #66892 stored the old "no_delivery_flow" enum; map it to the same copy.
+ "no_delivery_flow": "No delivery destination is configured for this action.",
+ "disabled": "The action was disabled when this run was due.",
+ "not_found": "The action no longer exists.",
+ "aborted_no_consent": "AI data processing isn't enabled for this organization.",
+ "aborted_no_user": "The action's creator no longer has access.",
+}
+
+
class RunObservationSerializer(serializers.Serializer):
"""One recording an action run included in its summary — the 'recordings included' list on the run detail view."""
@@ -442,14 +459,14 @@ class VisionActionRunListSerializer(serializers.ModelSerializer):
@extend_schema_field(serializers.CharField(allow_null=True))
def get_error_reason(self, run: VisionActionRun) -> str | None:
error = run.error if isinstance(run.error, dict) else {}
- # Surface only the engine's controlled skip/abort reasons. Failed runs also stamp error["message"]
- # with raw exception text (str(e)[:500]) — don't echo that to API consumers; show a generic reason.
+ # Surface only the engine's controlled skip/abort reasons, mapped to human copy. Failed runs also
+ # stamp error["message"] with raw exception text (str(e)[:500]) — don't echo that to API consumers.
for key in ("skip_reason", "aborted"):
value = error.get(key)
if isinstance(value, str) and value.strip():
- return value
+ return _RUN_REASON_LABELS.get(value, value)
if run.status == VisionActionRunStatus.FAILED:
- return "Run failed"
+ return "This run failed while generating the summary."
return None
diff --git a/products/replay_vision/backend/tests/test_vision_actions_api.py b/products/replay_vision/backend/tests/test_vision_actions_api.py
index 4bf9f494060c..b9326446aaa3 100644
--- a/products/replay_vision/backend/tests/test_vision_actions_api.py
+++ b/products/replay_vision/backend/tests/test_vision_actions_api.py
@@ -3,6 +3,8 @@ from typing import Any
from posthog.test.base import APIBaseTest
from unittest.mock import patch
+from parameterized import parameterized
+
from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.cdp.templates.slack.template_slack import template as template_slack
from posthog.models import Organization, Team
@@ -337,11 +339,35 @@ class TestVisionActionRunViewSet(_VisionActionAPITestCase):
body = self.client.get(f"{self.runs_url()}{run.id}/").json()
self.assertEqual([o["id"] for o in body["observations"]], [str(mine.id)])
- def test_error_reason_surfaced(self) -> None:
- run = self._create_run(status=VisionActionRunStatus.SKIPPED, error={"skip_reason": "over budget"})
+ @parameterized.expand(
+ [
+ # (status, error, expected copy)
+ (
+ VisionActionRunStatus.SKIPPED,
+ {"skip_reason": "skipped_empty"},
+ "No new observations in this window to summarize.",
+ ),
+ # Historical run rows (pre-#66892) stored the old enum; the alias must still humanize.
+ (
+ VisionActionRunStatus.SKIPPED,
+ {"skip_reason": "no_delivery_flow"},
+ "No delivery destination is configured for this action.",
+ ),
+ # Abort reasons carry FAILED status — the copy must not contradict the "failed" banner by saying "Skipped".
+ (
+ VisionActionRunStatus.FAILED,
+ {"aborted": "aborted_no_consent"},
+ "AI data processing isn't enabled for this organization.",
+ ),
+ ]
+ )
+ def test_error_reason_humanized(self, status: str, error: dict[str, Any], expected: str) -> None:
+ # A raw engine skip/abort reason is mapped to human copy, not surfaced verbatim.
+ run = self._create_run(status=status, error=error)
resp = self.client.get(f"{self.runs_url()}{run.id}/")
self.assertEqual(resp.status_code, 200, resp.content)
- self.assertEqual(resp.json()["error_reason"], "over budget")
+ self.assertEqual(resp.json()["error_reason"], expected)
+ self.assertNotIn("Skipped", resp.json()["error_reason"])
def test_failed_run_error_reason_does_not_leak_raw_exception(self) -> None:
# The engine stamps error["message"] with raw exception text (str(e)[:500]); the API must not
@@ -352,7 +378,8 @@ class TestVisionActionRunViewSet(_VisionActionAPITestCase):
)
resp = self.client.get(f"{self.runs_url()}{run.id}/")
self.assertEqual(resp.status_code, 200, resp.content)
- self.assertEqual(resp.json()["error_reason"], "Run failed")
+ self.assertNotIn("secret_token", resp.json()["error_reason"])
+ self.assertEqual(resp.json()["error_reason"], "This run failed while generating the summary.")
def test_runs_scoped_to_their_action(self) -> None:
other_action = VisionAction.all_teams.create(team=self.team, scanner=self.scanner, name="other-action")
diff --git a/products/replay_vision/frontend/replay_scanners/VisionActionRunScene.tsx b/products/replay_vision/frontend/replay_scanners/VisionActionRunScene.tsx
index ae397241d5cc..3b5c7ec6f100 100644
--- a/products/replay_vision/frontend/replay_scanners/VisionActionRunScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/VisionActionRunScene.tsx
@@ -3,6 +3,7 @@ import { useValues } from 'kea'
import { LemonTable, LemonTableColumns, Link } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
+import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { SceneExport } from 'scenes/sceneTypes'
@@ -104,8 +105,19 @@ function VisionActionRunScene(): JSX.Element {
{run.synthesized_markdown ? (
<LemonMarkdown className="text-base">{run.synthesized_markdown}</LemonMarkdown>
+ ) : run.status === 'running' ? (
+ <div className="text-muted italic">This run is in progress — check back shortly for the summary.</div>
) : (
- <div className="text-muted italic">{run.error_reason || 'No summary was produced for this run.'}</div>
+ <LemonBanner type={run.status === 'failed' ? 'error' : 'info'}>
+ <div className="font-semibold">
+ {run.status === 'failed'
+ ? 'This run failed'
+ : run.status === 'skipped'
+ ? 'This run was skipped'
+ : 'This run produced no summary'}
+ </div>
+ <div>{run.error_reason || 'No summary was produced for this run.'}</div>
+ </LemonBanner>
)}
{run.observations.length > 0 ? (
diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx
index 0b91c6c7ae20..1455613dd78d 100644
--- a/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx
@@ -94,7 +94,7 @@ export function VisionActionRuns(): JSX.Element {
{
title: 'Status',
key: 'status',
- render: (_, run) => <RunStatusTag status={run.status} />,
+ render: (_, run) => <RunStatusTag status={run.status} reason={run.error_reason} />,
},
{
title: 'Observations',
diff --git a/products/replay_vision/frontend/replay_scanners/visionActionRunStatus.tsx b/products/replay_vision/frontend/replay_scanners/visionActionRunStatus.tsx
index f565bdd2b90a..7b65ee2f102b 100644
--- a/products/replay_vision/frontend/replay_scanners/visionActionRunStatus.tsx
+++ b/products/replay_vision/frontend/replay_scanners/visionActionRunStatus.tsx
@@ -1,5 +1,7 @@
import { LemonTag } from '@posthog/lemon-ui'
+import { Tooltip } from 'lib/lemon-ui/Tooltip'
+
import type { VisionActionRunStatusEnumApi } from '../generated/api.schemas'
const STATUS_TAG: Record<
@@ -13,11 +15,19 @@ const STATUS_TAG: Record<
}
// Single source of truth for how a run's status renders — used by the run list and the run detail page.
-export function RunStatusTag({ status }: { status: VisionActionRunStatusEnumApi }): JSX.Element {
+// Pass `reason` (a skipped/failed run's error_reason) to surface it as a tooltip on the chip.
+export function RunStatusTag({
+ status,
+ reason,
+}: {
+ status: VisionActionRunStatusEnumApi
+ reason?: string | null
+}): JSX.Element {
const tag = STATUS_TAG[status]
- return (
+ const chip = (
<LemonTag type={tag.type} size="small">
{tag.label}
</LemonTag>
)
+ return reason ? <Tooltip title={reason}>{chip}</Tooltip> : chip
}