litellm/tests/unit/router_strategy
tavren27 a705537692
fix(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151)
* fix(openai): treat chat-latest and gpt-chat-latest as gpt-5 family models

OpenAI's chat-latest alias and Azure / Foundry gpt-chat-latest deployments reject max_tokens,
temperature other than 1, top_p, stop, the penalties, logit_bias and logprobs, which is the gpt-5
reasoning family's parameter shape. The shared name check only matched gpt-5 and gpt-6, so these
names forwarded max_tokens and the provider answered 400

The family check now also matches a last path segment equal to chat-latest or containing
gpt-chat-latest, and Azure's max_completion_tokens rename reuses the same helper. gpt-5-chat-latest
keeps its exclusion from issue 13781

Two side effects of moving these names onto the gpt-5 config are fixed too. The gpt-5 config read
tool_choice support off the bare name, which dropped it for azure_ai/gpt-chat-latest, so it now
reads the provider's map row. Azure gpt-5 deployments off the OpenAI catalog lost the user param,
which Azure accepts, so the Azure gpt-5 config adds it back next to tool_choice

The azure_ai/gpt-chat-latest map row gets reasoning_effort_levels ["medium"] like its azure and
openai twins, so /v1/messages lowers xhigh and max to medium instead of high, which Foundry rejects

* fix(openai): enforce a map row's reasoning_effort_levels on the gpt-5 effort checks

* fix(openai): import declared_reasoning_efforts_for_map_key from its litellm_core_utils home

* fix(openai): keep chat-latest tool_choice and user scoped and read effort levels off the catalog row

A router deployment's model_info.reasoning_effort_levels is copied onto the shared
map key, so reading levels from litellm.model_cost let one deployment gate its
siblings. The gate now reads catalog_with_runtime_registrations(), which leaves
router registrations out

chat-latest names keep tool_choice on every provider as they did before they
joined the gpt-5 config, and Azure adds user back only for chat-latest names, so
other off-catalog Azure gpt-5 deployments keep dropping it as on main

* fix(openai): gate custom chat-latest deployment names by the chat-latest row and keep main's tool_choice lookup

* fix(openai): keep chat-latest names on main's handling outside OpenAI, Azure and Foundry, and read base_model on azure_ai

* fix(openai): keep chat-latest names OpenAI doesn't serve on main's handling, and let a Foundry gpt-5 base_model set the param list

* fix(azure_ai,router): keep known Foundry names' params and drop effort levels a chat-latest row refuses

A gpt-5 base_model now stands in for a Foundry deployment name only when the
name is neither gpt-5 family nor a known azure_ai catalog model, with any
provider prefix stripped, so model-router, Phi-4 and gpt-5.6-terra keep main's
params. The complexity router's classifier and tier params drop a
reasoning_effort level a gpt-5 row lists its levels without, unless the
deployment's own model_info lists it

* fix(azure_ai): route custom Foundry names with a gpt-5 base_model to Responses for tools with reasoning

A custom-named Foundry deployment whose base_model is gpt-5.6 or later now
bridges function tools with an active reasoning effort to /v1/responses, the
same as the deployment named after that model, instead of 400ing on chat

* fix(anthropic): keep signed thinking for custom Foundry names that a gpt-5 base_model routes to Responses

* fix(azure_ai,cost): price nested base_model forms and refuse n and seed when a gpt-5 base_model bridges a custom Foundry name

A base_model written as azure_ai/openai/gpt-5.6-terra priced at $0 on every path. Chat only looked priced because Foundry's chat response names the served model, while Foundry's Responses API echoes the deployment name, so bridged and direct /v1/responses calls recorded $0. The cost lookup now drops a nested provider segment from a base_model that has no rates of its own, so it prices like azure_ai/gpt-5.6-terra, and a nested name with its own cost-map row keeps that row

A custom azure_ai name that its gpt-5 base_model sends to the Responses API now answers 400 for n above 1 or any seed, since Responses has neither field, unless drop_params is set. Names LiteLLM already knows and every other provider keep their current behavior

* fix(azure_ai): refuse n and seed only when the gpt-5 base_model sent the request to Responses

The explicit azure_ai/responses/ prefix and a pinned mode: responses already chose Responses before the
base_model was read, so those routes keep main's handling and no longer get a 400 that blames the base_model

* fix(azure_ai): let the /v1/messages adapter see a request-level base_model and name the proxy drop_params setting

A custom azure_ai deployment whose gpt-5 base_model sends it to the Responses API now keeps its reasoning summary on /v1/messages whether the base_model sits in model_info or litellm_params, with a non-empty litellm_params value winning as it does in completion(). The n and seed refusal names the proxy drop_params setting, and tests pin seed=0, n=1, a responses/ name and a gpt-5.6 deployment name keeping its own rules

* test(anthropic): use gpt-5-chat-latest as the chat model that takes no reasoning effort

chat-latest now takes the gpt-5 shape with a medium effort, so main's new
bare-effort test needs a model whose chat config still refuses reasoning_effort

* fix(openai): type OpenAIConfig's supported params as a list of strings

* fix(router): match openai/chat-latest and read litellm_params base_model first in the router's param check

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-24 04:02:51 -08:00
..
adaptive_router fix(anthropic): log the safeguards classifier and compaction summary calls in the parent request's session (#53405) 2026-11-24 01:31:04 -08:00
complexity_router fix(decisions): answer 400 naming extra_headers when it is not an object (#50581) 2026-11-16 07:26:07 -05:00
switchyard_router fix(anthropic): log the safeguards classifier and compaction summary calls in the parent request's session (#53405) 2026-11-24 01:31:04 -08:00
__init__.py test: add __init__.py to intermediate tests/unit packages 2026-09-20 12:55:27 +00:00
test_auto_router.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_auto_router_model_naming.py feat(router): infer custom classifier tiers from model mappings (#48987) 2026-10-29 11:30:23 -07:00
test_auto_router_tuning_baseline.py refactor(router): fence the router surface and document the router-core boundary (#48839) 2026-10-29 00:01:52 +00:00
test_base_routing_strategy.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_baseline_request.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_budget_limiter.py fix(router): preserve routing tags after guardrail metadata enrichment (#50488) 2026-11-16 11:34:48 -08:00
test_budget_limiter_hotpath.py test(router_strategy): keep foreign asyncio task noise out of the budget limiter caplog asserts (#43375) 2026-10-29 06:22:06 -07:00
test_complexity_router.py fix(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151) 2026-11-24 04:02:51 -08:00
test_complexity_tier_predictor.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_fuse_presets.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_lar1_routing.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_least_busy.py fix(proxy): reserve least-busy picks on Vertex pass-through calls (#53588) 2026-11-23 04:21:20 +00:00
test_litellm_encoder.py fix(router): restore four base behaviors the RoutingContext refactor changed (#49395) 2026-10-31 22:58:34 +00:00
test_llm_v2.py feat(redis): serve the router's session pins from a native store (#50870) 2026-11-13 03:22:28 +00:00
test_lowest_cost.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_lowest_latency.py feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
test_lowest_tpm_rpm.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_lowest_tpm_rpm_v2.py fix(router)!: name the request size when usage-based routing refuses an over-tpm request (#51838) 2026-11-14 16:16:21 -05:00
test_quality_router.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_routing_groups.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00
test_router_routing_plugins.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_tag_regex_routing.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_router_tag_routing.py fix(router): preserve routing tags after guardrail metadata enrichment (#50488) 2026-11-16 11:34:48 -08:00
test_savings_baseline.py fix(router): register a model_id Bedrock deployment after an ARN deployment for the same profile (#53461) 2026-11-22 22:27:56 +00:00
test_simple_shuffle.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_stall_detector.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00