fix(proxy): also redact instructions and system fields on guardrail failure

This commit is contained in:
Harshit Kulkarni 2026-11-05 20:33:38 +05:30
parent da3176cceb
commit baa488a10a
2 changed files with 5 additions and 1 deletions

View file

@ -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]"

View file

@ -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)