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 22e3f635b50..1cf1c839e83 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 52ea78abf5e..ff1fe8653f0 100644 --- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx @@ -175,13 +175,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 }); } }