From 487117042c1b7206128743d5427f8326de04c1c5 Mon Sep 17 00:00:00 2001 From: rudra717 <52209277+rudra717@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:04:28 -0700 Subject: [PATCH] fix(guardrails): Azure prompt_shield and text_moderation now check input for Responses API Both Azure guardrails (prompt_shield, text_moderation) only checked data["messages"] for user content. The Responses API (/v1/responses) uses data["input"] instead, causing both guardrails to silently skip with "No messages in data" warning. Fall back to data["input"] when data["messages"] is absent so guardrails run correctly for both /v1/chat/completions and /v1/responses endpoints. Fixes BerriAI/litellm#25215 Co-Authored-By: Claude --- litellm/proxy/guardrails/guardrail_hooks/azure/prompt_shield.py | 2 +- .../proxy/guardrails/guardrail_hooks/azure/text_moderation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/azure/prompt_shield.py b/litellm/proxy/guardrails/guardrail_hooks/azure/prompt_shield.py index 5f7e04cfb8b..5f06eeb5d89 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/azure/prompt_shield.py +++ b/litellm/proxy/guardrails/guardrail_hooks/azure/prompt_shield.py @@ -134,7 +134,7 @@ class AzureContentSafetyPromptShieldGuardrail(AzureGuardrailBase, CustomGuardrai "Azure Prompt Shield: Running pre-call prompt scan, on call_type: %s", call_type, ) - new_messages: Optional[List[AllMessageValues]] = data.get("messages") + new_messages: Optional[List[AllMessageValues]] = data.get("messages") or data.get("input") if new_messages is None: verbose_proxy_logger.warning( "Azure Prompt Shield: not running guardrail. No messages in data" diff --git a/litellm/proxy/guardrails/guardrail_hooks/azure/text_moderation.py b/litellm/proxy/guardrails/guardrail_hooks/azure/text_moderation.py index a465c5428dd..0b15438907b 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/azure/text_moderation.py +++ b/litellm/proxy/guardrails/guardrail_hooks/azure/text_moderation.py @@ -227,7 +227,7 @@ class AzureContentSafetyTextModerationGuardrail(AzureGuardrailBase, CustomGuardr "Azure Text Moderation: Running pre-call prompt scan, on call_type: %s", call_type, ) - new_messages: Optional[List[AllMessageValues]] = data.get("messages") + new_messages: Optional[List[AllMessageValues]] = data.get("messages") or data.get("input") if new_messages is None: verbose_proxy_logger.warning( "Azure Text Moderation: not running guardrail. No messages in data"