From 598729c5f4d22c13b973ba181d3cfe6a8dbbe113 Mon Sep 17 00:00:00 2001 From: Dmitry Rubtsov Date: Thu, 27 Aug 2026 22:33:23 +0600 Subject: [PATCH] fix(ui): prefer caller-sent requests over internal classifier calls Extend session representative selection to rank internal sub-calls (e.g. auto-router classifier calls, marked via metadata.internal_call_origin) lowest, so caller-sent calls are preferred over both MCP and internal sub-calls when collapsing multi-call sessions into a single row. --- .../view_logs/RequestLogsPanel.test.tsx | 19 +++++++++++++++++++ .../components/view_logs/RequestLogsPanel.tsx | 13 +++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx index b68e12b9c3d..20473e4789a 100644 --- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx @@ -171,6 +171,25 @@ describe("RequestLogsPanel", () => { expect(within(row("req-llm") as HTMLElement).getByText("3")).toBeInTheDocument(); }); + it("prefers a caller-sent call over an auto-router classifier sub-call as the representative", async () => { + const classifierSubCall: Partial = { + request_id: "req-classify", + session_id: "sess-1", + session_total_count: 2, + metadata: { internal_call_origin: "autorouter_classifier" }, + }; + const callerSentCall: Partial = { + request_id: "req-main", + session_id: "sess-1", + session_total_count: 2, + }; + respondWith([logEntry(classifierSubCall), logEntry(callerSentCall)]); + renderPanel(); + + await waitFor(() => expect(row("req-main")).not.toBeNull()); + expect(row("req-classify")).toBeNull(); + }); + it("leaves single-call rows untouched", async () => { respondWith([ logEntry({ request_id: "req-solo-a", session_id: "sess-a", session_total_count: 1 }), diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx index b6f61cb3c6b..9f5ea1f5633 100644 --- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx @@ -166,13 +166,18 @@ export default function RequestLogsPanel({ accessToken, token, userRole, userID, return acc; }, {}); - const sessionRepresentativeMap = new Map(); + // Lower rank wins: caller-sent non-MCP call, then MCP call, then internal + // sub-calls (metadata.internal_call_origin, e.g. auto-router classifier). + const representativeRank = (log: LogEntry): number => + (log.metadata?.internal_call_origin ? 2 : 0) + (MCP_CALL_TYPES.includes(log.call_type) ? 1 : 0); + + const sessionRepresentativeMap = new Map(); for (const log of searchedLogs) { if (!log.session_id || (log.session_total_count || 1) <= 1) continue; - const isMcp = MCP_CALL_TYPES.includes(log.call_type); + const rank = representativeRank(log); const existing = sessionRepresentativeMap.get(log.session_id); - if (!existing || (existing.isMcp && !isMcp)) { - sessionRepresentativeMap.set(log.session_id, { requestId: log.request_id, isMcp }); + if (!existing || rank < existing.rank) { + sessionRepresentativeMap.set(log.session_id, { requestId: log.request_id, rank }); } }