litellm/tests/unit/test_router
zoveki b45fae77cd
fix(azure_ai): send reasoning_effort to Foundry reasoning models (#51775)
* fix(azure_ai): send reasoning_effort to Foundry reasoning models

Foundry models outside the GPT-5 family that the cost map marks as reasoning
models, like DeepSeek V4, now accept reasoning_effort. A level the model row
declares is sent as is. A level it does not declare is dropped under
drop_params and gets a 400 otherwise. Declares the levels DeepSeek V4 Flash
and Pro accept on Foundry

* fix(azure_ai): send reasoning_effort only to Foundry rows that declare levels

Gate reasoning_effort on the cost map's reasoning_effort_levels instead of
supports_reasoning, so undeclared reasoning rows keep the drop_params behavior
they had before. Look the levels up case-insensitively, keep a dropped effort
out of the body when allowed_openai_params lists it, model the level check as
values, and name the proxy drop_params setting in the 400

* fix(azure_ai): read Foundry reasoning levels from the loaded catalog row and honor allowed_openai_params

Levels now come only from the model's own azure_ai catalog row, checked for the deployment's base_model first, so a sibling deployment's model_info or a bare openai row no longer decides them. A request that allows reasoning_effort sends any level, as before this PR

* fix(azure_ai): honor register_model reasoning levels on Foundry rows

The level check read only the loaded cost map, so a model registered with
litellm.register_model lost its declared reasoning_effort_levels. Read the
loaded map with register_model registrations on top, still without the
router's per-deployment registrations, so sibling deployments stay separate

* fix(azure_ai): leave default and auto to the model and keep rows without levels unchanged

default is stripped even when allowed_openai_params skips the level check, since Foundry refuses it on DeepSeek V4
auto leaves the level to the model, the same way the Fireworks config treats it, so Kimi K3 auto keeps working
A model whose catalog row lists no levels gets reasoning_effort exactly as it was sent
Updated the Kimi K3 level tests to the seven-level Foundry row, and the catalog-only test to the level check

* fix(router): drop a classifier reasoning_effort level the deployment refuses

The complexity router's classifier kept reasoning_effort once azure_ai listed it, so a level Foundry's row refuses failed the classifier call and sent every request to the capable tier. The classifier now drops a level the deployment's provider config refuses, unless the deployment declares its own levels or allows reasoning_effort

* fix(azure_ai): keep the catalog row's reasoning levels under a registration spelled in another case

A price-only register_model call under azure_ai/fw-kimi-k3 hid the azure_ai/FW-Kimi-K3 row, so its levels were lost and reasoning_effort answered 400 or was dropped
The level lookup now merges the catalog row under the registration, the way register_model itself merges
The Foundry Kimi K3 level test cites the live check behind its seven levels

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-16 16:40:16 -08:00
..
core fix(azure_ai): send reasoning_effort to Foundry reasoning models (#51775) 2026-11-16 16:40:16 -08:00
__init__.py test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
test_enforce_model_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_io_token_rate_limits.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_router.py perf(token_counter): memoize token counts of long texts per tokenizer (#51904) 2026-11-16 19:21:55 +00:00
test_router_callback_hook_sequence.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_router_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_router_entry_points.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08:00
test_router_facade.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_router_fallbacks.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_router_fuzz_regressions_rust_only.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_router_get_deployments.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_router_helper_utils.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_router_host.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_router_max_parallel_requests.py fix(health): log Test Connection spend with the mode's call type and model id (#50987) 2026-11-11 16:07:33 -08:00
test_router_provider_endpoints.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_router_retries.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_router_surface_check.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_router_timeout.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_router_vector_store_endpoints.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00