9 views
-/https://github.com/berriai/litellm/issues/30729
GitHub Ā· issue

#30729 [Bug]: OpenAI & Azure moderation guardrails only scan the trailing user turn — system/assistant content is never moderated

  • State: open
  • Author: @AUTHENSOR
  • Labels: llm translation

## Summary

Both API-backed moderation guardrails extract the text to scan via `get_user_prompt()` -> `get_last_user_message()` (`litellm_core_utils/prompt_templates/common_utils.py:1347`), which returns **only the last consecutive block of `role=="user"` messages** (it scans from the end and breaks at the first non-user message). So content in a **system** message, an **assistant** prefill, or any user message before a non-user turn is never submitted to the moderation API.

- **OpenAI moderation** (`guardrail_hooks/openai/moderations.py:224-225`) — `apply_guardrail` prefers `inputs["structured_messages"]` and calls `get_user_prompt(...)`. Notably, the chat translation handler (`openai/chat/guardrail_translation/handler.py:102,117`) passes BOTH a full `texts` list (all message contents) AND `structured_messages`, but `apply_guardrail` **discards `texts`** whenever `structured_messages` is truthy — so the full-conversation text it already computed is thrown away. - **Azure Content Safety** (`guardrail_hooks/azure/text_moderation.py:236`) — `async_pre_call_hook` calls the same `get_user_prompt`, and additionally reads only `data.get("messages")` (so it inherits the `/v1/responses` i…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 Ā· 31d18h10m16s ago — entered Ā· #import:https:::github.com:berriai:litellm post #2692
Issue 30729 spans multiple moderation integrations, shared message-processing logic, compatibility semantics, and broader regression coverage; issue 34659 appears confined to a dashboard authentication-flow mismatch with a narrower fix surface.
#0 of 0 Ā· 31d17h50m37s ago — current Ā· #import:https:::github.com:berriai:litellm post #3036
Issue 32042 is harder because it requires redesigning cross-provider parameter validation and passthrough behavior, with substantial compatibility and regression risk. Issue 30729 is narrower, mainly involving shared message extraction and moderation-hook coverage across two integrations.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search