From 6adb6a632d9f79d11a5a49ec7964e323d51b22a9 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Sat, 14 Mar 2026 20:47:08 +0800 Subject: [PATCH] fix: add 'block' to on_violation Literal type in BaseLitellmParams Fixes BerriAI/litellm#23624. The on_violation field only allowed 'warn' and 'end_session', but 'block' is a valid value used in guardrail configs. This caused a pydantic validation error when loading guardrails from the database. --- litellm/types/guardrails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/types/guardrails.py b/litellm/types/guardrails.py index d5abf5c8fbf..413a340f3c3 100644 --- a/litellm/types/guardrails.py +++ b/litellm/types/guardrails.py @@ -656,7 +656,7 @@ class BaseLitellmParams( default=None, description="For /v1/realtime sessions: automatically close the session after this many guardrail violations.", ) - on_violation: Optional[Literal["warn", "end_session"]] = Field( + on_violation: Optional[Literal["warn", "end_session", "block"]] = Field( default=None, description="For /v1/realtime sessions: 'warn' speaks the violation message and continues; 'end_session' speaks the message and closes the connection.", )