litellm/litellm
Yassin Kortam 10bd7406e0
feat: add guardrail violation span attributes and fix missing spans on pre-call blocks (#28364)
- Fix missing guardrail child spans when a pre-call guardrail blocks the request before reaching the LLM provider; `async_post_call_failure_hook` now calls `_emit_guardrail_spans_from_request_data` to emit spans from `request_data["metadata"]` regardless of whether `_handle_failure` already fired
- Add `guardrail_status`, `guardrail_action`, and `guardrail_violation_categories` as queryable top-level OTEL span attributes so trace backends can filter/group by violation type without parsing the redacted `guardrail_response` blob
- Introduce `_emit_guardrail_spans_from_request_data` helper that constructs minimal kwargs from `request_data["metadata"]` and routes through `_create_guardrail_span`, sharing the same dedupe state to prevent double-emitting when both failure hooks fire
- Extend `BedrockGuardrail` with `_build_tracing_detail` and `_extract_violation_category_names` which flatten BLOCKED assessments into human-readable category labels (topic names, content-filter types, PII entity types, named regex names) before redaction, and surface Bedrock's raw `action` field via `tracing_detail`
- Security: violation category extraction deliberately omits `customWords.match` and unnamed regex `match` values because those fields carry the user-submitted content that triggered the rule; only operator-defined `name`/`type` labels are emitted
- Add `violation_categories` and `guardrail_action` fields to `StandardLoggingGuardrailInformation` and `GuardrailTracingDetail` TypedDicts to carry the pre-redaction metadata through the logging pipeline
- Add comprehensive test suite covering: guardrail span creation on failure, dedupe between `_handle_failure` and `async_post_call_failure_hook`, per-span status attributes for multi-guardrail sequences, Bedrock category extraction for all policy types, security leak prevention, and end-to-end `CustomGuardrail` violation path

Co-authored-by: Yassin Kortam <yassinkortam@g.ucla.edu>
2026-05-21 15:49:42 -07:00
..
a2a_protocol
anthropic_interface
assistants
batch_completion
batches fix(vertex-ai): fix zero cost/usage on completed Vertex AI batch jobs (#27912) 2026-05-15 04:47:02 -07:00
caching fix(caching): replay openai/responses bridge cache hits as chat streams (#28158) 2026-05-18 16:27:06 -07:00
completion_extras Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
compression
containers
endpoints/speech/speech_to_completion_bridge
evals
experimental_mcp_client feat(mcp): add OBO MCP Auth (#27421) 2026-05-07 15:35:21 -07:00
files thread trusted params through vertex file content 2026-05-01 18:24:22 -07:00
fine_tuning
google_genai
images
integrations feat: add guardrail violation span attributes and fix missing spans on pre-call blocks (#28364) 2026-05-21 15:49:42 -07:00
interactions fix(interactions): never drop streamed text deltas; always emit terminal completion (#28394) 2026-05-20 16:41:40 -07:00
litellm_core_utils fix(logging): recalculate cost after router retry failures (#28476) 2026-05-21 14:07:05 -07:00
llms fix(vertex_gemma): strip context_management from request body (#28438) 2026-05-21 23:10:33 +05:30
ocr chore: reject bare str at file-input sinks to prevent local-file read (#27762) 2026-05-12 16:40:07 -07:00
passthrough
proxy feat: add guardrail violation span attributes and fix missing spans on pre-call blocks (#28364) 2026-05-21 15:49:42 -07:00
proxy_auth
rag
realtime_api
rerank_api
responses Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
router_strategy feat: add weighted-routing failover (#27980) 2026-05-15 17:28:54 +00:00
router_utils fix(responses): register cooldowns on failure + fail fast on stale encrypted_content (#27820) 2026-05-13 09:03:13 -07:00
search
secret_managers Implement normalize_nonempty_secret_str function to trim whitespace from secrets and treat empty values as unset. Update proxy_server to use this function for Grafana credentials. Enhance tests to validate the new normalization behavior. 2026-05-04 18:17:31 +00:00
skills
types feat: add guardrail violation span attributes and fix missing spans on pre-call blocks (#28364) 2026-05-21 15:49:42 -07:00
vector_store_files
vector_stores
videos
__init__.py fix: end user logs (#27758) (#28290) 2026-05-20 23:37:19 -07:00
_internal_context.py
_lazy_imports_registry.py fix(utils): import get_secret at runtime (#28014) 2026-05-15 14:01:18 -07:00
_lazy_imports.py
_logging.py fix(bedrock-mantle): use /anthropic/v1/messages path for Mantle endpo… (#27976) 2026-05-15 13:31:59 -07:00
_redis_credential_provider.py feat: add ability to auth to azure with token (#27556) 2026-05-09 22:34:09 +00:00
_redis.py Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
_service_logger.py
_uuid.py
_version.py
anthropic_beta_headers_config.json fix(anthropic,bedrock,databricks): four reasoning_effort follow-ups 2026-05-03 10:03:53 -07:00
anthropic_beta_headers_manager.py
blog_posts.json
budget_manager.py docs(budget_manager): add docstring to BudgetManager.reset_cost (#27867) 2026-05-13 13:28:22 -07:00
constants.py feat(mcp): support MCP access group names in URL-based namespacing (#27726) 2026-05-13 20:20:38 -07:00
cost_calculator.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
cost.json
exceptions.py Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
main.py Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
model_prices_and_context_window_backup.json Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
mypy.ini
policy_templates_backup.json
provider_endpoints_support_backup.json
py.typed
router.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
scheduler.py
setup_wizard.py
timeout.py docs: add class docstring to _LoopWrapper (#27870) 2026-05-13 13:54:00 -07:00
utils.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00