From 138bcc8051a7dfba4440c9be143644575682d800 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Fri, 24 Apr 2026 11:33:50 -0700 Subject: [PATCH] fix(llm_as_a_judge): set guardrail_status=guardrail_intervened when score fails, regardless of on_failure mode --- .../llm_as_a_judge/__init__.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py b/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py index 1fdde2835d5..45bdd6dd09f 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py +++ b/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py @@ -209,17 +209,18 @@ class LLMAsAJudgeGuardrail(CustomGuardrail): else: _metadata["eval_information"] = eval_info - if not passed and self.on_failure == "block": + if not passed: status = "guardrail_intervened" - raise HTTPException( - status_code=422, - detail={ - "error": "LLM judge rejected response: score below threshold", - "overall_score": overall_score, - "threshold": self.overall_threshold, - "verdicts": judge_result.get("verdicts", []), - }, - ) + if self.on_failure == "block": + raise HTTPException( + status_code=422, + detail={ + "error": "LLM judge rejected response: score below threshold", + "overall_score": overall_score, + "threshold": self.overall_threshold, + "verdicts": judge_result.get("verdicts", []), + }, + ) return inputs