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): allow backfill estimates on disabled evaluations (#118319)

posthog[bot]df10a8926251
diff --git a/products/ai_observability/backend/api/evaluation_backfills.py b/products/ai_observability/backend/api/evaluation_backfills.py
index 148dffe5c59f..92d90aec340e 100644
--- a/products/ai_observability/backend/api/evaluation_backfills.py
+++ b/products/ai_observability/backend/api/evaluation_backfills.py
@@ -494,7 +494,6 @@ class EvaluationBackfillViewSet(
def estimate(self, request: Request, **kwargs: Any) -> Response:
"""Count what a backfill over the given window would evaluate, without creating one."""
evaluation = self._evaluation_for_url()
- self._require_enabled(evaluation)
data = self._validated_request(request)
window = self._clamped_window(evaluation, data)
conditions = self._conditions(evaluation, data)
diff --git a/products/ai_observability/backend/api/test/test_evaluation_backfills.py b/products/ai_observability/backend/api/test/test_evaluation_backfills.py
index 6685f29094f0..886a7c56c688 100644
--- a/products/ai_observability/backend/api/test/test_evaluation_backfills.py
+++ b/products/ai_observability/backend/api/test/test_evaluation_backfills.py
@@ -168,9 +168,13 @@ class TestEvaluationBackfillsApi(APIBaseTest):
throttled = self.client.post(f"{self.url}/estimate/", _body(), format="json")
assert throttled.status_code == status.HTTP_429_TOO_MANY_REQUESTS, throttled.json()
+ @parameterized.expand([("enabled", True), ("disabled_draft", False)])
@patch(CAPTURE)
@patch(f"{API_MODULE}.count_backfill_candidates", return_value=_scope(42, already_judged=8))
- def test_estimate_counts_without_creating_a_row(self, _count, capture):
+ def test_estimate_counts_without_creating_a_row(self, _case, enabled, _count, capture):
+ self.evaluation.enabled = enabled
+ self.evaluation.save()
+
response = self.client.post(f"{self.url}/estimate/", _body(), format="json")
assert response.status_code == status.HTTP_200_OK, response.json()
@@ -559,14 +563,12 @@ class TestEvaluationBackfillsApi(APIBaseTest):
assert response.json()["detail"] == "A condition could not be applied. Check the filters and try again."
assert EvaluationBackfill.objects.unscoped().count() == 0
- @parameterized.expand(["create", "estimate"])
@patch(CAPTURE)
- def test_a_disabled_evaluation_cannot_be_backfilled(self, case, capture):
+ def test_a_disabled_evaluation_cannot_be_backfilled(self, capture):
self.evaluation.enabled = False
self.evaluation.save()
- path = f"{self.url}/" if case == "create" else f"{self.url}/estimate/"
- response = self.client.post(path, _body(), format="json")
+ response = self.client.post(f"{self.url}/", _body(), format="json")
assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
assert response.json()["detail"] == "Enable the evaluation before backfilling it."
diff --git a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts
index 7ced196e097d..78cdfb3f3e90 100644
--- a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts
+++ b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts
@@ -370,6 +370,17 @@ describe('evaluationBackfillsLogic', () => {
}
)
+ it('blocks the start button on a disabled evaluation even when the estimate has a count', async () => {
+ await mountAndSettle()
+
+ saveEvaluation({ enabled: false })
+ logic.actions.requestEstimateSuccess(estimate({ total_units: 42 }))
+
+ await expectLogic(logic).toMatchValues({
+ startDisabledReason: 'Enable the evaluation before backfilling it',
+ })
+ })
+
it('says it is counting while an estimate is in flight, then surfaces the failure', async () => {
await mountAndSettle()
diff --git a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts
index a310c241f3a9..e0ec98516221 100644
--- a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts
+++ b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts
@@ -217,6 +217,7 @@ export interface evaluationBackfillsLogicMeta {
evaluation: EvaluationConfig | null
) => EvaluationTargetEnumApi
startDisabledReason: (
+ evaluation: EvaluationConfig | null,
hasActiveBackfill: boolean,
transitioningIds: string[],
conditions: EvaluationConditionSet[],
@@ -394,6 +395,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([
],
startDisabledReason: [
(s) => [
+ s.evaluation,
s.hasActiveBackfill,
s.transitioningIds,
s.conditions,
@@ -402,6 +404,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([
s.estimateError,
],
(
+ evaluation: EvaluationConfig | null,
hasActiveBackfill: boolean,
transitioningIds: string[],
conditions: EvaluationConditionSet[],
@@ -409,6 +412,9 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([
estimateLoading: boolean,
estimateError: string | null
): string | undefined => {
+ if (evaluation?.enabled === false) {
+ return 'Enable the evaluation before backfilling it'
+ }
if (hasActiveBackfill) {
return 'This evaluation already has a running backfill'
}
diff --git a/products/ai_observability/skills/creating-online-evaluations/SKILL.md b/products/ai_observability/skills/creating-online-evaluations/SKILL.md
index be4d252a480a..ea8530e49e46 100644
--- a/products/ai_observability/skills/creating-online-evaluations/SKILL.md
+++ b/products/ai_observability/skills/creating-online-evaluations/SKILL.md
@@ -349,7 +349,8 @@ enable yet) and what would unblock it.
### 2.7 — Offer to evaluate past data
An enabled eval only scores traffic from now on. If the user wants results on data they already have, offer
-a backfill over a recent window, at most the last 30 days.
+a backfill over a recent window, at most the last 30 days. `posthog:llma-evaluation-backfill-create` refuses a
+disabled eval, so enable it first (see 2.6).
1. Call `posthog:llma-evaluation-backfill-estimate` with the window, `conditions`, and `rerun_existing` the
user wants. Tell the user `total_units`, the