feat(a2a/): add guardrails for agent interactions

allows the same guardrails for llm's to be applied to agents as well
This commit is contained in:
Krrish Dholakia 2026-02-05 15:08:24 -08:00 • committed by Shin
parent 0ef51255dd
commit babcc78298
3 changed files with 2 additions and 18 deletions

View file

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

View file

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

View file

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