litellm/tests/unit/router_utils
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
..
pre_call_checks perf(token_counter): memoize token counts of long texts per tokenizer (#51904) 2026-11-16 19:21:55 +00:00
__init__.py
test_access_windows.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_add_retry_fallback_headers.py fix(responses): accept a string or tuple allowed_openai_params on Responses models instead of answering 500 (#51751) 2026-11-14 04:32:38 -05:00
test_client_initalization_utils.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_cooldown_cache.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_cooldown_handlers.py fix(completion)!: answer 400 for a chat message without a role (#51124) 2026-11-11 20:59:19 +00:00
test_deployment_pricing.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_embedding_batch_size_check.py feat(embeddings): enforce per-request input batch limit (#44574) 2026-10-20 11:35:18 +00:00
test_endpoint_eligibility.py feat(router): opt in to non-chat deployment filtering (#46257) 2026-10-29 08:33:36 -07:00
test_fallback_event_handlers.py feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
test_fallback_event_v2_dispatch.py feat(custom-logger-v2): add types, dispatcher and route callback call sites (step 0) (#51214) 2026-11-13 22:08:05 +00:00
test_get_retry_from_policy.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_handle_error.py fix(completion)!: answer 400 for a chat message without a role (#51124) 2026-11-11 20:59:19 +00:00
test_health_check_allowed_fails_integration.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_health_state_cache.py feat(redis): serve the health checks' deployment states from a native store (#50357) 2026-11-13 03:22:28 +00:00
test_kubernetes_pod_discovery.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_pattern_match_deployments.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_prompt_caching_cache.py fix(anthropic)!: carry prompt_cache_breakpoint to cache_control on chat completions to Claude (#49783) 2026-11-03 12:56:22 +00:00
test_ptu_shares.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_reasoning_effort_capability.py fix(azure_ai): send reasoning_effort to Foundry reasoning models (#51775) 2026-11-16 16:40:16 -08:00
test_request_priority.py fix(router)!: schedule default_priority requests once and reject a malformed priority (#47498) 2026-10-20 08:00:57 +00:00
test_router_health_check_routing.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_interactions_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_utils_common_utils.py fix(responses): accept a string or tuple allowed_openai_params on Responses models instead of answering 500 (#51751) 2026-11-14 04:32:38 -05:00
test_routing_read_batch.py refactor(redis): delete the Python RedisBatch now that every request op is native (#51383) 2026-11-13 03:22:28 +00:00