: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
feat(error-tracking): bypass shared decision and AI approval gates (#120152)
Hugues Pouillot35e03990b562
diff --git a/products/error_tracking/backend/logic/severity_inference.py b/products/error_tracking/backend/logic/severity_inference.pyindex 133c0ffe464a..2e4a1093d46b 100644--- a/products/error_tracking/backend/logic/severity_inference.py+++ b/products/error_tracking/backend/logic/severity_inference.py@@ -99,12 +99,13 @@ def _page_without_query(current_url: object) -> str | None:def infer_severity(team_id: int, state: str) -> ChoiceAnswer | None:"""Ask the decision model for a severity. Raises the ml_inference gateway errors unchanged."""- result = ml_inference.decide(+ result = ml_inference.decide_when_available(DecisionRequest(team_id=team_id,state=state,questions={_SEVERITY_QUESTION_ID: _SEVERITY_QUESTION},model=SEVERITY_INFERENCE_MODEL,+ privacy_mode=True,))answer = result.answers.get(_SEVERITY_QUESTION_ID)diff --git a/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py b/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.pyindex 12595c7a958d..bd6fcf245669 100644--- a/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py+++ b/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py@@ -185,8 +185,6 @@ def _severity_state(inputs: IssueCreatedWorkflowInputs) -> str | SeverityInferenteam = Team.objects.select_related("organization").get(id=inputs.team_id)except Team.DoesNotExist:return SeverityInferenceSkipReason.TEAM_MISSING- if not team.organization.is_ai_data_processing_approved:- return SeverityInferenceSkipReason.AI_DATA_PROCESSING_NOT_APPROVEDevent_properties = fetch_event_properties(team, inputs)stacktrace = render_stacktrace(event_properties, SEVERITY_INFERENCE_MAX_TOKENS)diff --git a/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py b/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.pyindex 99198c834432..85980cbae5e0 100644--- a/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py+++ b/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py@@ -16,7 +16,7 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Workerfrom posthog.helpers.tiktoken_encoding import LLM_TOKEN_COUNT_PROXY_MODEL, get_tiktoken_encoding_for_model-from products.error_tracking.backend.logic.severity_inference import build_severity_state+from products.error_tracking.backend.logic.severity_inference import SEVERITY_INFERENCE_MODEL, build_severity_statefrom products.error_tracking.backend.temporal.fingerprint_embedding_result.types import (AutoMergeReopenedTarget,FingerprintEmbeddingMergeResult,@@ -237,41 +237,53 @@ def _decision(choice: str) -> DecisionResult:@pytest.mark.parametrize(- "enabled,decide_outcome,expected_result,expected_error_type",+ "enabled,ai_approved,decide_outcome,expected_result,expected_error_type",[(+ False,False,_decision("critical"),IssueSeverityInferenceResult(skipped_reason=SeverityInferenceSkipReason.DISABLED),None,),(+ True,+ False,+ _decision("critical"),+ IssueSeverityInferenceResult(resolved=True, stored_severity="critical"),+ None,+ ),+ (+ True,True,_decision("critical"),IssueSeverityInferenceResult(resolved=True, stored_severity="critical"),None,),(+ True,True,_decision("catastrophic"),IssueSeverityInferenceResult(skipped_reason=SeverityInferenceSkipReason.UNEXPECTED_ANSWER),None,),(+ True,True,DecisionsDisabledError(1),IssueSeverityInferenceResult(skipped_reason=SeverityInferenceSkipReason.DECISIONS_UNAVAILABLE),None,),(+ True,True,DecisionGatewayError(422, "bad request"),IssueSeverityInferenceResult(skipped_reason=SeverityInferenceSkipReason.GATEWAY_REJECTED),None,),- (True, DecisionGatewayError(429, "rate limited"), None, SEVERITY_INFERENCE_UNAVAILABLE_ERROR_TYPE),- (True, DecisionGatewayError(503, "unavailable"), None, SEVERITY_INFERENCE_UNAVAILABLE_ERROR_TYPE),- (True, DecisionGatewayUnreachableError("timeout"), None, SEVERITY_INFERENCE_UNAVAILABLE_ERROR_TYPE),+ (True, True, DecisionGatewayError(429, "rate limited"), None, SEVERITY_INFERENCE_UNAVAILABLE_ERROR_TYPE),+ (True, True, DecisionGatewayError(503, "unavailable"), None, SEVERITY_INFERENCE_UNAVAILABLE_ERROR_TYPE),+ (True, True, DecisionGatewayUnreachableError("timeout"), None, SEVERITY_INFERENCE_UNAVAILABLE_ERROR_TYPE),],)@patch("products.error_tracking.backend.temporal.lifecycle.issue_created.activities.posthoganalytics.capture_exception")@@ -280,7 +292,7 @@ def _decision(choice: str) -> DecisionResult:)@patch("products.error_tracking.backend.temporal.lifecycle.issue_created.activities.logger")@patch("products.error_tracking.backend.temporal.lifecycle.issue_created.activities.apply_inferred_severity")-@patch("products.error_tracking.backend.logic.severity_inference.ml_inference.decide")+@patch("products.error_tracking.backend.logic.severity_inference.ml_inference.decide_when_available")@patch("products.error_tracking.backend.temporal.lifecycle.issue_created.activities.fetch_event_properties")@patch("products.error_tracking.backend.temporal.lifecycle.issue_created.activities.Team.objects.select_related")@patch("products.error_tracking.backend.temporal.lifecycle.issue_created.activities.severity_inference_enabled")@@ -294,12 +306,13 @@ def test_severity_inference_outcomes(inference_outcomes: MagicMock,capture_exception: MagicMock,enabled: bool,+ ai_approved: bool,decide_outcome: DecisionResult | Exception,expected_result: IssueSeverityInferenceResult | None,expected_error_type: str | None,) -> None:severity_inference_enabled.return_value = enabled- select_related.return_value.get.return_value.organization.is_ai_data_processing_approved = True+ select_related.return_value.get.return_value.organization.is_ai_data_processing_approved = ai_approvedfetch_event_properties.return_value = {"$exception_list": [{"type": "TypeError", "value": "boom"}]}if isinstance(decide_outcome, Exception):decide.side_effect = decide_outcome@@ -330,6 +343,9 @@ def test_severity_inference_outcomes(inference_outcomes.labels.assert_called_once_with(outcome=expected_outcome, severity=expected_severity)inference_outcomes.labels.return_value.inc.assert_called_once_with()capture_exception.assert_not_called()+ if enabled and isinstance(decide_outcome, DecisionResult):+ assert decide.call_args.args[0].model == SEVERITY_INFERENCE_MODEL+ assert decide.call_args.args[0].privacy_mode is True@override_settings(ERROR_TRACKING_EVENT_PROPERTIES_REDIS_URL="redis://event-properties")