From 5896ec8c02841ee659e390e47099006624efcb8e Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 23 Apr 2026 17:02:56 -0700 Subject: [PATCH] fix(llm_as_a_judge): remove dead registry dicts, fix KeyError in prompt builder, set correct status on judge failure --- .../guardrail_hooks/llm_as_a_judge/__init__.py | 13 +++---------- 1 file changed, 3 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 4bcdf624aee..0a7abdbf5d2 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 @@ -12,7 +12,7 @@ from litellm.integrations.custom_guardrail import ( CustomGuardrail, log_guardrail_information, ) -from litellm.types.guardrails import GuardrailEventHooks, SupportedGuardrailIntegrations +from litellm.types.guardrails import GuardrailEventHooks from litellm.types.utils import GenericGuardrailAPIInputs, GuardrailStatus if TYPE_CHECKING: @@ -71,7 +71,7 @@ def _build_judge_prompt( response_text: str, ) -> str: criteria_block = "\n".join( - f'- {c["name"]} (weight {c["weight"]}%): {c.get("description", "")}' + f'- {c.get("name", "")} (weight {c.get("weight", 0)}%): {c.get("description", "")}' for c in criteria ) conversation = "\n".join( @@ -181,6 +181,7 @@ class LLMAsAJudgeGuardrail(CustomGuardrail): verbose_logger.warning( f"llm_as_a_judge guardrail: judge call failed, failing open. Error: {judge_err}" ) + status = "guardrail_failed_to_respond" return inputs try: @@ -297,14 +298,6 @@ def initialize_guardrail( return instance -guardrail_initializer_registry = { - SupportedGuardrailIntegrations.LLM_AS_A_JUDGE.value: initialize_guardrail, -} - -guardrail_class_registry = { - SupportedGuardrailIntegrations.LLM_AS_A_JUDGE.value: LLMAsAJudgeGuardrail, -} - __all__ = [ "LLMAsAJudgeGuardrail", "initialize_guardrail",