From 47d238b2288f8de08be1ba240e79d3b4711b3ec1 Mon Sep 17 00:00:00 2001 From: Zamuldinov Nikita <59732804+NIK-TIGER-BILL@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:37:06 +0300 Subject: [PATCH] fix(guardrails): add 'block' as valid on_violation value in BaseLitellmParams (#23685) Guardrail configs loaded from the database can have on_violation='block' (a natural choice for "block the request"). The current Pydantic schema only accepts Literal["warn", "end_session"], causing a validation error: Input should be 'warn' or 'end_session' [type=literal_error, input_value='block', ...] Add 'block' to the Literal type so existing configs with on_violation='block' are accepted instead of crashing the proxy on startup. Fixes #23624 Co-authored-by: NIK-TIGER-BILL --- litellm/types/guardrails.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/types/guardrails.py b/litellm/types/guardrails.py index d5abf5c8fbf..38fc2c3eef8 100644 --- a/litellm/types/guardrails.py +++ b/litellm/types/guardrails.py @@ -656,9 +656,9 @@ 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.", + description="For /v1/realtime sessions: 'warn' speaks the violation message and continues; 'end_session' speaks the message and closes the connection. 'block' rejects the request (same as the default guardrail behaviour).", ) realtime_violation_message: Optional[str] = Field( default=None,