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: push org filter into DB query for /team/list, fix agents.tsx build

yuneng-jiang063198cf8e65
diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py
index 86b988f581d..633de86aa6e 100644
--- a/litellm/proxy/management_endpoints/team_endpoints.py
+++ b/litellm/proxy/management_endpoints/team_endpoints.py
@@ -3434,28 +3434,33 @@ async def _authorize_and_filter_teams(
},
)
- response = await prisma_client.db.litellm_teamtable.find_many(
- include={"litellm_model_table": True}
- )
-
if allowed_org_ids is not None:
- allowed_org_set = set(allowed_org_ids)
- seen_team_ids: set = set()
- filtered: list = []
- for team in response:
- if team.organization_id in allowed_org_set:
- filtered.append(team)
- seen_team_ids.add(team.team_id)
- # Also include teams the user is a direct member of
- if user_id:
- for team in response:
- if team.team_id not in seen_team_ids and team.members_with_roles:
- for member in team.members_with_roles:
- if member.get("user_id") == user_id:
- filtered.append(team)
- seen_team_ids.add(team.team_id)
- return filtered
+ # Org admin: query DB for teams in their orgs
+ org_teams = await prisma_client.db.litellm_teamtable.find_many(
+ where={"organization_id": {"in": allowed_org_ids}},
+ include={"litellm_model_table": True},
+ )
+ if not user_id:
+ return list(org_teams)
+ # Also include teams the user is a direct member of (outside their orgs)
+ seen_team_ids = {team.team_id for team in org_teams}
+ all_teams = list(org_teams)
+ # Prisma doesn't support filtering JSON array fields, so we fetch by membership separately
+ member_teams = await prisma_client.db.litellm_teamtable.find_many(
+ where={"team_id": {"not_in": list(seen_team_ids)}} if seen_team_ids else {},
+ include={"litellm_model_table": True},
+ )
+ for team in member_teams:
+ if team.members_with_roles and any(
+ m.get("user_id") == user_id for m in team.members_with_roles
+ ):
+ all_teams.append(team)
+ return all_teams
elif user_id:
+ # Regular user: fetch all and filter by membership (Prisma can't filter JSON arrays)
+ response = await prisma_client.db.litellm_teamtable.find_many(
+ include={"litellm_model_table": True}
+ )
return [
team
for team in response
@@ -3463,7 +3468,12 @@ async def _authorize_and_filter_teams(
and any(m.get("user_id") == user_id for m in team.members_with_roles)
]
else:
- return list(response)
+ # Proxy admin: all teams
+ return list(
+ await prisma_client.db.litellm_teamtable.find_many(
+ include={"litellm_model_table": True}
+ )
+ )
@router.get(
diff --git a/ui/litellm-dashboard/src/components/agents.tsx b/ui/litellm-dashboard/src/components/agents.tsx
index b60af254133..169017ec86b 100644
--- a/ui/litellm-dashboard/src/components/agents.tsx
+++ b/ui/litellm-dashboard/src/components/agents.tsx
@@ -11,7 +11,7 @@ import {
Badge,
Text,
} from "@tremor/react";
-import { Modal, Alert, Tooltip, Skeleton } from "antd";
+import { Modal, Alert, Tooltip, Skeleton, Switch } from "antd";
import { CheckCircleOutlined } from "@ant-design/icons";
import { getAgentsList, deleteAgentCall, keyListCall } from "./networking";
import AddAgentForm from "./agents/add_agent_form";