: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(aio): support bounded numeric system one evaluations (#109215)
Bernat Torres750688fbe143
diff --git a/docs/internal/ai-observability-judge-inputs.md b/docs/internal/ai-observability-judge-inputs.mdindex 33bd5eafce8e..9cd79e60414b 100644--- a/docs/internal/ai-observability-judge-inputs.md+++ b/docs/internal/ai-observability-judge-inputs.md@@ -43,6 +43,7 @@ Implementation: [trace judge](../../posthog/temporal/ai_observability/run_trace_System One-compatible models are available under the existing LLM judge option.The `llm-analytics-system-one-evaluations` project-group feature flag controls access in the browser and background workers.+Both use the project's UUID as its group key; the numeric project ID is a group property.Deploy the ingestion and evaluation worker changes before enabling the flag.Projects configure a System One-compatible deployment and its authentication.Evaluation connections never fall back to an instance credential or gateway configuration.@@ -75,8 +76,15 @@ Multiple selection uses one Noul question per option and includes each categoryThe endpoint must support the configured number of options and questions; model limits can be lower than the evaluation's configuration limit.Results use the existing categorical event property and passing rules.An empty selection is an applicable result; N/A remains a separate outcome.-`$ai_evaluation_probability` remains the probability of true for boolean evaluations and is not emitted for categorical results.-Numeric evaluations retain their existing arbitrary ranges and completion-based judges.+Numeric evaluations use a native Score question and require finite minimum and maximum bounds, with the minimum below the maximum.+The evaluation prompt defines the scoring criteria, including what low and high scores mean.+The judge generates ten evenly spaced reference scores across the configured range and sends them as ordered rubric levels.+The endpoint's fractional index (0–9) is mapped linearly back to that range and stored in `$ai_evaluation_numeric_result`.+Rubric descriptions preserve each reference score's full float precision; the stored numeric result is not rounded.+For example, an index of 6.75 on a 0–10 range produces 7.5. Step remains a prompt hint and does not round the result.+These are estimated ratings, not exact counts; unbounded numeric outputs still require a completion-based judge.+Numeric results use the existing passing rules and N/A handling. No new output configuration fields are required.+`$ai_evaluation_probability` remains the probability of true for boolean evaluations and is not emitted for categorical or numeric results.API compatibility does not guarantee equivalent judgments or calibration across models.Compare results on representative inputs when changing models.@@ -115,6 +123,10 @@ The playground keeps the provider's explanation so users can correct the settingBoolean online evaluations write their raw verdict to `$ai_evaluation_result`.Numeric evaluations write their score to `$ai_evaluation_numeric_result`, with optional `$ai_evaluation_numeric_result_min` and `$ai_evaluation_numeric_result_max` bounds.+Result badges and mean scores display up to two decimal places, with two significant digits for values below one to keep small nonzero scores visible. Badges in the runs table expose the exact score on hover; storage, sorting, and passing rules use the original value.+If rounding would change whether the displayed score meets the passing rule, the badge shows the exact score instead.+For online LLM judges, including System One, `step` is a suggested score increment in the prompt; results are not rounded or restricted to its multiples.+Hog evaluations use the numeric value returned by the code and do not apply `step`.`$ai_evaluation_result_type` identifies the output type; events without it are legacy boolean results.Categorical evaluations write a list of category keys to `$ai_evaluation_categorical_result`, including for single selection.Sentiment evaluations keep their `$ai_sentiment_*` properties.diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 9d860dee5993..b7a02c03eb06 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -11167,21 +11167,29 @@ snapshots:scenes-app-llm-observability-evaluationresulttag--categorical--light:hash: v1.k794b7964.45c5f02e9112dedb384783067742d23e6030c168878fed04de5deff678c8bd64.CRIywDuIaYMhwH_2Al4ytrohDpd5WB8e45s10FlVClwscenes-app-llm-observability-evaluationresulttag--numeric--dark:- hash: v1.k794b7964.1bcae05742f63c4b15b94fa5c6244a87c0dc72844623fd5a33fc72c54c879e3d.yz9CWrxD2rjp0oW_PvO6xOocQQunI1_Y2ymHqgtXPJA+ hash: v1.k794b7964.e1799ba1290b5693b5f29bb98ec8c11b59add26727c02e64ba8291de43c53bf5.L3spMBT8JyYxh6xN2ckwaab4AxByfxLkQX7YCIizTC0scenes-app-llm-observability-evaluationresulttag--numeric--light:- hash: v1.k794b7964.c23c448b50a0cb74a72e21fb5a16dbd24b90d6a3001710988f3d167ba6600f87.NIuKn2a1mky083oY1i2cHNLI2eHUh1PIRWry-7x0fN8+ hash: v1.k794b7964.0e1acd3eb652b9dc8087a126baf203d1d03f34fb88b32247702888910a8f2b5a.JshZUiYgQN-TiIER5StLCoSzaQHvU-lARFDDKxdQt28scenes-app-llm-observability-evaluationruntimestampcell--backfill--dark:hash: v1.k794b7964.87b458b34ae5d830eb72ac580aede650874a983633166cb4bd245eb5ebb30899.v1aOgn4bIz6CNCala1ykABgOkiCEC7FQB6b5o0MaStAscenes-app-llm-observability-evaluationruntimestampcell--backfill--light:hash: v1.k794b7964.900e00971dc99736c6d180aafbe449314de9874808ae7f0c261237a1ba599175.RYHZYhE1zgGTF1KXLEphkZSZv3SFtSoOj0zJRQXmfhgscenes-app-llm-observability-numericevaluationconfig--default--dark:- hash: v1.k794b7964.5efa717dee7fd925fe2b84fc86da63e6dfc99814d02dc94211113a6021a43914.ZtWJCtl75IPpnldtyrWooFB2tvg5psXqa0zFqELwMlE+ hash: v1.k794b7964.4486edb3ccf07a717ac377aaa62137c6b7f374cb4c9289eb5397c3d6621c86c6.g2euU7V3JJnf2vvyZAovAFBVI_-K4ntFqj34dGcYQTYscenes-app-llm-observability-numericevaluationconfig--default--light:- hash: v1.k794b7964.5d515040769bf8f5d2941b2fcd2a260e0b18c4a604344cc8ce650603d8c29a3d.KgaXSMDFPYGdcIljUTKWKROOTuOu0hjWiDTRiDmb7QY+ hash: v1.k794b7964.c868f7e75a52249c7ff57f0284ffc9bcd9b70094c6b0d22a9c640c20ff814393.nhtrM2oRbRil7cUkyGDkCbDvLizfRAYbr2kdHju7y8oscenes-app-llm-observability-numericevaluationconfig--narrow--dark:- hash: v1.k794b7964.5d3ea95400c9bfdf99ad885024bae82b001b3a75157cd1d330c5813507ea5db7.CUqQDU0iH8mhHDv7KNqihe1ORp6qTp44s_JexKlTbJA+ hash: v1.k794b7964.44086c835c7e9895248f8248fb0258f8343478e49ef66ce8a8fd71aa2d11e3c2.SpddjyeTLwIPxxSLknFgxOIKyK_W9UyeRwirESrbM2Mscenes-app-llm-observability-numericevaluationconfig--narrow--light:- hash: v1.k794b7964.06665db1bacabdd45b8bc20b07f151cc931a7d59f014af1ed1bc1b20d76fca39.7AaRhvrE7zgHk7SBS31uAfNcm-JyzHeorWybXzX7Dfg+ hash: v1.k794b7964.3b14c70883882e9765408de50b9c573820c50d03959f5a1fd2a5642f25b52d0c.JlBGFhVeXl_XmjUXix0GW-p8OahVr8z3i5a9Y-SIvvY+ scenes-app-llm-observability-numericevaluationconfig--system-one--dark:+ hash: v1.k794b7964.375fdbc9e08d70f061fe3a7f2680e4a8eeba88174e8c1568bb6f87276fb5f917.yp71Q1Hn0wczoOctAUTfHdyvuZLoCUfp8mMRc_vqcLY+ scenes-app-llm-observability-numericevaluationconfig--system-one--light:+ hash: v1.k794b7964.3388b128ffab027ba225500326a0966959a5743fc62dbd5a9578f6579d429525.hK5s33kCOL_QWdwxDqs6upfM6h9szX0Kb6QLgnIej68+ scenes-app-llm-observability-numericevaluationconfig--system-one-narrow--dark:+ hash: v1.k794b7964.ef34c395a9c714e408b11f16c269b26faf1702c47d28b1a4a75a6dfc53843c86.bGIL3-MblhBwE8TbLeV2b950OxPKA6zuY845SbU3Eyk+ scenes-app-llm-observability-numericevaluationconfig--system-one-narrow--light:+ hash: v1.k794b7964.0582a7952e17e17dcbcf88734e3593fda4adc9e4ef4d18dc33e3264f1f54db30.L3V9MhG1KqtPXLmo0YNTOyblMDqwyN5ByhYuKSUz3-gscenes-app-logs-logsimpactcounts--no-coverage--dark:hash: v1.k794b7964.fcfa5be29c5721d0db9fa21ecab20f16c04a4074c9af7fb3a58311900e168a48.2eslY8aigbAuKJ2Bsn8AjSOah5Q77FoWONVdG2fb6C4scenes-app-logs-logsimpactcounts--no-coverage--light:diff --git a/posthog/llm/system_one.py b/posthog/llm/system_one.pyindex 89f7c259588e..2557d3517b49 100644--- a/posthog/llm/system_one.py+++ b/posthog/llm/system_one.py@@ -3,8 +3,7 @@A System One model such as Jev answers typed questions about a ``state`` and returns judgmentsrather than text. A noul question returns the probability that a yes/no statement holds. A choicequestion picks one option from the criteria the caller supplies, with a probability for every-option. Score questions exist too and stay unwired until a caller needs one, so the request body-remains a checked shape.+option. A score question returns a fractional index into an ordered list of rubric levels.Keep user text in ``state`` and refer to it from the instructions by name. Never interpolate itinto ``instructions``, so user text cannot become an instruction.@@ -23,6 +22,7 @@ SYSTEM_ONE_PATH = "/v1/systemone"# The most options a System One server takes in one choice question. A model can take fewer.MAX_CHOICE_OPTIONS = 255+MAX_SCORE_LEVELS = 10type JsonValue = str | int | float | bool | None | Mapping[str, JsonValue] | Sequence[JsonValue]@@ -78,7 +78,20 @@ class ChoiceQuestion:return {"type": "choice", "instructions": self.instructions, "criteria": dict(self.criteria)}-type Question = NoulQuestion | ChoiceQuestion+@frozen+class ScoreQuestion:+ instructions: JsonValue+ criteria: Sequence[JsonValue]++ def __post_init__(self) -> None:+ if not 2 <= len(self.criteria) <= MAX_SCORE_LEVELS:+ raise ValueError(f"A score question needs between 2 and {MAX_SCORE_LEVELS} rubric levels")++ def to_json(self) -> dict[str, JsonValue]:+ return {"type": "score", "instructions": self.instructions, "criteria": list(self.criteria)}+++type Question = NoulQuestion | ChoiceQuestion | ScoreQuestion@frozen@@ -93,7 +106,14 @@ class ChoiceAnswer:probabilities: Mapping[str, float]-type Answer = NoulAnswer | ChoiceAnswer+@frozen+class ScoreAnswer:+ score: float+ confidence: float+ probabilities: Mapping[str, float]+++type Answer = NoulAnswer | ChoiceAnswer | ScoreAnswer@frozen@@ -138,6 +158,27 @@ def _parse_answer(question_id: str, question: Question, raw: object) -> Answer:raise SystemOneRequestFailed(f"The System One server returned a malformed noul for {question_id!r}")return NoulAnswer(probability=probability)+ if isinstance(question, ScoreQuestion):+ score = answer.get("score")+ if (+ answer.get("type", "score") != "score"+ or isinstance(score, bool)+ or not isinstance(score, int | float)+ or not 0 <= score <= len(question.criteria) - 1+ ):+ raise SystemOneRequestFailed(f"The System One server returned a malformed score for {question_id!r}")+ confidence = _as_probability(answer.get("confidence"))+ raw_probabilities = _as_mapping(answer.get("probabilities")) or {}+ probabilities = {+ str(index): _as_probability(raw_probabilities.get(str(index))) for index in range(len(question.criteria))+ }+ complete = {index: probability for index, probability in probabilities.items() if probability is not None}+ if confidence is None or len(complete) != len(question.criteria):+ raise SystemOneRequestFailed(+ f"The System One server returned malformed score probabilities for {question_id!r}"+ )+ return ScoreAnswer(score=float(score), confidence=confidence, probabilities=complete)+choice = answer.get("choice")confidence = _as_probability(answer.get("confidence"))if answer.get("type", "choice") != "choice" or not isinstance(choice, str) or choice not in question.criteria:diff --git a/posthog/temporal/ai_observability/evaluation_llm_judge.py b/posthog/temporal/ai_observability/evaluation_llm_judge.pyindex b3a41076bec3..d4238b31f6a0 100644--- a/posthog/temporal/ai_observability/evaluation_llm_judge.py+++ b/posthog/temporal/ai_observability/evaluation_llm_judge.py@@ -1,4 +1,5 @@import json+import mathfrom dataclasses import dataclassfrom datetime import timedeltafrom typing import Annotated, Any, Literal@@ -12,7 +13,16 @@ from temporalio.common import RetryPolicyfrom temporalio.exceptions import ApplicationErrorfrom posthog.dataclasses import frozen-from posthog.llm.system_one import ChoiceAnswer, ChoiceQuestion, NoulAnswer, NoulQuestion, Question+from posthog.llm.system_one import (+ MAX_SCORE_LEVELS,+ ChoiceAnswer,+ ChoiceQuestion,+ NoulAnswer,+ NoulQuestion,+ Question,+ ScoreAnswer,+ ScoreQuestion,+)from posthog.temporal.ai_observability.evaluation_errors import (require_user_error_spec,terminal_user_error_result,@@ -440,6 +450,20 @@ def _execute_llm_judge_activity(inputs: ExecuteLLMJudgeInputs) -> EvaluationActi)+def _system_one_numeric_score(minimum: float, maximum: float, index: float) -> float:+ last_index = MAX_SCORE_LEVELS - 1+ if index == 0:+ return minimum+ if index == last_index:+ return maximum+ score = (minimum * (last_index - index) + maximum * index) / last_index+ if math.isfinite(score):+ return score+ # Scale first when multiplying large finite bounds would overflow.+ weight = index / last_index+ return minimum * (1 - weight) + maximum * weight++def call_llm_judge(*,evaluation: dict[str, Any],@@ -474,11 +498,11 @@ def call_llm_judge(key_id = str(provider_key.id) if provider_key else Noneif provider == "system_one":- if output_type not in ("boolean", "categorical"):+ if output_type not in ("boolean", "categorical", "numeric"):return build_skipped_evaluation_result(output_type=output_type,allows_na=allows_na,- reasoning="System One supports boolean and categorical evaluations.",+ reasoning="System One supports boolean, categorical, and numeric evaluations.",skip_reason="unsupported_output_type",)base_url = provider_key.encrypted_config.get("base_url", "") if provider_key else ""@@ -509,8 +533,34 @@ def call_llm_judge(categorical_config = (CategoricalOutputConfig.model_validate(output_config) if output_type == "categorical" else None)+ numeric_levels: list[float] | None = Nonequestions: dict[str, Question]- if categorical_config is None:+ if output_type == "numeric":+ numeric_config = NumericOutputConfig.model_validate(output_config)+ if numeric_config.min is None or numeric_config.max is None or numeric_config.min >= numeric_config.max:+ return build_skipped_evaluation_result(+ output_type=output_type,+ allows_na=allows_na,+ reasoning="System One numeric evaluations require a minimum score below the maximum score.",+ skip_reason="request_rejected",+ )+ numeric_levels = [+ _system_one_numeric_score(numeric_config.min, numeric_config.max, index)+ for index in range(MAX_SCORE_LEVELS)+ ]+ if numeric_config.step is not None:+ prompt += (+ f"\nSuggested score increment: {numeric_config.step}; do not round an otherwise valid score."+ )+ questions = {+ "score": ScoreQuestion(+ instructions=prompt,+ criteria=[+ f"The score according to the evaluation criteria is {value!r}." for value in numeric_levels+ ],+ )+ }+ elif categorical_config is None:questions = {"verdict": NoulQuestion(instructions=prompt)}elif categorical_config.selection_mode == "single":questions = {@@ -549,8 +599,25 @@ def call_llm_judge(if not isinstance(applicability_answer, NoulAnswer):raise StructuredOutputParseError("The endpoint returned an invalid applicability answer.")applicable = applicability_answer.probability >= 0.5- parsed: BooleanEvalResult | BooleanWithNAEvalResult | CategoricalEvalResult | CategoricalWithNAEvalResult- if categorical_config is not None:+ parsed: (+ BooleanEvalResult+ | BooleanWithNAEvalResult+ | CategoricalEvalResult+ | CategoricalWithNAEvalResult+ | NumericEvalResult+ | NumericWithNAEvalResult+ )+ if numeric_levels is not None:+ score_answer = system_one_result.answers["score"]+ if not isinstance(score_answer, ScoreAnswer):+ raise StructuredOutputParseError("The endpoint returned an invalid score answer.")+ score = _system_one_numeric_score(numeric_levels[0], numeric_levels[-1], score_answer.score)+ parsed = (+ NumericWithNAEvalResult(reasoning="", score=score if applicable else None)+ if allows_na+ else NumericEvalResult(reasoning="", score=score)+ )+ elif categorical_config is not None:categories: list[str] = []if categorical_config.selection_mode == "single":category_answer = system_one_result.answers["category"]diff --git a/posthog/temporal/ai_observability/test_run_evaluation.py b/posthog/temporal/ai_observability/test_run_evaluation.pyindex 116f4f207ba1..7dbfa52285fb 100644--- a/posthog/temporal/ai_observability/test_run_evaluation.py+++ b/posthog/temporal/ai_observability/test_run_evaluation.py@@ -458,7 +458,93 @@ def test_system_one_categorical_results_use_category_keys_without_boolean_probabassert "$ai_evaluation_probability" not in properties-def test_system_one_numeric_mapping_is_not_enabled() -> None:+ "minimum,maximum,index,allows_na,applicable,expected",+ [+ (0, 10, 0, False, True, 0),+ (0, 10, 9, False, True, 10),+ (1, 10, 6, False, True, 7),+ (1, 100, 3, False, True, 34),+ (1, 100, 7, False, True, 78),+ (0, 1.9, 9, False, True, 1.9),+ (3.7, 10, 0, False, True, 3.7),+ (0, 10, 6.75, True, True, 7.5),+ (-2, 4, 2.25, False, True, -0.5),+ (0.1, 0.2, 4.5, False, True, 0.15),+ (1_000_000, 1_000_001, 4.5, False, True, 1_000_000.5),+ (-1e308, 1e308, 4.5, False, True, 0),+ (0, 10, 6.75, True, False, None),+ ],+)+def test_system_one_numeric_scores_use_configured_bounds(+ minimum: float, maximum: float, index: float, allows_na: bool, applicable: bool, expected: float | None+) -> None:+ prompt = "Score how well the response answers the question."+ evaluation = {+ "id": "test-evaluation",+ "name": "Answer quality",+ "team_id": 1,+ "evaluation_type": "llm_judge",+ "evaluation_config": {"prompt": prompt},+ "output_type": "numeric",+ "output_config": {"min": minimum, "max": maximum, "step": 1, "allows_na": allows_na},+ }+ answers: dict[str, object] = {+ "score": {"type": "score", "score": index, "confidence": 0.1, "probabilities": {str(i): 0.1 for i in range(10)}}+ }+ if allows_na:+ answers["applicable"] = {"noul": 0.9 if applicable else 0.1}+ key = MagicMock(+ provider="system_one", encrypted_config={"api_key": "", "base_url": "https://decisions.example.com/v1"}+ )+ with (+ patch("posthog.security.url_validation.resolve_host_ips", return_value={ip_address("8.8.8.8")}),+ patch("posthog.temporal.ai_observability.evaluation_llm_judge.model_spec") as spec,+ patch(+ "posthog.temporal.ai_observability.evaluation_llm_judge.system_one_evaluations_enabled", return_value=True+ ),+ patch(+ "httpx.AsyncHTTPTransport.handle_async_request",+ return_value=httpx.Response(+ 200, stream=httpx.ByteStream(json.dumps({"model": "custom-model", "answers": answers}).encode())+ ),+ ) as request,+ ):+ spec.return_value.resolve.return_value = MagicMock(+ provider="system_one", model="custom-model", provider_key=key, is_byok=True+ )+ result = call_llm_judge(evaluation=evaluation, system_prompt="", user_prompt="Hello!", allows_na=allows_na)++ sent = json.loads(request.call_args.args[0].content)+ assert sent["state"] == "Hello!"+ question = sent["questions"]["score"]+ assert question["type"] == "score"+ assert len(question["criteria"]) == 10+ assert len(set(question["criteria"])) == 10+ assert question["criteria"][0] == f"The score according to the evaluation criteria is {float(minimum)!r}."+ assert question["criteria"][-1] == f"The score according to the evaluation criteria is {float(maximum)!r}."+ assert prompt in question["instructions"]+ assert "Suggested score increment: 1.0" in question["instructions"]+ assert result["result_type"] == "numeric"+ assert result.get("score") == (pytest.approx(expected) if expected is not None else None)+ if index == int(index) and expected is not None:+ assert result["score"] == expected+ assert (+ question["criteria"][int(index)]+ == f"The score according to the evaluation criteria is {float(expected)!r}."+ )+ assert result["reasoning"] == ""+ assert "probability" not in result+ properties = build_evaluation_event_properties(evaluation, result, datetime(2026, 1, 1, tzinfo=UTC))+ assert properties.get("$ai_evaluation_numeric_result") == (+ pytest.approx(expected) if expected is not None else None+ )+ assert properties.get("$ai_evaluation_applicable", True) is applicable+ assert "$ai_evaluation_probability" not in properties++[email protected]("output_config", [{}, {"min": 0}, {"max": 10}, {"min": 1, "max": 1}])+def test_system_one_numeric_requires_a_score_range(output_config: dict[str, float]) -> None:with (patch("posthog.security.url_validation.resolve_host_ips", return_value={ip_address("8.8.8.8")}),patch("posthog.temporal.ai_observability.evaluation_llm_judge.model_spec") as spec,@@ -467,9 +553,17 @@ def test_system_one_numeric_mapping_is_not_enabled() -> None:),patch("httpx.AsyncHTTPTransport.handle_async_request") as request,):- spec.return_value.resolve.return_value = MagicMock(provider="system_one")+ spec.return_value.resolve.return_value = MagicMock(+ provider="system_one",+ provider_key=MagicMock(encrypted_config={"base_url": "https://decisions.example.com/v1", "api_key": ""}),+ )result = call_llm_judge(- evaluation={"team_id": 1, "output_type": "numeric"},+ evaluation={+ "team_id": 1,+ "output_type": "numeric",+ "output_config": output_config,+ "evaluation_config": {"prompt": "Score quality."},+ },system_prompt="",user_prompt="Hello!",allows_na=False,diff --git a/products/ai_observability/backend/api/evaluations.py b/products/ai_observability/backend/api/evaluations.pyindex 54c8490db6b2..2fdaed62c6bf 100644--- a/products/ai_observability/backend/api/evaluations.py+++ b/products/ai_observability/backend/api/evaluations.py@@ -184,12 +184,12 @@ class _EvaluationConfigField(serializers.JSONField):"min": {"type": "number","nullable": True,- "description": "Inclusive minimum numeric score. Omit for no lower bound.",+ "description": "Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.",},"max": {"type": "number","nullable": True,- "description": "Inclusive maximum numeric score. Omit for no upper bound.",+ "description": "Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.",},"step": {"type": "number",@@ -571,7 +571,7 @@ class EvaluationSerializer(UserAccessControlSerializerMixin, serializers.ModelSeif isinstance(model_configuration, dict)else getattr(model_configuration, "provider", None))- if model_provider == LLMProvider.SYSTEM_ONE and output_type not in ("boolean", "categorical"):+ if model_provider == LLMProvider.SYSTEM_ONE and output_type not in ("boolean", "categorical", "numeric"):raise serializers.ValidationError({"model_configuration": "Select a model that supports this evaluation output type."})@@ -622,6 +622,13 @@ class EvaluationSerializer(UserAccessControlSerializerMixin, serializers.ModelSeexcept ValueError as e:raise serializers.ValidationError({"config": str(e)})+ if model_provider == LLMProvider.SYSTEM_ONE and output_type == "numeric":+ config = data.get("output_config", getattr(self.instance, "output_config", {}))+ if config.get("min") is None or config.get("max") is None or config["min"] >= config["max"]:+ raise serializers.ValidationError(+ {"output_config": "System One numeric evaluations require a minimum score below the maximum score."}+ )+# Sentiment is addressed per-message within one generation event ($ai_target_event_id +# message index). An aggregate target emits a single evaluation event for the whole unit,# where the message index is ambiguous and that per-generation linkage is absent.diff --git a/products/ai_observability/backend/api/test/test_evaluations.py b/products/ai_observability/backend/api/test/test_evaluations.pyindex edca78fb7d1a..78427d812072 100644--- a/products/ai_observability/backend/api/test/test_evaluations.py+++ b/products/ai_observability/backend/api/test/test_evaluations.py@@ -120,22 +120,51 @@ class TestNumericEvaluationSerializer(SimpleTestCase):class TestModelConfigurationSerializer(SimpleTestCase):- @parameterized.expand([("boolean", True), ("categorical", True), ("numeric", False)])- def test_system_one_supports_boolean_and_categorical_outputs(self, output_type: str, supported: bool) -> None:+ @parameterized.expand([("boolean", {}), ("categorical", {}), ("numeric", {"min": 0, "max": 10})])+ def test_system_one_supports_evaluation_output_types(+ self, output_type: str, output_config: dict[str, float]+ ) -> None:evaluation = Evaluation(evaluation_type="llm_judge",evaluation_config={"prompt": "Score quality"},output_type=output_type,- output_config={},+ output_config=output_config,)serializer = EvaluationSerializer(instance=evaluation, partial=True)data = {"model_configuration": {"provider": "system_one", "model": "custom-model"}}- if supported:- with patch.object(serializer, "_validate_chat_model"):- self.assertEqual(serializer.validate(data), data)+ with patch.object(serializer, "_validate_chat_model"):+ self.assertEqual(serializer.validate(data), data)++ @parameterized.expand([({},), ({"min": 0},), ({"max": 10},), ({"min": 1, "max": 1},)])+ def test_system_one_requires_numeric_bounds_on_model_change(self, output_config: dict[str, float]) -> None:+ evaluation = Evaluation(+ evaluation_type="llm_judge",+ evaluation_config={"prompt": "Score quality"},+ output_type="numeric",+ output_config=output_config,+ )+ serializer = EvaluationSerializer(instance=evaluation, partial=True)+ with (+ patch.object(serializer, "_validate_chat_model"),+ self.assertRaisesMessage(ValidationError, "minimum score below the maximum"),+ ):+ serializer.validate({"model_configuration": {"provider": "system_one", "model": "custom-model"}})++ @parameterized.expand([("system_one", False), ("openai", True)])+ def test_clearing_numeric_bounds_depends_on_provider(self, provider: str, valid: bool) -> None:+ evaluation = Evaluation(+ evaluation_type="llm_judge",+ evaluation_config={"prompt": "Score quality"},+ output_type="numeric",+ output_config={"min": 0, "max": 10},+ model_configuration=LLMModelConfiguration(provider=provider, model="custom-model"),+ )+ serializer = EvaluationSerializer(instance=evaluation, data={"output_config": {"max": None}}, partial=True)+ self.assertEqual(serializer.is_valid(), valid, serializer.errors)+ if valid:+ self.assertEqual(serializer.validated_data["output_config"]["min"], 0)else:- with self.assertRaisesMessage(ValidationError, "Select a model that supports this evaluation output type"):- serializer.validate(data)+ self.assertIn("output_config", serializer.errors)@parameterized.expand([diff --git a/products/ai_observability/backend/llm/system_one.py b/products/ai_observability/backend/llm/system_one.pyindex 1341dd711a38..bfc0a05e1fd6 100644--- a/products/ai_observability/backend/llm/system_one.py+++ b/products/ai_observability/backend/llm/system_one.py@@ -55,7 +55,7 @@ def system_one_evaluations_enabled(team_id: int, *, base_url: str) -> bool:get_feature_flag_or_none("llm-analytics-system-one-evaluations",str(team.uuid),- groups={"organization": str(team.organization_id), "project": str(team.id)},+ groups={"organization": str(team.organization_id), "project": str(team.uuid)},send_feature_flag_events=False,)is Truediff --git a/products/ai_observability/backend/llm/test/test_system_one.py b/products/ai_observability/backend/llm/test/test_system_one.pyindex 4d1221d9762e..47d72d0eda4f 100644--- a/products/ai_observability/backend/llm/test/test_system_one.py+++ b/products/ai_observability/backend/llm/test/test_system_one.py@@ -1,5 +1,6 @@import jsonfrom collections.abc import Iterator+from contextlib import nullcontextfrom ipaddress import ip_addressfrom uuid import uuid4@@ -10,7 +11,7 @@ from django.test import override_settingsimport httpx-from posthog.llm.system_one import NoulAnswer, NoulQuestion+from posthog.llm.system_one import NoulAnswer, NoulQuestion, ScoreAnswer, ScoreQuestionfrom posthog.models import Teamfrom products.ai_observability.backend.llm.client import Client@@ -67,7 +68,10 @@ def test_system_one_connections_require_flag_and_reserve_posthog_gateway_for_intwith (override_settings(POSTHOG_INTERNAL_ORG_IDS=[str(team.organization_id)] if internal else []),patch("products.ai_observability.backend.llm.system_one.Team.objects.only") as teams,- patch("products.ai_observability.backend.llm.system_one.get_feature_flag_or_none", return_value=flag),+ patch(+ "products.ai_observability.backend.llm.system_one.get_feature_flag_or_none",+ side_effect=lambda *args, groups, **kwargs: flag if groups["project"] == str(team.uuid) else False,+ ),):teams.return_value.get.return_value = teamassert system_one_evaluations_enabled(team.id, base_url=base_url) is enabled@@ -147,6 +151,61 @@ def test_system_one_rejects_invalid_probabilities(probability: object) -> None:)+ "patch_answer,valid",+ [+ ({}, True),+ ({"score": 0}, True),+ ({"score": 2}, True),+ ({"score": -0.1}, False),+ ({"score": 2.1}, False),+ ({"score": True}, False),+ ({"score": "1.5"}, False),+ ({"score": float("nan")}, False),+ ({"score": float("inf")}, False),+ ({"type": "choice"}, False),+ ({"confidence": 1.1}, False),+ ({"probabilities": {"0": 0.5, "1": 0.5}}, False),+ ({"probabilities": {"0": 0, "1": 0, "2": True}}, False),+ ],+)+def test_system_one_score_response(patch_answer: dict[str, object], valid: bool) -> None:+ answer = {"score": 1.5, "confidence": 0.5, "probabilities": {"0": 0.0, "1": 0.5, "2": 0.5}, **patch_answer}+ question = ScoreQuestion(instructions="Rate answer quality.", criteria=["Incorrect", "Partly correct", "Correct"])+ with (+ patch(+ "httpx.AsyncHTTPTransport.handle_async_request",+ return_value=_response(200, {"model": "custom-model", "answers": {"score": answer}}),+ ) as request,+ nullcontext() if valid else pytest.raises(StructuredOutputParseError),+ ):+ result = SystemOneClient.evaluate(+ api_key="",+ base_url="https://decisions.example.com/v1",+ model="custom-model",+ state="Hello!",+ questions={"score": question},+ )+ if not valid:+ return+ parsed = result.answers["score"]+ assert isinstance(parsed, ScoreAnswer)+ assert parsed.score == answer["score"]+ assert parsed.confidence == 0.5+ assert parsed.probabilities == {"0": 0.0, "1": 0.5, "2": 0.5}+ assert json.loads(request.call_args.args[0].content)["questions"]["score"] == {+ "type": "score",+ "instructions": "Rate answer quality.",+ "criteria": ["Incorrect", "Partly correct", "Correct"],+ }++[email protected]("level_count", [0, 1, 11])+def test_system_one_rejects_unsupported_score_rubric_sizes(level_count: int) -> None:+ with pytest.raises(ValueError, match="between 2 and 10"):+ ScoreQuestion(instructions="Score quality.", criteria=[str(index) for index in range(level_count)])++@pytest.mark.parametrize("status", [408, 429, 503, 529])def test_system_one_rate_limits_are_retryable(status: int) -> None:response = _response(status)diff --git a/products/ai_observability/frontend/components/EvalResultBadges.test.tsx b/products/ai_observability/frontend/components/EvalResultBadges.test.tsxindex faff2a22e0ae..fa06b4decfa1 100644--- a/products/ai_observability/frontend/components/EvalResultBadges.test.tsx+++ b/products/ai_observability/frontend/components/EvalResultBadges.test.tsx@@ -66,15 +66,33 @@ describe('EvalResultBadges', () => {})it.each([- [1 / 3, '0.333333'],+ [0, '0'],+ [1 / 3, '0.33'],[123456789, '123456789'],[-123456789, '-123456789'],- [0.0000000123456789, '1.23457e-8'],- [1234567.1234567, '1234567.123457'],- ])('formats score %s without dropping integer digits', (score, label) => {+ [0.0000000123456789, '1.2e-8'],+ [1234567.1234567, '1234567.12'],+ ])('formats score %s compactly without losing its magnitude', (score, label) => {expect(getEvaluationResultDisplay(makeRun({ result_type: 'numeric', score })).label).toBe(label)})+ it.each([+ [4.899999, 'gte', 4.9, '4.899999', 'danger'],+ [4.9, 'gte', 4.9, '4.9', 'success'],+ [4.900001, 'lte', 4.9, '4.900001', 'danger'],+ [4.9, 'lte', 4.9, '4.9', 'success'],+ [4.900001, 'gte', 4.900001, '4.900001', 'success'],+ [4.899999, 'lte', 4.899999, '4.899999', 'success'],+ [10.001, 'gte', 10, '10', 'success'],+ [9.999, 'lte', 10, '10', 'success'],+ ] as const)('keeps the label for score %s consistent with %s %s', (score, operator, threshold, label, type) => {+ expect(+ getEvaluationResultDisplay(makeRun({ result_type: 'numeric', score }), {+ passingRule: { operator, threshold },+ })+ ).toMatchObject({ label, type })+ })+it.each([[[], true, ['resolved'], 'danger', 'No categories'],[['resolved'], true, ['resolved'], 'success', 'Resolved'],diff --git a/products/ai_observability/frontend/components/EvaluationResultTag.stories.tsx b/products/ai_observability/frontend/components/EvaluationResultTag.stories.tsxindex 0bfe1d917215..9b04c1ccaa90 100644--- a/products/ai_observability/frontend/components/EvaluationResultTag.stories.tsx+++ b/products/ai_observability/frontend/components/EvaluationResultTag.stories.tsx@@ -40,7 +40,7 @@ export const Numeric: Story = {<div className="space-y-2"><div>Below the passing threshold</div><EvaluationResultTag- run={{ status: 'completed', result: null, result_type: 'numeric', score: 6.5 }}+ run={{ status: 'completed', result: null, result_type: 'numeric', score: 6.999999 }}passingRule={{ operator: 'gte', threshold: 7 }}/></div>diff --git a/products/ai_observability/frontend/components/EvaluationResultTag.tsx b/products/ai_observability/frontend/components/EvaluationResultTag.tsxindex b2f4fec0bcef..1960c82ea4da 100644--- a/products/ai_observability/frontend/components/EvaluationResultTag.tsx+++ b/products/ai_observability/frontend/components/EvaluationResultTag.tsx@@ -86,10 +86,11 @@ export function getEvaluationResultDisplay(return { type: 'muted', icon: <IconMinus />, label: 'No score', sortValue: -1 }}const passed = numericScorePasses(run.score, options.passingRule)+ const label = formatNumericEvaluationScore(run.score)return {type: passed === null ? 'none' : passed ? 'success' : 'danger',icon: passed === null ? <IconMinus /> : passed ? <IconCheck /> : <IconX />,- label: formatNumericEvaluationScore(run.score),+ label: numericScorePasses(Number(label), options.passingRule) === passed ? label : String(run.score),sortValue: 4,}}diff --git a/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx b/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsxindex 084692302abd..346fc2fa81ad 100644--- a/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx+++ b/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx@@ -102,6 +102,7 @@ export function AIObservabilityEvaluation(): JSX.Element {canEnable,canEnableReason,modelSelectionRequired,+ numericBoundsRequired,} = useValues(llmEvaluationLogic)const { searchParams } = useValues(router)const { featureFlags } = useValues(featureFlagLogic)@@ -188,7 +189,7 @@ export function AIObservabilityEvaluation(): JSX.Element {: evaluation.output_type === 'categorical'? (categoricalOutputConfigError(evaluation.output_config) ?? undefined): evaluation.output_type === 'numeric'- ? (numericOutputConfigError(evaluation.output_config) ?? undefined)+ ? (numericOutputConfigError(evaluation.output_config, numericBoundsRequired) ?? undefined): undefinedconst focusTriggers = (): void => {@@ -771,6 +772,7 @@ export function AIObservabilityEvaluation(): JSX.Element {<NumericEvaluationConfigconfig={evaluation.output_config}onChange={patchOutputConfig}+ requiresBounds={numericBoundsRequired}/>)}<LemonField.Pure label="Description (optional)">@@ -958,6 +960,7 @@ function EvaluationModelPicker(): JSX.Element {(group) =>evaluation?.output_type === 'boolean' ||evaluation?.output_type === 'categorical' ||+ evaluation?.output_type === 'numeric' ||group.provider !== 'system_one')const loading = byokModelsLoading || providerKeysLoading@@ -989,7 +992,9 @@ function EvaluationModelPicker(): JSX.Element {<p className="text-sm text-muted mt-2">{evaluation.output_type === 'categorical'? 'This judge selects categories without written reasoning. For multiple selections, each category is included when its probability is 50% or higher.'- : 'This judge returns a probability without written reasoning. A probability of 50% or higher produces a true result.'}+ : evaluation.output_type === 'numeric'+ ? 'This judge estimates a score between your minimum and maximum without written reasoning. Define what low and high scores mean in your evaluation prompt. Scores can be fractional.'+ : 'This judge returns a probability without written reasoning. A probability of 50% or higher produces a true result.'}</p>)}{modelSelectionRequired && !selectedModel && (diff --git a/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.stories.tsx b/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.stories.tsxindex ccde3ae802c9..dfebe61f33e7 100644--- a/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.stories.tsx+++ b/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.stories.tsx@@ -13,7 +13,13 @@ export default metatype Story = StoryObj<typeof NumericEvaluationConfig>-function Template({ narrow = false }: { narrow?: boolean }): JSX.Element {+function Template({+ narrow = false,+ requiresBounds = false,+}: {+ narrow?: boolean+ requiresBounds?: boolean+}): JSX.Element {const [config, setConfig] = useState<EvaluationOutputConfig>({min: 0,max: 10,@@ -25,6 +31,7 @@ function Template({ narrow = false }: { narrow?: boolean }): JSX.Element {<div className={narrow ? 'max-w-lg' : 'max-w-4xl'}><NumericEvaluationConfigconfig={config}+ requiresBounds={requiresBounds}onChange={(patch) => setConfig((current) => ({ ...current, ...patch }))}/></div>@@ -33,3 +40,5 @@ function Template({ narrow = false }: { narrow?: boolean }): JSX.Element {export const Default: Story = { render: () => <Template /> }export const Narrow: Story = { render: () => <Template narrow /> }+export const SystemOne: Story = { render: () => <Template requiresBounds /> }+export const SystemOneNarrow: Story = { render: () => <Template narrow requiresBounds /> }diff --git a/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.test.tsx b/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.test.tsxindex e263c954fef7..e846acb144ec 100644--- a/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.test.tsx+++ b/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.test.tsx@@ -7,6 +7,20 @@ import { NumericEvaluationConfig } from './NumericEvaluationConfig'describe('NumericEvaluationConfig', () => {afterEach(cleanup)+ it.each([{}, { min: 0 }, { max: 10 }, { min: 1, max: 1 }])(+ 'requires a score range only for System One: %j',+ (config) => {+ const { getByLabelText, getByText } = render(+ <NumericEvaluationConfig config={config} onChange={jest.fn()} requiresBounds />+ )+ getByLabelText('Minimum')+ getByLabelText('Maximum')+ getByText('System One numeric evaluations require a minimum score below the maximum score.')+ expect(numericOutputConfigError(config)).toBeNull()+ expect(numericOutputConfigError({ min: -2, max: 4 }, true)).toBeNull()+ }+ )+it.each([['min', 'Minimum (optional)'],['max', 'Maximum (optional)'],diff --git a/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.tsx b/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.tsxindex 56bb6cc0f222..f688cbbee6e3 100644--- a/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.tsx+++ b/products/ai_observability/frontend/evaluations/components/NumericEvaluationConfig.tsx@@ -10,13 +10,15 @@ import type { EvaluationOutputConfig } from '../types'export function NumericEvaluationConfig({config,onChange,+ requiresBounds = false,}: {config: EvaluationOutputConfigonChange: (patch: EvaluationOutputConfig) => void+ requiresBounds?: boolean}): JSX.Element {const id = useId()const rule = config.passing_rule && 'threshold' in config.passing_rule ? config.passing_rule : null- const error = numericOutputConfigError(config)+ const error = numericOutputConfigError(config, requiresBounds)return (<div className="space-y-4">{error && <LemonBanner type="error">{error}</LemonBanner>}@@ -25,7 +27,18 @@ export function NumericEvaluationConfig({<LemonField.Purekey={field}htmlFor={`${id}-${field}`}- label={{ min: 'Minimum (optional)', max: 'Maximum (optional)', step: 'Step (optional)' }[field]}+ info={+ field === 'step'+ ? 'Suggests a score increment to LLM judges, including System One. Scores are not rounded or restricted to this increment. Hog evaluations use the score returned by your code.'+ : undefined+ }+ label={+ {+ min: requiresBounds ? 'Minimum' : 'Minimum (optional)',+ max: requiresBounds ? 'Maximum' : 'Maximum (optional)',+ step: 'Step (optional)',+ }[field]+ }><LemonInputid={`${id}-${field}`}@@ -38,7 +51,7 @@ export function NumericEvaluationConfig({</LemonField.Pure>))}</div>- <p className="text-muted text-sm">Bounds are inclusive. Step guides scoring without rounding results.</p>+ <p className="text-muted text-sm">Bounds are inclusive.</p><LemonSwitchlabel="Allow N/A responses"checked={config.allows_na ?? false}diff --git a/products/ai_observability/frontend/evaluations/constants.ts b/products/ai_observability/frontend/evaluations/constants.tsindex bebbe1633f3f..4e653cbdb50c 100644--- a/products/ai_observability/frontend/evaluations/constants.ts+++ b/products/ai_observability/frontend/evaluations/constants.ts@@ -21,12 +21,15 @@ const EVALUATION_RESULT_FALSE_HOGQL = "properties.$ai_evaluation_result = 'falseexport const EVALUATION_NOT_SKIPPED_HOGQL ="(isNull(properties.$ai_evaluation_skipped) OR properties.$ai_evaluation_skipped != 'true')"-export function numericOutputConfigError(config: EvaluationOutputConfig): string | null {+export function numericOutputConfigError(config: EvaluationOutputConfig, requiresBounds = false): string | null {const { min, max, step } = configconst passing_rule = config.passing_rule && 'threshold' in config.passing_rule ? config.passing_rule : nullif ([min, max, step, passing_rule?.threshold].some((value) => value != null && !Number.isFinite(value))) {return 'Enter finite numbers for the score bounds, step, and threshold.'}+ if (requiresBounds && (min == null || max == null || min >= max)) {+ return 'System One numeric evaluations require a minimum score below the maximum score.'+ }if (min != null && max != null && min > max) {return 'Minimum must be less than or equal to maximum.'}@@ -85,7 +88,7 @@ export function evaluationPassedHogQLForMany(detectorEvaluationIds: string[]): s}export function formatNumericEvaluationScore(score: number): string {- return Number(Math.abs(score) >= 1 ? score.toFixed(6) : score.toPrecision(6)).toString()+ return Number(Math.abs(score) >= 1 ? score.toFixed(2) : score.toPrecision(2)).toString()}export function numericScorePasses(diff --git a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.tsindex 43b71ee19333..7d0b6397e4c3 100644--- a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts+++ b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts@@ -722,6 +722,29 @@ return result`,await expectLogic(logic).toMatchValues({ formValid: true })})+ it('requires numeric bounds only while a System One judge is selected', async () => {+ await expectLogic(logic).toDispatchActions(['loadEvaluationSuccess'])+ logic.actions.loadEvaluationSuccess({+ ...mockEvaluation,+ output_type: 'numeric',+ output_config: {},+ model_configuration: { provider: 'system_one', model: 'custom-model', provider_key_id: 'key-1' },+ })+ expect(logic.values.formValid).toBe(false)++ logic.actions.patchOutputConfig({ min: 1, max: 10 })+ expect(logic.values.formValid).toBe(true)+ logic.actions.patchOutputConfig({ max: null })+ expect(logic.values.formValid).toBe(false)++ logic.actions.setModelConfiguration({+ provider: 'openai',+ model: 'gpt-5-mini',+ provider_key_id: 'key-1',+ })+ expect(logic.values.formValid).toBe(true)+ })+// A loaded evaluation whose stored shape doesn't match its type (e.g. an llm_judge// record with no prompt) used to crash formValid with a TypeError on render.it.each([diff --git a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.tsindex 1172c06f0aa3..2dd5722f0a52 100644--- a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts+++ b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts@@ -325,6 +325,7 @@ export interface llmEvaluationLogicValues {isReportableEvaluation: booleanmaxContext: MaxContextInput[]modelSelectionRequired: boolean+ numericBoundsRequired: booleanoriginalEvaluation: EvaluationConfig | nulloutputConfigDrafts: Partial<Record<'boolean' | 'categorical' | 'numeric', EvaluationOutputConfig>>runsBackfill: EvaluationBackfillApi | null@@ -539,7 +540,12 @@ export interface llmEvaluationLogicMeta {originalEvaluation: EvaluationConfig | null,evaluationId: string) => boolean- formValid: (evaluation: EvaluationConfig | null, modelSelectionRequired: boolean) => boolean+ numericBoundsRequired: (evaluation: EvaluationConfig | null) => boolean+ formValid: (+ evaluation: EvaluationConfig | null,+ modelSelectionRequired: boolean,+ numericBoundsRequired: boolean+ ) => booleancanEnable: (evaluation: EvaluationConfig | null,activeProviderKey: LLMProviderKey | null | undefined@@ -1493,14 +1499,22 @@ export const llmEvaluationLogic = kea<llmEvaluationLogicType>([},],+ numericBoundsRequired: [+ (s) => [s.evaluation],+ (evaluation: EvaluationConfig | null): boolean =>+ isLLMJudgeEvaluation(evaluation) &&+ evaluation.output_type === 'numeric' &&+ evaluation.model_configuration?.provider === 'system_one',+ ],formValid: [- (s) => [s.evaluation, s.modelSelectionRequired],- (evaluation: EvaluationConfig | null, modelSelectionRequired: boolean) => {+ (s) => [s.evaluation, s.modelSelectionRequired, s.numericBoundsRequired],+ (evaluation: EvaluationConfig | null, modelSelectionRequired: boolean, numericBoundsRequired: boolean) => {if (!evaluation) {return false}if (- (evaluation.output_type === 'numeric' && numericOutputConfigError(evaluation.output_config)) ||+ (evaluation.output_type === 'numeric' &&+ numericOutputConfigError(evaluation.output_config, numericBoundsRequired)) ||(evaluation.output_type === 'categorical' && categoricalOutputConfigError(evaluation.output_config))) {return falsediff --git a/products/ai_observability/frontend/generated/api.schemas.ts b/products/ai_observability/frontend/generated/api.schemas.tsindex 6935f83d86b3..e37a79a48bbb 100644--- a/products/ai_observability/frontend/generated/api.schemas.ts+++ b/products/ai_observability/frontend/generated/api.schemas.ts@@ -1909,12 +1909,12 @@ export type EvaluationApiOutputConfig = {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null@@ -2230,12 +2230,12 @@ export type PatchedEvaluationApiOutputConfig = {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null@@ -2409,12 +2409,12 @@ export type TestHogRequestApiOutputConfig = {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null@@ -3141,12 +3141,12 @@ export type EvaluationReportMetricsApiOutputConfig = {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | nulldiff --git a/products/ai_observability/frontend/generated/api.zod.ts b/products/ai_observability/frontend/generated/api.zod.tsindex c69157c601d5..935466c7dbe0 100644--- a/products/ai_observability/frontend/generated/api.zod.ts+++ b/products/ai_observability/frontend/generated/api.zod.ts@@ -606,8 +606,18 @@ export const EvaluationsCreateBody = /* @__PURE__ */ zod.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsCreateBodyOutputConfigStepExclusiveMin)@@ -981,8 +991,18 @@ export const EvaluationsUpdateBody = /* @__PURE__ */ zod.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsUpdateBodyOutputConfigStepExclusiveMin)@@ -1260,8 +1280,18 @@ export const EvaluationsPartialUpdateBody = /* @__PURE__ */ zod.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsPartialUpdateBodyOutputConfigStepExclusiveMin)@@ -1487,8 +1517,18 @@ export const EvaluationsTestHogCreateBody = /* @__PURE__ */ zod.object({.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsTestHogCreateBodyOutputConfigStepExclusiveMin)diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex ae94e89ea634..8bff02d8bf5e 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -40307,12 +40307,12 @@ export namespace Schemas {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean;/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null;/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null;@@ -40939,12 +40939,12 @@ export namespace Schemas {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean;/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null;/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null;@@ -75999,12 +75999,12 @@ export namespace Schemas {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean;/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null;/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null;@@ -104221,12 +104221,12 @@ export namespace Schemas {/** Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail. */true_is_failure?: boolean;/**- * Inclusive minimum numeric score. Omit for no lower bound.+ * Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.* @nullable*/min?: number | null;/**- * Inclusive maximum numeric score. Omit for no upper bound.+ * Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.* @nullable*/max?: number | null;diff --git a/services/mcp/src/generated/ai_observability/api.ts b/services/mcp/src/generated/ai_observability/api.tsindex e0973621dd9c..0f812496e53e 100644--- a/services/mcp/src/generated/ai_observability/api.ts+++ b/services/mcp/src/generated/ai_observability/api.ts@@ -654,8 +654,18 @@ export const EvaluationsCreateBody = () => zod.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsCreateBodyOutputConfigStepExclusiveMin)@@ -1110,8 +1120,18 @@ export const EvaluationsPartialUpdateBody = () => zod.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsPartialUpdateBodyOutputConfigStepExclusiveMin)@@ -1357,8 +1377,18 @@ export const EvaluationsTestHogCreateBody = () => zod.object({.describe('Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'),- min: zod.number().nullish().describe('Inclusive minimum numeric score. Omit for no lower bound.'),- max: zod.number().nullish().describe('Inclusive maximum numeric score. Omit for no upper bound.'),+ min: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges.'+ ),+ max: zod+ .number()+ .nullish()+ .describe(+ 'Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min.'+ ),step: zod.number().gt(evaluationsTestHogCreateBodyOutputConfigStepExclusiveMin)diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-create.jsonindex df04ff44474e..121f11f37e6e 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-create.json@@ -180,7 +180,7 @@"type": "null"}],- "description": "Inclusive maximum numeric score. Omit for no upper bound."+ "description": "Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min."},"min": {"anyOf": [@@ -191,7 +191,7 @@"type": "null"}],- "description": "Inclusive minimum numeric score. Omit for no lower bound."+ "description": "Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges."},"options": {"description": "Categorical output options. Keys identify stored results; labels are displayed to users.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-test-hog.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-test-hog.jsonindex 85654a61d5ee..09560ef5b1d7 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-test-hog.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-test-hog.json@@ -33,7 +33,7 @@"type": "null"}],- "description": "Inclusive maximum numeric score. Omit for no upper bound."+ "description": "Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min."},"min": {"anyOf": [@@ -44,7 +44,7 @@"type": "null"}],- "description": "Inclusive minimum numeric score. Omit for no lower bound."+ "description": "Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges."},"options": {"description": "Categorical output options. Keys identify stored results; labels are displayed to users.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-update.jsonindex fe7324d3653e..1796d3d8a920 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-update.json@@ -183,7 +183,7 @@"type": "null"}],- "description": "Inclusive maximum numeric score. Omit for no upper bound."+ "description": "Inclusive maximum numeric score. Omit for no upper bound. Required for System One numeric judges and must exceed min."},"min": {"anyOf": [@@ -194,7 +194,7 @@"type": "null"}],- "description": "Inclusive minimum numeric score. Omit for no lower bound."+ "description": "Inclusive minimum numeric score. Omit for no lower bound. Required for System One numeric judges."},"options": {"description": "Categorical output options. Keys identify stored results; labels are displayed to users.",