litellm/tests/unit/test_router/core
Kerry Lu e2625d0509
fix(router): re-check and reserve per-model rate limits on fallback targets (#50994)
* fix(router): re-check and reserve per-model rate limits on fallback targets

A provider error fallback handed the caller the fallback model group without
its per-model TPM/RPM limits ever being checked. The router gets a
fallback_rate_limit_check hook next to fallback_budget_check, the proxy wires
it to the v3 limiter, which reserves the target model's per-model descriptors
before each fallback hop and skips targets that are over their limit.

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

* fix(router): dedupe a repeated fallback target before the reserving rate limit check

Both walks now consult the attempted set before the rate limit check, so a
chain like ["B", "B"] reserves B once. The deprecated settings parity test
also learns the new setting.

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

* test(router): a bidirectional fallback chain never re-reserves the requested model group

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

* test(router): match the surfaced failure in the fallback reservation tests

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

* fix(rate-limit): keep the admission stash untouched while building fallback descriptors

Building the fallback target's descriptors could rewrite the request stash's
PTU ceiling, which post-call settlement reads for the model the caller named.
The fallback check now hides the stash while it builds, like the frame check.

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

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-10 16:36:10 -08:00
..
__init__.py refactor(router): extract PythonCore behind RouterCore and pass the router its config (#49119) 2026-10-31 12:54:23 -07:00
conftest.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
construction_precall_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
endpoints_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
fallbacks_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
gaps_l11100_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
registry_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
retries_health_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
rust_parity_pending.txt feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
scripted_host.py fix(router): count embedding batches per input in pre-call checks (#49851) 2026-11-06 11:32:08 -08:00
selection_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
streaming_helpers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_callback_filters_step.py perf(router): skip unused deployment reads in the callback filter step and cache anthropic capability probes (#50641) 2026-11-08 17:59:55 -08:00
test_construction_precall_characterization.py fix(router): give the rust core's priority scheduler the router's redis cache (#50265) 2026-11-06 08:50:42 +09:00
test_construction_precall_characterization_precall.py fix(router): count embedding batches per input in pre-call checks (#49851) 2026-11-06 11:32:08 -08:00
test_deprecated_members.py fix(router): re-check and reserve per-model rate limits on fallback targets (#50994) 2026-11-10 16:36:10 -08:00
test_endpoints.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_endpoints_characterization_batch.py feat(proxy): let teams use their own allowed S3 buckets for batch files (#50571) 2026-11-10 11:06:17 -08:00
test_endpoints_characterization_generic.py fix(router): sync responses() applies the Router's num_retries and fallbacks (#51011) 2026-11-10 12:55:49 -08:00
test_endpoints_characterization_inference.py fix(router): merge default metadata under the request's instead of replacing it (#50700) 2026-11-09 17:23:52 -08:00
test_fallbacks.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_fallbacks_characterization.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_fallbacks_characterization_outcomes.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_fallbacks_characterization_refusal.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_fallbacks_walk_parity.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_adapter_timeout.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_fuzz_access.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l0001.py fix(proxy): serve Codex its own Bedrock catalog entries for Bedrock deployments (#50743) 2026-11-09 19:00:22 -08:00
test_gaps_l2800.py fix(router): merge default metadata under the request's instead of replacing it (#50700) 2026-11-09 17:23:52 -08:00
test_gaps_l2800_streaming.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l5600.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l5600_anthropic.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l8400_precall.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l8400_pricing.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l8400_retries.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l11100_registry.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l11100_strategy.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l14000.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_l14000_selection.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_pick_input_and_compaction.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_request_overrides.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_router_core_crate.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_gaps_router_core_crate_picks.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_health_registry_views.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_host_settings_changes_characterization.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_legacy_members.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_parity_cooldown_service_model.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_decisions_routing.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_failure_logging.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_parity_malformed_after_rate_limit.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_pick_count_and_fallback_log.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_provider_scoped_fallbacks.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_regress5.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_regress5_errors.py fix(router): sync responses() applies the Router's num_retries and fallbacks (#51011) 2026-11-10 12:55:49 -08:00
test_parity_regress5_settings.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_regress5_streams.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_response_headers.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_parity_rulings_2026_11.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_registry_changesets.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_registry_characterization_construction.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_registry_characterization_lookups.py fix(router): hold the registry lock across router-core writes and mirror reads (#50933) 2026-11-10 17:58:46 +00:00
test_registry_characterization_model_info.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08:00
test_registry_characterization_writes.py fix(router): hold the registry lock across router-core writes and mirror reads (#50933) 2026-11-10 17:58:46 +00:00
test_request_scoped_outcomes.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_retries_cooldowns.py feat(proxy): total_timeout bounds a whole non-streaming request (#50496) 2026-11-08 00:43:50 -08:00
test_retries_health_characterization_cooldowns.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_retries_health_characterization_failure_exits.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_retries_health_characterization_retries.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_selection.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_selection_characterization_groups.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_selection_characterization_prerouting.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_selection_characterization_session_repin.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_selection_characterization_strategies.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_selection_characterization_traffic.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_streaming_characterization_anthropic.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_streaming_characterization_chat.py fix(router): honor request fallbacks in the mid-stream continuation check (#50260) 2026-11-09 17:56:41 -08:00
test_streaming_characterization_outcomes.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_streaming_characterization_responses.py feat(router): add the Rust router core with the host as its only boundary (#49513) 2026-11-04 21:47:58 -08:00
test_usage_and_failure_counting_parity.py fix(router): record retries and fallback hops past a request's first logged failure (#50445) 2026-11-06 19:48:25 -08:00