From baa488a10a73471883497ab7f45fec7f903bf103 Mon Sep 17 00:00:00 2001 From: Harshit Kulkarni Date: Thu, 5 Nov 2026 20:33:38 +0530 Subject: [PATCH] fix(proxy): also redact instructions and system fields on guardrail failure --- litellm/proxy/litellm_pre_call_utils.py | 2 +- tests/unit/proxy/test_litellm_pre_call_utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index 6a83e17f52b..782ad239c62 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -2623,7 +2623,7 @@ def redact_proxy_server_request_body_on_guardrail_block( body: Final = proxy_server_request.get("body") if not isinstance(body, dict): return - for field in ("messages", "prompt", "input"): + for field in ("messages", "prompt", "input", "instructions", "system"): if field in body: body[field] = "[REDACTED - BLOCKED BY GUARDRAIL]" diff --git a/tests/unit/proxy/test_litellm_pre_call_utils.py b/tests/unit/proxy/test_litellm_pre_call_utils.py index a0f8043b8f7..126ee565e16 100644 --- a/tests/unit/proxy/test_litellm_pre_call_utils.py +++ b/tests/unit/proxy/test_litellm_pre_call_utils.py @@ -1410,6 +1410,8 @@ def test_redact_proxy_server_request_body_on_guardrail_block(): "model": "gpt-4", "messages": [{"role": "user", "content": "secret password is supersecret"}], "prompt": "supersecret prompt", + "instructions": "supersecret instruction", + "system": "supersecret system", }, }, } @@ -1419,6 +1421,8 @@ def test_redact_proxy_server_request_body_on_guardrail_block(): body = data["proxy_server_request"]["body"] assert body["messages"] == "[REDACTED - BLOCKED BY GUARDRAIL]" assert body["prompt"] == "[REDACTED - BLOCKED BY GUARDRAIL]" + assert body["instructions"] == "[REDACTED - BLOCKED BY GUARDRAIL]" + assert body["system"] == "[REDACTED - BLOCKED BY GUARDRAIL]" assert "supersecret" not in json.dumps(body)