Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
bd345ef to
9f5e60b
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning
Comparing |
9f5e60b to
3dc66d7
Compare
|
The enterprise unit tests timeout after 20mins, it was at 99% already. |
3dc66d7 to
1a1254e
Compare
|
bugbot run |
1a1254e to
92a0aad
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 92a0aad. Configure here.
d68d738 to
0eb1c16
Compare
|
|
0eb1c16 to
3ef7bc4
Compare
…cooldown The cooldown callback labelled the deployment state with the router group name and the config api_base, while requests label it with the resolved model name and the request api_base. A cooldown therefore wrote 2 to a second series that nothing ever reset, so it stayed at 2 after the provider recovered and alerts on it kept firing A new DeploymentStateSeriesTracker remembers the series each deployment wrote since its last success. A cooldown marks those series at 2, falling back to the series derived from config when there is no history. Failures logged while the deployment cools down stay at 2, and the next success clears every marked series back to 0. The cooldown callback now labels its state with the resolved model name and provider, and litellm_deployment_cooled_down keeps its labels The tracker holds at most 10000 deployments and 8 series per deployment, and it writes 0 to any marked series it stops tracking so none is left at 2. It takes its lock as an argument so the concurrency test can watch for contention instead of timing it. set_litellm_deployment_state keeps its five argument signature and the gauge states are a DeploymentState enum The tests check the final gauge state per series in the tracker, the logger setters against the real registry, and the cooldown callback against a real Router. The registry isolation and deployment state readers live in the unit conftest Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
3ef7bc4 to
f2d3e72
Compare
|
@mubashir1osmani Can you trigger the ci again |
The deployment state metric on the Prometheus endpoint no longer gets stuck at 2 after a deployment recovers from a cooldown. Before, a cooldown added a second, differently labeled line for the same deployment that nothing ever reset, so alerts on it kept firing after the provider came back. Now a cooldown marks the lines the deployment's own requests already report on, and the next successful request clears them
Details
TLDR
Problem this solves:
litellm_deployment_stateline for the deploymentHow it solves it:
Intentional product change: a cooldown now marks the line requests already write, labeled with the resolved model name (for example
gpt-5.4-mini) instead of the model group name (for exampleprod-chat), so one deployment has one line. Users lose the group-name label on state 2, so alerts that matched it should matchmodel_idor the resolved nameUser Flow
Before: an operator who alerts on the deployment state metric keeps getting paged after the provider has recovered
prod-chatand get a 200litellm_deployment_stateline forgpt-5.4-miniat 0prod-chatappears at 2After: the same operator sees the metric follow the deployment, so the alert clears when the provider recovers
prod-chatand get a 200litellm_deployment_stateline forgpt-5.4-miniat 0Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 moreDelays 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
No provider key was available in this session, so the upstream is a local OpenAI-compatible stand-in that answers 200 or 401 on demand. Everything else is the real proxy hit with curl, started from a checkout of each hash below
Setup (config, upstream, helpers)
config.yamlstub_upstream.pyStart the upstream and the proxy, then define two helpers
Before (f2118fc)
A request while the upstream is healthy
Read the metric
The provider starts rejecting the key, then the same request
Read the metric again, a second line at 2 appeared
A request during the 5 second cooldown
The provider recovers, the cooldown runs out, and the request goes through
Read the metric, the second line is still stuck at 2
After (bd345ef)
A request while the upstream is healthy
Read the metric
The provider starts rejecting the key, then the same request
Read the metric again, the one line moved to 2 and no second line appeared
A request during the 5 second cooldown
The provider recovers, the cooldown runs out, and the request goes through
Read the metric, the same line is back at 0
Mutation check
Forty-four hand-made changes to the tracker, the cooldown callback and the gauge wiring were each applied on their own, and the tests went red for every one. Forty-three were caught by the first set of tests and the last (lifting the series cap from a cooling deployment) needed one more test, which is in this PR. For example, making the next success skip the extra lines a cooldown marked, which brings the original bug back, fails
test_a_success_under_a_new_label_clears_every_series_a_full_cooldown_marked, and it passes again with the change revertedType
🐛 Bug Fix
✅ Test
Caveats (if any)
Severe
model_idor the resolved name insteadMedium
Low
api_basecomes from config and may differ from the request onelitellm_deployment_cooled_downlabels are unchanged on purposeFinal Attestation
Note
Medium Risk
Changes Prometheus deployment health semantics and label values (group vs resolved model on cooldown), which can break existing alerts; logic is observability-only but non-trivial and per-process in multiprocess mode.
Overview
Fixes
litellm_deployment_statestaying at 2 after a deployment recovers from router cooldown, which left a second metric line (often labeled with the model group name) that success never reset.DeploymentStateSeriesTrackeris added and wired intoPrometheusLogger: healthy/partial/complete setters now route through it instead of writing the gauge once per call. On cooldown it marks the label series the request path already wrote (and related history), keeps failures during cooldown at 2 until the next success, then clears those series to 0. LRU caps limit tracked deployments and series per deployment; evicted cooling deployments are reset to healthy.The router cooldown callback resolves model/provider via
resolved_model_and_providerand uses the resolved model name for deployment state (not the group name);litellm_deployment_cooled_downstill uses the group name. Unit/integration tests and Prometheus registry fixtures cover the state transitions and end-to-end router flow.Reviewed by Cursor Bugbot for commit 92a0aad. Bugbot is set up for automated code reviews on this repo. Configure here.