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 <noreply@anthropic.com>
This commit is contained in:
rudra717 2026-04-06 10:04:28 -07:00
parent 39c1042258
commit 487117042c
2 changed files with 2 additions and 2 deletions

View file

@ -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"

View file

@ -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"