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]

Merge pull request #36478 from BerriAI/litellm_/vibrant-booth-d4258b

yuneng-jiang80f34cb6fcab
diff --cc ui/litellm-dashboard/src/components/leftnav.test.tsx
index 33a8448da44,f074624dcf2..8eca990261c
--- a/ui/litellm-dashboard/src/components/leftnav.test.tsx
+++ b/ui/litellm-dashboard/src/components/leftnav.test.tsx
@@@ -293,98 -300,8 +300,98 @@@ describe("Sidebar (leftnav)", () =>
});
});
+ // Workflow Runs, Memory and Guardrails Monitor render a shell and then 401
+ // for every non-proxy-admin role, because their page-load routes sit outside
+ // internal_user_routes / self_managed_routes. Cost Optimization does not:
+ // its primary call is /user/daily/activity, which every role may make, so
+ // the entry stays and only its proxy-wide tabs are gated inside the page.
+ describe("capability-gated pages whose data is proxy-admin-only", () => {
+ const authFor = (userRole: string) => ({
+ userId: "some-user-id",
+ accessToken: "test-access-token",
+ userRole,
+ isViewOnly: false,
+ token: "test-token",
+ userEmail: "[email protected]",
+ premiumUser: false,
+ disabledPersonalKeyCreation: false,
+ showSSOBanner: false,
+ });
+
+ afterEach(() => {
+ mockUseAuthorized.mockReset();
+ });
+
+ it("hides Workflow Runs and Memory from an internal user under Agentic", async () => {
+ mockUseAuthorized.mockReturnValue(authFor("internal"));
+ renderWithProviders(<Sidebar {...defaultProps} />);
+
+ act(() => {
+ fireEvent.click(screen.getByText("Agentic"));
+ });
+ // Liveness gate: the sibling Agents child stays visible to this role, so
+ // the absences below mean the gate fired, not that the group never opened.
+ await waitFor(() => {
+ expect(screen.getByText("Agents")).toBeInTheDocument();
+ });
+ expect(screen.queryByText("Workflow Runs")).not.toBeInTheDocument();
+ expect(screen.queryByText("Memory")).not.toBeInTheDocument();
+ });
+
+ // An org admin's session role is "Org Admin", which no capability list
+ // carries, and the proxy denies these routes to org admins too because
+ // `_user_is_org_admin` needs an organization_id the page-load GET never sends.
+ // Agents is already out of reach for this role, so gating the other two
+ // empties the Agentic group entirely and the parent must go with it rather
+ // than degrade into a leaf link to the non-route `?page=agentic`.
+ it("drops the whole Agentic group for an org admin once its last child is gated", () => {
+ mockUseAuthorized.mockReturnValue(authFor("org_admin"));
+ renderWithProviders(<Sidebar {...defaultProps} />);
+
+ // Liveness gate: Logs carries no role list, so it proves the sidebar rendered.
+ expect(screen.getByText("Logs")).toBeInTheDocument();
+ expect(screen.queryByText("Agentic")).not.toBeInTheDocument();
+ expect(screen.queryByText("Workflow Runs")).not.toBeInTheDocument();
+ expect(screen.queryByText("Memory")).not.toBeInTheDocument();
+ });
+
+ it("keeps the Agentic group for an internal user, who can still see Agents", () => {
+ mockUseAuthorized.mockReturnValue(authFor("internal"));
+ renderWithProviders(<Sidebar {...defaultProps} />);
+
+ expect(screen.getByText("Agentic")).toBeInTheDocument();
+ });
+
+ it("shows Workflow Runs and Memory to admins", async () => {
+ renderWithProviders(<Sidebar {...defaultProps} />);
+
+ act(() => {
+ fireEvent.click(screen.getByText("Agentic"));
+ });
+ await waitFor(() => {
+ expect(screen.getByText("Workflow Runs")).toBeInTheDocument();
+ });
+ expect(screen.getByText("Memory")).toBeInTheDocument();
+ });
+
+ it("hides Guardrails Monitor from an internal user while keeping Usage and Cost Optimization", () => {
+ mockUseAuthorized.mockReturnValue(authFor("internal"));
+ renderWithProviders(<Sidebar {...defaultProps} />);
+
+ expect(screen.queryByText("Guardrails Monitor")).not.toBeInTheDocument();
+ expect(screen.getByText("Usage")).toBeInTheDocument();
+ expect(screen.getByText("Cost Optimization")).toBeInTheDocument();
+ });
+
+ it("shows Guardrails Monitor to admins", () => {
+ renderWithProviders(<Sidebar {...defaultProps} />);
+
+ expect(screen.getByText("Guardrails Monitor")).toBeInTheDocument();
+ });
+ });
+
it("should show Organizations tab for organization admins", () => {
- mockUseAuthorized.mockReturnValueOnce({
+ mockUseAuthorized.mockReturnValue({
userId: "org-admin-user-id",
accessToken: "test-access-token",
userRole: "viewer",