Skip to content

revert: "perf(proxy): split aggregated usage query into key-free rollups and bounded top-N keys (#41293)" - #43596

Merged
yuneng-berri merged 1 commit into
litellm_revert_41324from
litellm_revert_41293
Sep 28, 2026
Merged

yuneng-berri merged 1 commit into
litellm_revert_41324from
litellm_revert_41293

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Reverts #41293

TLDR

Problem this solves:

How it solves it:

  • git revert -m 1 2e46b10320, conflicts resolved by hand against today's main
  • Drops USAGE_TOP_API_KEYS_LIMIT, the key-free aggregate split and the top-N key query
  • Removes api_key_limit / total_api_keys from the response and the dashboard truncation notice
  • Keeps the newer Cache Leakage date picker and other later UI work intact

Intentional product change: the Usage page loads every key again instead of the 100 highest-spend keys, so the "Only the 100 highest-spend keys of N are loaded" notice and the export block tied to it are gone

User Flow

Before: an admin with 105 keys in one team only sees 100 of them on the Usage page

  1. They open http://localhost:4000/ui/?page=usage and click the Key Activity tab
  2. The page shows "Showing 100 of 100 keys" and "Only the 100 highest-spend keys of 105 are loaded"
  3. GET http://localhost:4000/team/daily/activity/aggregated returns api_key_limit: 100, total_api_keys: 105 and 100 keys

Before: Key Activity capped at 100 of 105 keys

After: the same admin sees all 105 keys and no truncation notice

  1. They open http://localhost:4000/ui/?page=usage and click the Key Activity tab
  2. The page shows "Showing 105 of 105 keys" with no truncation notice
  3. The same GET returns all 105 keys and no api_key_limit or total_api_keys fields

After: Key Activity shows all 105 keys

Pre-Submission checklist

  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<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's scope is as isolated as possible; it only solves 1 specific problem

Screenshots / Proof of Fix

Postgres, one proxy on localhost:4000 with a single openai/gpt-5.4-mini deployment, one team qa-topn-team with 105 virtual keys owned by qa-topn-user, each key sending one real POST /v1/chat/completions to OpenAI

for k in $(cat keys.txt); do
  curl -s localhost:4000/v1/chat/completions -H "Authorization: Bearer $k" -H "Content-Type: application/json" \
    -d '{"model":"gpt-5.4-mini","messages":[{"role":"user","content":"say hi"}]}' -o /dev/null -w "%{http_code}\n"
done | sort | uniq -c

The QA below ran at ceede67 and 52c2990. The current head 17c22bc carries the same patch (identical git patch-id), re-squashed on newer main

Before (ceede67)

User aggregated activity

  1. curl -s "localhost:4000/user/daily/activity/aggregated?start_date=2026-09-28&end_date=2026-09-28&user_id=qa-topn-user" -H "Authorization: Bearer $MASTER_KEY"
  2. Metadata has api_key_limit: 100 and total_api_keys: 105, total_api_requests: 212, and breakdown.api_keys has 100 entries

Team aggregated activity

  1. curl -s "localhost:4000/team/daily/activity/aggregated?start_date=2026-09-28&end_date=2026-09-28&team_ids=qa-topn-team" -H "Authorization: Bearer $MASTER_KEY"
  2. Metadata has api_key_limit: 100 and total_api_keys: 105, total_api_requests: 212, and breakdown.api_keys has 100 entries

Usage page

  1. Open http://localhost:4000/ui/?page=usage, log in as admin, click Key Activity
  2. The page shows the capped view in the Before screenshot under User Flow, captured on the same data before the stack was rebuilt on current main, with the same UI since the feat(proxy): add LiteLLM_DailyGlobalSpend key-free rollup for the usage dashboard #41324 revert does not touch the dashboard

After (52c2990)

User aggregated activity

  1. The same user curl, after one more real chat request
  2. Metadata has no api_key_limit or total_api_keys, total_api_requests: 213, and breakdown.api_keys has 105 entries

Team aggregated activity

  1. The same team curl
  2. Metadata has no api_key_limit or total_api_keys, total_api_requests: 213, and breakdown.api_keys has 105 entries

Usage page

  1. Open http://localhost:4000/ui/?page=usage, log in as admin, click Key Activity
  2. The page shows all 105 keys with no notice, as in the After screenshot under User Flow

Type

Refactoring

Caveats (if any)

Medium

  • Large tenants load every key again, so the aggregated query gets slower as key count grows

Low

Link to Devin session: https://app.devin.ai/sessions/7097c700d7fc4601961a6013b1adcec7
Open in Devin Desktop: https://app.devin.ai/desktop/session/7097c700d7fc4601961a6013b1adcec7?variant=devin
Requested by: @yassin-berriai

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • 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.

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Reverts a performance optimization for usage query aggregation.

The PR appears safe to merge based on the reviewed changes.

Summary

This revert removes the top-100 key cap from aggregated daily activity, returns every matching key, and removes the associated response metadata and dashboard truncation controls. PostgreSQL-backed tests now cover the uncapped query.

Reviews (2) · Last reviewed commit: "Revert "Merge pull request #41293 from B..."

Comment thread litellm/proxy/management_endpoints/common_daily_activity.py
Comment thread tests/test_litellm/proxy/management_endpoints/test_common_daily_activity.py Outdated
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

@greptileai review

@yuneng-berri
yuneng-berri merged commit 84e234c into litellm_revert_41324 Sep 28, 2026
94 of 96 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_revert_41293 branch September 28, 2026 21:39
yuneng-berri pushed a commit that referenced this pull request Sep 28, 2026
…r the usage dashboard (#41324)" (#43595)

* Revert "Merge pull request #41324 from BerriAI/litellm_daily_global_spend_table"

* Revert "Merge pull request #41293 from BerriAI/litellm_usage_key_free_aggregate_split" (#43596)

Co-authored-by: yassin <yassin@berri.ai>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
yuneng-berri pushed a commit that referenced this pull request Sep 28, 2026
…)" (#43378)

* Revert "feat(usage): search keys beyond the top-N usage subset (#42827)"

* revert: "feat(proxy): add LiteLLM_DailyGlobalSpend key-free rollup for the usage dashboard (#41324)" (#43595)

* Revert "Merge pull request #41324 from BerriAI/litellm_daily_global_spend_table"

* Revert "Merge pull request #41293 from BerriAI/litellm_usage_key_free_aggregate_split" (#43596)

Co-authored-by: yassin <yassin@berri.ai>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
yuneng-berri pushed a commit that referenced this pull request Sep 28, 2026
…sage view (#42857)" (#43377)

* Revert "feat(usage): search team keys beyond the top-N in the Team usage view (#42857)"

* revert: "feat(usage): search keys beyond the top-N usage subset (#42827)" (#43378)

* Revert "feat(usage): search keys beyond the top-N usage subset (#42827)"

* revert: "feat(proxy): add LiteLLM_DailyGlobalSpend key-free rollup for the usage dashboard (#41324)" (#43595)

* Revert "Merge pull request #41324 from BerriAI/litellm_daily_global_spend_table"

* Revert "Merge pull request #41293 from BerriAI/litellm_usage_key_free_aggregate_split" (#43596)

Co-authored-by: yassin <yassin@berri.ai>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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