: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(replay-vision): time out hung tag-suggestion model calls (#71879)
Arno Hillenb4d1cea3992a
diff --git a/products/replay_vision/backend/tag_suggestions.py b/products/replay_vision/backend/tag_suggestions.pyindex 600f18228e29..146fd29225c9 100644--- a/products/replay_vision/backend/tag_suggestions.py+++ b/products/replay_vision/backend/tag_suggestions.py@@ -35,6 +35,7 @@ logger = structlog.get_logger(__name__)# Cheap, fast model — this is an interactive form helper, not a recording scan._SUGGESTION_MODEL = "gemini-3.1-flash-lite-preview"+_MODEL_CALL_TIMEOUT_MS = 90_000_MAX_SUGGESTIONS = 8# Bounds on assembled context so a large team/scanner can't blow up the prompt._MAX_REASONING_SAMPLES = 15@@ -252,7 +253,12 @@ def suggest_classifier_tags(def _generate(*, user_content: str, team_id: int, distinct_id: str) -> _LlmSuggestions:# Inline the key resolution (rather than importing the temporal helper) to keep this off the temporal import path.api_key = settings.REPLAY_VISION_GEMINI_API_KEY or settings.GEMINI_API_KEY- client = genai.Client(api_key=api_key, posthog_client=posthoganalytics.default_client)+ # Runs inline on the interactive request path, so a hung provider call must time out.+ client = genai.Client(+ api_key=api_key,+ posthog_client=posthoganalytics.default_client,+ http_options={"timeout": _MODEL_CALL_TIMEOUT_MS},+ )config = GenerateContentConfig(system_instruction=_SYSTEM_PROMPT,response_mime_type="application/json",diff --git a/products/replay_vision/backend/temporal/vision_actions/synthesis.py b/products/replay_vision/backend/temporal/vision_actions/synthesis.pyindex f4cedc6a51ec..7d6b19fa4671 100644--- a/products/replay_vision/backend/temporal/vision_actions/synthesis.py+++ b/products/replay_vision/backend/temporal/vision_actions/synthesis.py@@ -7,7 +7,7 @@ is written onto `VisionActionRun` inside the activity — it never crosses the Timport refrom datetime import UTC, datetime, timedelta, tzinfo-from typing import TYPE_CHECKING, Any, NamedTuple+from typing import Any, NamedTuplefrom zoneinfo import ZoneInfofrom django.conf import settings@@ -38,9 +38,6 @@ from products.replay_vision.backend.temporal.vision_actions.types import (from ee.billing.quota_limiting import is_team_over_ai_credit_budgetfrom ee.hogai.utils.untrusted import as_untrusted_data-if TYPE_CHECKING:- pass-logger = structlog.get_logger(__name__)# Matches how insight AI summaries synthesize: PostHog AI through the LLM gateway