: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(llma): hog evals bypass trial-limit re-enable gate (#58796)
Carlos Marchale2fef3a26e72
diff --git a/products/llm_analytics/backend/api/evaluations.py b/products/llm_analytics/backend/api/evaluations.pyindex 1b5f743854c8..36197e95327c 100644--- a/products/llm_analytics/backend/api/evaluations.py+++ b/products/llm_analytics/backend/api/evaluations.py@@ -183,6 +183,12 @@ class EvaluationSerializer(serializers.ModelSerializer):def _validate_re_enable(self, data: dict) -> None:has_byok = self._has_byok_key(data)status_reason = getattr(self.instance, "status_reason", None)+ evaluation_type = data.get("evaluation_type") or getattr(self.instance, "evaluation_type", None)+ # Hog evals run deterministic bytecode server-side: they never call an LLM provider,+ # never consume trial quota, and never need a BYOK key. The trial-limit / model-allowlist /+ # provider-key-deleted gates below all assume an LLM-judge call path, so skip them entirely.+ if evaluation_type == "hog":+ return# Trial limit: can only re-enable if they've attached a BYOK key (which bypasses trial quota).if status_reason == "trial_limit_reached" or not status_reason:diff --git a/products/llm_analytics/backend/api/test/test_evaluations.py b/products/llm_analytics/backend/api/test/test_evaluations.pyindex 22579c4f5101..f5f59367f27a 100644--- a/products/llm_analytics/backend/api/test/test_evaluations.py+++ b/products/llm_analytics/backend/api/test/test_evaluations.py@@ -545,6 +545,29 @@ class TestEnableBlockingWhenTrialExhausted(APIBaseTest):eval_obj.refresh_from_db()self.assertTrue(eval_obj.enabled)+ def test_allows_enabling_hog_eval_when_limit_reached(self):+ EvaluationConfig.objects.create(team=self.team, trial_eval_limit=100, trial_evals_used=100)+ eval_obj = Evaluation.objects.create(+ team=self.team,+ name="Hog Eval",+ evaluation_type="hog",+ evaluation_config={"source": "return true"},+ output_type="boolean",+ output_config={},+ enabled=False,+ created_by=self.user,+ conditions=[{"id": "cond-1", "rollout_percentage": 100, "properties": []}],+ )++ response = self.client.patch(+ f"/api/environments/{self.team.id}/evaluations/{eval_obj.id}/",+ {"enabled": True},+ format="json",+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK)+ eval_obj.refresh_from_db()+ self.assertTrue(eval_obj.enabled)+def test_allows_enabling_byok_eval_when_limit_reached(self):EvaluationConfig.objects.create(team=self.team, trial_eval_limit=100, trial_evals_used=100)key = LLMProviderKey.objects.create(diff --git a/products/llm_analytics/frontend/evaluations/llmEvaluationLogic.ts b/products/llm_analytics/frontend/evaluations/llmEvaluationLogic.tsindex 0d1d067f74ec..e829f49368e6 100644--- a/products/llm_analytics/frontend/evaluations/llmEvaluationLogic.ts+++ b/products/llm_analytics/frontend/evaluations/llmEvaluationLogic.ts@@ -648,6 +648,10 @@ export const llmEvaluationLogic = kea<llmEvaluationLogicType>([if (!evaluation || !isTrialLimitReached) {return true}+ // Hog evals don't call an LLM and never consume trial quota+ if (evaluation.evaluation_type === 'hog') {+ return true+ }// Can enable if the evaluation has a BYOK keyreturn !!evaluation.model_configuration?.provider_key_id},diff --git a/products/llm_analytics/frontend/evaluations/llmEvaluationsLogic.ts b/products/llm_analytics/frontend/evaluations/llmEvaluationsLogic.tsindex 90dfa4616bcf..302302da15ab 100644--- a/products/llm_analytics/frontend/evaluations/llmEvaluationsLogic.ts+++ b/products/llm_analytics/frontend/evaluations/llmEvaluationsLogic.ts@@ -266,6 +266,10 @@ export const llmEvaluationsLogic = kea<llmEvaluationsLogicType>([if (!isTrialLimitReached) {return true}+ // Hog evals don't call an LLM and never consume trial quota+ if (evaluation.evaluation_type === 'hog') {+ return true+ }return !!evaluation.model_configuration?.provider_key_id}},