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(llma): close stale db connections in llm judge activity (#66983)

posthog[bot]9871285bed2c
diff --git a/posthog/temporal/ai_observability/evaluation_llm_judge.py b/posthog/temporal/ai_observability/evaluation_llm_judge.py
index 0da99ccb7136..c9cfc5857af3 100644
--- a/posthog/temporal/ai_observability/evaluation_llm_judge.py
+++ b/posthog/temporal/ai_observability/evaluation_llm_judge.py
@@ -27,6 +27,7 @@ from posthog.temporal.ai_observability.metrics import (
increment_user_errors,
)
from posthog.temporal.ai_observability.model_resolution import model_spec
+from posthog.temporal.common.utils import close_db_connections
from products.ai_observability.backend.llm import DEFAULT_MODEL_BY_PROVIDER, Client, CompletionRequest
from products.ai_observability.backend.llm.config import get_eval_config
@@ -172,6 +173,7 @@ def _build_errored_trace_result(allows_na: bool) -> EvaluationActivityResult:
@temporalio.activity.defn
+@close_db_connections
@posthoganalytics.scoped()
def execute_llm_judge_activity(inputs: ExecuteLLMJudgeInputs) -> EvaluationActivityResult:
"""Execute LLM judge to evaluate the target event.