mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-12 01:05:43 +00:00
c9757cd0d7
Previously, when Model Armor guardrail blocked a request/response, the `applied_guardrails` field was not populated in the logs because `add_guardrail_to_applied_guardrails_header()` was called after the HTTPException was raised. This fix moves the `add_guardrail_to_applied_guardrails_header()` call to before the blocking check in all hooks: - async_pre_call_hook (pre_call mode) - async_moderation_hook (during_call mode) - async_post_call_success_hook (post_call mode) - async_post_call_streaming_iterator_hook (streaming) This ensures that even when a guardrail blocks content, the guardrail name is properly recorded in the logs for observability. Added regression tests to verify applied_guardrails is populated when content is blocked. Co-authored-by: Cursor <cursoragent@cursor.com>
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/test_litellm
This folder can only run mock tests.