Skip to content

feat(ui): add cache hit/miss filter to Request Logs - #38432

Merged
yassin-berriai merged 4 commits into
litellm_internal_stagingfrom
litellm_lit6260_cache_filter_request_logs
Aug 27, 2026
Merged

yassin-berriai merged 4 commits into
litellm_internal_stagingfrom
litellm_lit6260_cache_filter_request_logs

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Request Logs shows cache state per row but cannot filter by it
  • Admins evaluating caching had to query the API and filter externally

How it solves it:

  • New cache_hit_filter query param (hit or miss) on /spend/logs/ui, applied in SQL
  • Counts and pagination use the same predicate, so totals match the selection
  • New Cache dropdown (All Requests, Cache Hit, Cache Miss) in the Request Logs filters
  • Legacy rows with a null or unknown cache value count as misses

User Flow

Before: an admin evaluating response caching cannot isolate cache hits in the dashboard

  1. They open http://localhost:4000/ui/?page=logs and see a Cache Hit column on each row
  2. They open the Filters panel and find Team, Status, Model and others, but nothing for cache state
  3. To count hits they call GET http://localhost:4000/spend/logs/ui and filter the JSON themselves

After: the same admin filters hits and misses directly in the dashboard

  1. They open http://localhost:4000/ui/?page=logs and open the Filters panel
  2. A new Cache dropdown offers All Requests, Cache Hit and Cache Miss
  3. Picking Cache Hit reloads the table with only cache hits, and the row count and pagination match
  4. Picking Cache Miss shows everything else, including older rows that never recorded a cache state

Relevant issues

Linear ticket

Resolves LIT-6260

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Shared setup: proxy on localhost:4000 with local response caching enabled and Postgres attached, then one real OpenAI call that misses the cache and an identical second call that hits it

BODY='{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Say the word pineapple"}],"temperature":0}'
curl -s http://localhost:4000/chat/completions -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d "$BODY"
curl -s http://localhost:4000/chat/completions -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d "$BODY"

The spend table then held two rows for the same completion id: the first with no cache state recorded, the second _cache_hit row with cache_hit True

Before (ecc4976)

cache_hit_filter=hit is ignored, both rows come back

  1. curl -s -G "http://localhost:4000/spend/logs/ui" -H "Authorization: Bearer sk-1234" --data-urlencode "start_date=2026-08-26 23:46:37" --data-urlencode "end_date=2026-08-27 01:46:37" --data-urlencode "cache_hit_filter=hit"
  2. Observed: total: 2, both the cache-hit row and the miss row are returned

unknown filter value is silently accepted

  1. Same request with cache_hit_filter=invalid
  2. Observed: HTTP 200, no error, unfiltered results

After (d57f2d8)

cache_hit_filter=hit returns only the hit

  1. Same cache_hit_filter=hit request as Before
  2. Observed: total: 1, only the _cache_hit row with cache_hit= True

cache_hit_filter=miss returns only the miss, including the legacy null row

  1. Same request with cache_hit_filter=miss
  2. Observed: total: 1, only the original row with cache_hit= None

no filter still returns everything

  1. Same request with no cache_hit_filter
  2. Observed: total: 2

invalid value is rejected

  1. Same request with cache_hit_filter=invalid
  2. Observed: HTTP 400 with {"error":{"message":"Invalid cache_hit_filter: invalid. Must be one of: hit, miss","type":"bad_request","param":"cache_hit_filter","code":"400"}}

UI check: open http://localhost:4000/ui/?page=logs, open Filters, pick Cache Hit in the new Cache dropdown and the table reloads with only cache hits; pick Cache Miss for the rest; pick All Requests to clear

Type

🆕 New Feature

Caveats (if any)

Low

  • Rows that predate cache tracking have no cache state and are counted as misses

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/6a80c584983d45b09a8a49cfdcdcd47c
Requested by: @yassin-berriai

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

No action taken on #38432 — it has no labels at all, so the required enterprise label is absent. Author and repo checks passed; no GitHub or Linear changes made.

@greptile-apps

greptile-apps Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds cache hit/miss filtering to the Request Logs API and dashboard.

  • Validates and applies cache-state filtering consistently to log rows, totals, and pagination.
  • Adds a Cache dropdown and forwards its selection through the dashboard request layer.
  • Covers hit, miss, legacy/null, clearing, and invalid-value behavior with focused tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
litellm/proxy/spend_tracking/spend_management_endpoints.py Adds allowlisted cache filtering with shared SQL predicates for count and data queries.
tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py Tests hit, miss, legacy/null, unfiltered, and invalid filter behavior.
ui/litellm-dashboard/src/components/view_logs/RequestLogsFilters.tsx Adds the Cache selector using the existing filter drawer state flow.
ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx Maps cache filter state to the backend query parameter.
ui/litellm-dashboard/src/components/networking.tsx Extends request parameters with the cache filter while removing the previously flagged redundant comment.
ui/litellm-dashboard/src/lib/http/schema.d.ts Reflects the new query parameter in the typed API schema.

Reviews (3): Last reviewed commit: "chore(ui): drop redundant cache filter c..." | Re-trigger Greptile

Comment thread ui/litellm-dashboard/src/components/networking.tsx Outdated
@codecov

codecov Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_lit6260_cache_filter_request_logs (7d3f11a) with litellm_internal_staging (8ebcb3e)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (02dcc4d) during the generation of this report, so 8ebcb3e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

@greptileai

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

@greptileai

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Removed in d57f2d8, thanks

@yassin-berriai
yassin-berriai enabled auto-merge (squash) August 27, 2026 17:46
…ment_endpoints.py

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@yassin-berriai
yassin-berriai merged commit a7da792 into litellm_internal_staging Aug 27, 2026
77 checks passed
@yassin-berriai
yassin-berriai deleted the litellm_lit6260_cache_filter_request_logs branch August 27, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants