From bb81b1dae059ae96e36f446c0941d59790ed6c1d Mon Sep 17 00:00:00 2001 From: Yucheng Zhu Date: Sat, 11 Jul 2026 10:57:37 -0700 Subject: [PATCH] fix(guardrails): address greptile review - guard input_type kwarg presence, add str to guardrail_mode type --- litellm/integrations/custom_guardrail.py | 2 +- litellm/types/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/integrations/custom_guardrail.py b/litellm/integrations/custom_guardrail.py index cf75fb38b75..5859e7f3693 100644 --- a/litellm/integrations/custom_guardrail.py +++ b/litellm/integrations/custom_guardrail.py @@ -1129,7 +1129,7 @@ def log_guardrail_information(func): "async_post_call_streaming_hook", ): return GuardrailEventHooks.post_call - elif func_name == "apply_guardrail" and kwargs: + elif func_name == "apply_guardrail" and kwargs and "input_type" in kwargs: input_type = kwargs.get("input_type") if input_type == "request": return GuardrailEventHooks.pre_call diff --git a/litellm/types/utils.py b/litellm/types/utils.py index e33e2335525..1f54a3e63a8 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -2698,7 +2698,7 @@ GuardrailStatus = Literal["success", "guardrail_intervened", "guardrail_failed_t class StandardLoggingGuardrailInformation(TypedDict, total=False): guardrail_name: Optional[str] guardrail_provider: Optional[str] - guardrail_mode: Optional[Union[GuardrailEventHooks, List[GuardrailEventHooks], GuardrailMode]] + guardrail_mode: Optional[Union[GuardrailEventHooks, List[GuardrailEventHooks], GuardrailMode, str]] guardrail_request: Optional[Union[str, dict]] guardrail_response: Optional[Union[dict, str, List[dict]]] guardrail_status: GuardrailStatus