From af8ff6cdd50a035e9c664a21b33ae8b1c0dd2e95 Mon Sep 17 00:00:00 2001 From: rzeta-10 Date: Sat, 4 Apr 2026 19:00:43 +0530 Subject: [PATCH] remove the unused code --- .../guardrails/guardrail_hooks/akto/akto.py | 43 ++++--------------- .../guardrails_tests/test_akto_guardrails.py | 11 +++-- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/akto/akto.py b/litellm/proxy/guardrails/guardrail_hooks/akto/akto.py index 8f8aa57fc3f..cf2ad17a522 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/akto/akto.py +++ b/litellm/proxy/guardrails/guardrail_hooks/akto/akto.py @@ -162,25 +162,6 @@ class AktoGuardrail(CustomGuardrail): return body - @staticmethod - def build_response_body( - inputs: GenericGuardrailAPIInputs, - request_data: Optional[dict] = None, - ) -> Dict[str, Any]: - """Build the LLM response body, preferring the actual model response if available.""" - model_response = request_data.get("response") if request_data else None - if model_response is not None and hasattr(model_response, "model_dump"): - return model_response.model_dump() - - texts = inputs.get("texts", []) - if texts: - return { - "choices": [ - {"message": {"content": t, "role": "assistant"}} for t in texts - ] - } - return {} - @staticmethod def build_tag_metadata(request_data: dict) -> Dict[str, str]: """Build tag/metadata dict with user_id and team_id for Akto tracking.""" @@ -201,23 +182,17 @@ class AktoGuardrail(CustomGuardrail): self, inputs: GenericGuardrailAPIInputs, request_data: dict, - *, - status_code: int = 200, - include_response: bool = False, ) -> Dict[str, Any]: - """Build the MIRRORING payload for Akto's HTTP proxy endpoint.""" + """Build the MIRRORING payload for Akto's guardrail validation endpoint. + + Response headers and payload are empty — the guardrail only sends + the request for validation, not the response. + """ request_path = self.extract_request_path(request_data) request_headers = self.build_request_headers(request_data) request_body = self.build_request_body(inputs, request_data) tag = self.build_tag_metadata(request_data) - response_payload = json.dumps({}) - response_headers: Dict[str, str] = {} - if include_response: - response_body = self.build_response_body(inputs, request_data) - response_payload = json.dumps(response_body) - response_headers = {"content-type": "application/json"} - # Extract client IP from proxy headers ip = "" proxy_req = request_data.get("proxy_server_request", {}) @@ -236,16 +211,16 @@ class AktoGuardrail(CustomGuardrail): return { "path": request_path, "requestHeaders": json.dumps(request_headers), - "responseHeaders": json.dumps(response_headers), + "responseHeaders": json.dumps({}), "method": "POST", "requestPayload": json.dumps(request_body), - "responsePayload": response_payload, + "responsePayload": json.dumps({}), "ip": ip, "destIp": "127.0.0.1", "time": str(int(datetime.now().timestamp() * 1000)), - "statusCode": str(status_code), + "statusCode": "200", "type": "HTTP/1.1", - "status": str(status_code), + "status": "200", "akto_account_id": self.akto_account_id, "akto_vxlan_id": self.akto_vxlan_id, "is_pending": "false", diff --git a/tests/guardrails_tests/test_akto_guardrails.py b/tests/guardrails_tests/test_akto_guardrails.py index 9ebd9dce565..d031e9cfe2e 100644 --- a/tests/guardrails_tests/test_akto_guardrails.py +++ b/tests/guardrails_tests/test_akto_guardrails.py @@ -181,14 +181,13 @@ def test_build_akto_payload(akto_validate, sample_inputs, sample_request_data): assert len(payload["time"]) >= 13 -def test_build_akto_payload_with_response( +def test_build_akto_payload_response_always_empty( akto_validate, sample_inputs, sample_request_data ): - payload = akto_validate.build_akto_payload( - sample_inputs, sample_request_data, include_response=True - ) - resp_body = json.loads(payload["responsePayload"]) - assert "choices" in resp_body + payload = akto_validate.build_akto_payload(sample_inputs, sample_request_data) + assert payload["responsePayload"] == json.dumps({}) + assert payload["responseHeaders"] == json.dumps({}) + assert payload["statusCode"] == "200" def test_build_akto_payload_custom_ids(sample_request_data):