Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: add explicit admin bypass to agent access checks for consistency

Yuneng Jiangbcb2ea63f139
diff --git a/litellm/proxy/agent_endpoints/a2a_routing.py b/litellm/proxy/agent_endpoints/a2a_routing.py
index d5f5348731f..a9b75de9807 100644
--- a/litellm/proxy/agent_endpoints/a2a_routing.py
+++ b/litellm/proxy/agent_endpoints/a2a_routing.py
@@ -11,7 +11,7 @@ import litellm
from fastapi import HTTPException
from litellm._logging import verbose_proxy_logger
-from litellm.proxy._types import UserAPIKeyAuth
+from litellm.proxy._types import LitellmUserRoles, UserAPIKeyAuth
async def route_a2a_agent_request(
@@ -50,16 +50,21 @@ async def route_a2a_agent_request(
route_name = ROUTE_ENDPOINT_MAPPING.get(route_type, route_type)
raise ProxyModelNotFoundError(route=route_name, model_name=model_name)
- # Verify the caller is permitted to use this agent
- is_allowed = await AgentRequestHandler.is_agent_allowed(
- agent_id=agent.agent_id,
- user_api_key_auth=user_api_key_dict,
+ # Verify the caller is permitted to use this agent (admins bypass the check)
+ is_admin = user_api_key_dict is not None and (
+ user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN
+ or user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value
)
- if not is_allowed:
- raise HTTPException(
- status_code=403,
- detail=f"Agent '{agent_name}' is not allowed for your key/team. Contact proxy admin for access.",
+ if not is_admin:
+ is_allowed = await AgentRequestHandler.is_agent_allowed(
+ agent_id=agent.agent_id,
+ user_api_key_auth=user_api_key_dict,
)
+ if not is_allowed:
+ raise HTTPException(
+ status_code=403,
+ detail=f"Agent '{agent_name}' is not allowed for your key/team. Contact proxy admin for access.",
+ )
# Get API base URL from agent config
if not agent.agent_card_params or "url" not in agent.agent_card_params:
diff --git a/litellm/proxy/agent_endpoints/endpoints.py b/litellm/proxy/agent_endpoints/endpoints.py
index 4c5fbaa22c5..c351d3cfecb 100644
--- a/litellm/proxy/agent_endpoints/endpoints.py
+++ b/litellm/proxy/agent_endpoints/endpoints.py
@@ -392,18 +392,23 @@ async def get_agent_by_id(
"""
await check_feature_access_for_user(user_api_key_dict, "agents")
- from litellm.proxy.agent_endpoints.auth.agent_permission_handler import (
- AgentRequestHandler,
+ is_admin = (
+ user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN
+ or user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value
)
+ if not is_admin:
+ from litellm.proxy.agent_endpoints.auth.agent_permission_handler import (
+ AgentRequestHandler,
+ )
- is_allowed = await AgentRequestHandler.is_agent_allowed(
- agent_id=agent_id, user_api_key_auth=user_api_key_dict
- )
- if not is_allowed:
- raise HTTPException(
- status_code=403,
- detail=f"Agent '{agent_id}' is not allowed for your key/team. Contact proxy admin for access.",
+ is_allowed = await AgentRequestHandler.is_agent_allowed(
+ agent_id=agent_id, user_api_key_auth=user_api_key_dict
)
+ if not is_allowed:
+ raise HTTPException(
+ status_code=403,
+ detail=f"Agent '{agent_id}' is not allowed for your key/team. Contact proxy admin for access.",
+ )
from litellm.proxy.proxy_server import prisma_client