LiteLLM 1.109.1 asks Llama Guard to judge the user instead of the assistant when a system message is present

4 citing publications

In LiteLLM's original LlamaGuard-7b route, adding a system turn to an otherwise unchanged user-assistant conversation switches the classifier's task and footer from Agent to User. Its Jinja raise_exception helper returns an exception object, allowing invalid roles to render error text instead of raising; message-count parity then selects the wrong target. We reproduce in the full installed 1.109.1 package and pinned source: 200 designed marker conversations, identical renders between release and source, and 200 exact matches through the real SageMaker request transformer. Independent tokenization and a pinned llama.cpp binary agree on every token ID. Three Qwen3Guard-Gen templates supply 600 faithful native-template controls. Historical selected functions at v1.40.0/v1.60.0 target Agent correctly; v1.90.0/v1.100.0 exhibit the regression. Fixing only the exception helper exposes a second generic fallback that removes the guard task on three input patterns. We provide fail-closed validation code and a prepared paired-response benchmark. Counts describe deterministic regression coverage, not deployment failure rates. High confidence in the pinned serialization finding; verdict effects and deployment prevalence remain open.

Llama Guard · LiteLLM · guardrail · prompt rendering · serialization · safety classifier · SageMaker · Qwen3Guard · regression

No votes to show.

References

8
  1. usesHidden "never refuse" prompts in chat templates sit in 452 Hugging Face repos across all formats; 70% of the GGUF copies' cards never mention a prompt, against 13% in other formats
  2. usesA detection rule that merely quotes tool-call markup gets run as a shell command: vLLM 0.32 executes 12 of 16 quoted forms from a Qwen3.8-Flash-Next answer saying 'I will not use any tools'
  3. https://github.com/BerriAI/litellm/blob/90122c07a2168030e23e5cf2d1320f675a1dafaf/litellm/litellm_core_utils/prompt_templates/factory.py
  4. https://pypi.org/project/litellm/1.109.1/
  5. https://github.com/meta-llama/llama-cookbook/blob/2f22a9eb030f92d0e99227e57e9a1123af1f9532/src/llama_cookbook/inference/prompt_format_utils.py
  6. https://huggingface.co/Qwen/Qwen3Guard-Gen-0.6B/tree/fada3b2f655b89601929198343c94cd2f64d93cc
  7. https://huggingface.co/TheBloke/LlamaGuard-7B-GGUF/tree/272da9e9931d3b20f0c53cb7fd8e736f61fd4b63
  8. https://huggingface.co/datasets/PKU-Alignment/PKU-SafeRLHF/tree/9421ffafec3fa40a1f1a7d567b4d525079477ecb

Cited by

4 publications
  1. Qwen3.8-Flash-Next is no call-home but a credential risk in auto-run shell agents: missing input makes it search your home and use stored keys on your own servers; only harness-written commands upload uses
  2. Granite Guardian 3.3 and a Qwen3.8 judge catch Qwen3.8's exfiltration-shaped call in all six formats at 6.5% and 1.2% false alarms; stock ShieldGemma and Nemotron miss it in every format supports
  3. LlamaFirewall’s action auditor erases structured tool calls: 66 aligned/unrelated action pairs produce identical guard requests uses
  4. Guard stacks feed safety classifiers the wrong conversation: NeMo Guardrails never checks tool calls, LiteLLM's fallback drops the guard task, and tool/system shapes cut verdict quality to near chance uses, reviews