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.

fix(aio): guard trace LLM judge activity against stale DB connections (#71476)

Carlos Marchal6b7ad8ddf956
diff --git a/posthog/temporal/ai_observability/run_trace_evaluation.py b/posthog/temporal/ai_observability/run_trace_evaluation.py
index c858094f2834..9f5c10cebdaa 100644
--- a/posthog/temporal/ai_observability/run_trace_evaluation.py
+++ b/posthog/temporal/ai_observability/run_trace_evaluation.py
@@ -62,6 +62,7 @@ from posthog.temporal.ai_observability.run_evaluation import (
increment_trial_usage_and_notify,
)
from posthog.temporal.common.base import PostHogWorkflow
+from posthog.temporal.common.utils import close_db_connections
from products.ai_observability.backend.models.evaluation_configs import (
TRACE_EVAL_DEFAULT_WINDOW_SECONDS,
@@ -286,6 +287,7 @@ def build_trace_hog_globals(trace: LLMTrace, trace_id: str) -> dict[str, Any]:
@temporalio.activity.defn
+@close_db_connections
@posthoganalytics.scoped()
def execute_trace_llm_judge_activity(inputs: ExecuteTraceEvaluationInputs) -> EvaluationActivityResult:
"""Fetch the whole trace and run the LLM judge over its transcript.