From babcc782983b548751033851a379cbf7bc49ae56 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 5 Feb 2026 15:08:24 -0800 Subject: [PATCH] feat(a2a/): add guardrails for agent interactions allows the same guardrails for llm's to be applied to agents as well --- litellm/proxy/common_request_processing.py | 18 ------------------ .../custom_code/custom_code_guardrail.py | 1 + .../unified_guardrail/unified_guardrail.py | 1 + 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index f33b2412260..480c6855343 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -520,7 +520,6 @@ class ProxyBaseLLMRequestProcessing: "adelete_interaction", "acancel_interaction", "asend_message", - "call_mcp_tool", ], version: Optional[str] = None, user_model: Optional[str] = None, @@ -620,23 +619,6 @@ class ProxyBaseLLMRequestProcessing: user_api_key_dict=user_api_key_dict, data=self.data, call_type=route_type # type: ignore ) - # Apply hierarchical router_settings (Key > Team) - # Global router_settings are already on the Router object itself. - if llm_router is not None and proxy_config is not None: - from litellm.proxy.proxy_server import prisma_client - - router_settings = await proxy_config._get_hierarchical_router_settings( - user_api_key_dict=user_api_key_dict, - prisma_client=prisma_client, - proxy_logging_obj=proxy_logging_obj, - ) - - # If router_settings found (from key or team), apply them - # Pass settings as per-request overrides instead of creating a new Router - # This avoids expensive Router instantiation on each request - if router_settings is not None: - self.data["router_settings_override"] = router_settings - if "messages" in self.data and self.data["messages"]: logging_obj.update_messages(self.data["messages"]) diff --git a/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py b/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py index 924d2f2585d..c4698b1242d 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py +++ b/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py @@ -210,6 +210,7 @@ class CustomCodeGuardrail(CustomGuardrail): HTTPException: If content is blocked CustomCodeExecutionError: If execution fails """ + if self._compiled_function is None: if self._compile_error: raise CustomCodeExecutionError( diff --git a/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py b/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py index cc05358baf7..13bdd6fe58d 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py +++ b/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py @@ -87,6 +87,7 @@ class UnifiedLLMGuardrails(CustomLogger): if CallTypes(call_type) not in endpoint_guardrail_translation_mappings: return data except ValueError: + return data # handle unmapped call types endpoint_translation = endpoint_guardrail_translation_mappings[