From d422c63a60533867139bb895795d666524fc8bb8 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 16 Feb 2026 15:44:32 -0800 Subject: [PATCH] feat: add GuardrailTracingDetail TypedDict and tracing fields to StandardLoggingGuardrailInformation --- litellm/types/utils.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 80c03ec5ea2..5fbfd23b2db 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -2620,6 +2620,48 @@ class StandardLoggingGuardrailInformation(TypedDict, total=False): } """ + guardrail_id: Optional[str] + """Unique identifier for the guardrail configuration, e.g. 'gd-eu-pii-001'""" + + policy_template: Optional[str] + """Name of the policy template this guardrail belongs to, e.g. 'EU AI Act Article 5'""" + + detection_method: Optional[str] + """How detection was performed: 'regex', 'keyword', 'llm-judge', 'presidio', etc.""" + + confidence_score: Optional[float] + """For LLM-judge guardrails: confidence score 0.0-1.0""" + + classification: Optional[dict] + """For LLM-judge guardrails: structured classification output""" + + match_details: Optional[List[dict]] + """Detailed match information for each detected pattern""" + + patterns_checked: Optional[int] + """Total number of patterns evaluated by this guardrail""" + + alert_recipients: Optional[List[str]] + """Email addresses that were notified""" + + +class GuardrailTracingDetail(TypedDict, total=False): + """ + Typed fields for guardrail tracing metadata. + + Passed to add_standard_logging_guardrail_information_to_request_data() + to enrich the StandardLoggingGuardrailInformation with provider-specific details. + """ + + guardrail_id: Optional[str] + policy_template: Optional[str] + detection_method: Optional[str] + confidence_score: Optional[float] + classification: Optional[dict] + match_details: Optional[List[dict]] + patterns_checked: Optional[int] + alert_recipients: Optional[List[str]] + StandardLoggingPayloadStatus = Literal["success", "failure"]