litellm - ✅(Solved) Fix [Bug]: Session trace sidebar in Log Details drawer silently truncates to first 50 entries [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#28224Fetched 2026-05-20 03:40:52
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

Root Cause

Root cause is on the UI side, not the backend:

Fix Action

Fixed

PR fix notes

PR #28225: fix(ui/log-drawer): paginate session trace list to surface logs beyond the first 50

Description (problem / solution / changelog)

Relevant issues

Fixes #28224

Pre-Submission checklist

  • I have Added testing in the tests/test_litellm/ directory — see note below; tests live next to the changed files in ui/litellm-dashboard/... per existing convention.
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • My PR passes all unit tests on make test-unit — UI-only PR; ran npx vitest run src/components/view_logs/LogDetailsDrawer/109 specs pass (Python make test-unit is not applicable to a frontend-only change).
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 — Greptile gave 5/5 (see review comment dated 2026-05-19T07:10Z); both initially flagged P1/P2 issues addressed in follow-up commits.

Note on test placement: tests/test_litellm/ is for the Python SDK / proxy. The LiteLLM dashboard already follows the convention of co-locating *.test.tsx next to source files (e.g. view_logs/time_cell.test.tsx, view_logs/columns neighbors, the existing tests inside LogDetailsDrawer/). I added a vitest spec under the same path to match.

Type

🐛 Bug Fix

Changes

When the Log Details drawer opens in session mode, the left "Session" sidebar fetches /spend/logs/session/ui to enumerate every spend log for that session. The frontend ignored the endpoint's pagination params, so on sessions with more than 50 entries the sidebar silently truncated to the earliest 50 (ordered by startTime ASC) — see #28224 for the reproduction.

This PR threads the existing backend pagination (page, page_size, total_pages) through the UI:

  • ui/litellm-dashboard/src/components/networking.tsxsessionSpendLogsCall now takes page / page_size and forwards them in the query string. Defaults preserve the previous behavior.
  • view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx — adds sessionPage state, includes it in the React Query key so the page is keyed independently, and reads total_pages from the response. goToPreviousPage / goToNextPage clear the selected request id so the existing effect picks the first row of the new page. Page state resets to 1 on drawer close.
  • view_logs/LogDetailsDrawer/DrawerHeader.tsxNavigationSection grows two new buttons (DoubleLeftOutlined / DoubleRightOutlined) that mirror the K/J style, only render in session mode, and disable at page boundaries.
  • view_logs/LogDetailsDrawer/useKeyboardNavigation.ts — routes Shift+J / Shift+K to onNextPage / onPreviousPage. Plain J/K still walks rows within the current page; the hook now checks e.shiftKey so the two paths stay mutually exclusive (with shift held, e.key is already "J"/"K", which would otherwise conflate them).

Tests

view_logs/LogDetailsDrawer/useKeyboardNavigation.test.ts (new) covers:

  • J / K walk the current page within bounds and no-op at head/tail
  • Shift+J / Shift+K invoke the page handlers and never fall through to row-walk
  • Shift+J without an onNextPage handler is a safe no-op (doesn't silently walk forward)
  • Escape and isOpen=false honor existing semantics
$ npx vitest run src/components/view_logs/LogDetailsDrawer/
PASS (109) FAIL (0)

Manual verification

  • Session with 137 spend logs (3 pages):
    • Drawer opens on page 1 with the earliest 50 events; both ⇧K button and Shift+K disabled.
    • ⇧J / Shift+J → page 2, sidebar refreshes, currentLog jumps to the new page's first row, both prev and next page controls are enabled.
    • ⇧J again → page 3, ⇧J button disabled.
    • J / K continue to walk only within the visible page (50 rows).
  • Non-session mode (clicking a row without session_id): the page-control buttons are not rendered, and Shift+J / Shift+K are no-ops; existing behavior unchanged.

What this does NOT do

  • Does not change the backend default page_size=50 or upper bound 100. If a maintainer would prefer auto-fetching all pages over surfacing pagination controls, happy to re-spin.
  • Does not add cumulative / infinite-scroll behavior — each page independently replaces the sidebar. Mirrors how the outer logs table already paginates.

Screenshots / Proof of Fix

(UI-only change; will attach screenshots in a follow-up comment after the PR opens.)

Changed files

  • ui/litellm-dashboard/src/components/networking.tsx (modified, +9/-3)
  • ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/DrawerHeader.tsx (modified, +63/-2)
  • ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx (modified, +67/-8)
  • ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/useKeyboardNavigation.test.ts (added, +217/-0)
  • ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/useKeyboardNavigation.ts (modified, +24/-16)

Code Example

# DevToolsNetwork/spend/logs/session/ui?session_id=<id>
# Request URL has no page/page_size params.
# Response (truncated):
{
  "data": [ ... 50 items ordered by startTime ASC ... ],
  "total": 137,
  "page": 1,
  "page_size": 50,
  "total_pages": 3
}
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When opening the Log Details drawer in session mode (clicking a row that has a session_id), the left sidebar lists every spend log belonging to that session. For sessions with more than 50 entries, only the earliest 50 are shown — the rest are silently dropped, with no UI indication that more exist and no way to reach them.

Root cause is on the UI side, not the backend:

  • The backend endpoint GET /spend/logs/session/ui already supports pagination (page, page_size, returns total, total_pages). Default page_size=50, max 100, ordered by startTime ASC.
  • The frontend helper sessionSpendLogsCall in ui/litellm-dashboard/src/components/networking.tsx calls the endpoint without any pagination params, so it always receives page 1 (= the earliest 50 logs by startTime).
  • LogDetailsDrawer consumes response.data as-is and never reads total_pages, so users on a large session see "the first 50 events" with no warning and no controls.

Expected behavior: the UI should expose all session events — either by fetching all pages, or by surfacing pagination controls in the trace sidebar.

Steps to Reproduce

  1. Run a litellm proxy with store_prompts_in_spend_logs enabled (or any setup where spend logs are written to DB).
  2. Generate a session whose session_id accumulates more than 50 spend log rows (e.g. an agent loop with many tool/MCP calls, or a long multi-turn chat).
  3. Open the LiteLLM UI → Logs tab.
  4. Click any row belonging to that session — the Log Details drawer opens with the left "Session" sidebar.
  5. Observe: the sidebar shows exactly 50 entries with the earliest startTime. There is no pagination control, no "+N more" indicator, and J/K navigation cannot reach later events.
  6. Confirm via DevTools → Network that the request to /spend/logs/session/ui?session_id=... is sent without page / page_size, the response contains total > 50 and total_pages > 1, but the UI ignores those fields.

Relevant log output

# DevTools → Network → /spend/logs/session/ui?session_id=<id>
# Request URL has no page/page_size params.
# Response (truncated):
{
  "data": [ ... 50 items ordered by startTime ASC ... ],
  "total": 137,
  "page": 1,
  "page_size": 50,
  "total_pages": 3
}

What part of LiteLLM is this about?

UI Dashboard

What LiteLLM version are you on?

v1.86.0

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING