litellm/tests/unit/llms/deepseek
norkelbyte 5fd9cc8949
fix(deepseek): forward output_config.effort and thinking as sent on /v1/messages (#51317)
* fix(deepseek): forward output_config.effort and thinking as sent on /v1/messages

* fix(deepseek): validate effort and map reasoning_effort on /v1/messages

An effort level DeepSeek does not accept now gets a 400 that lists the accepted levels, or is dropped under drop_params, instead of reaching DeepSeek and coming back as a 422 labeled api_error. The reasoning_effort alias is sent as output_config.effort, and the caller's output_config.effort wins when both are set. The tests carry their types and Final annotations

* fix(deepseek): keep the effort drop for non-reasoning models and reject bad aliases on /v1/messages

Only DeepSeek models the cost map marks supports_reasoning get thinking and output_config.effort as sent. deepseek-chat, coder and v3 keep the base drop, so clients that send adaptive thinking on every request do not start billing thinking tokens there. A string reasoning_effort is checked against DeepSeek's levels even next to output_config.effort, and a non-object output_config is forwarded unchanged instead of being replaced

* fix(deepseek): keep base effort handling for models listed without reasoning on /v1/messages

Models the cost map lists without reasoning, such as deepseek-chat, keep the
base reasoning_effort budget mapping, effort drop, and temperature drop.
Models the cost map does not list yet get the forwarding path, like the
current DeepSeek reasoning models.

* test(deepseek): cover reasoning_effort added beside other output_config fields

* fix(deepseek): fall back to reasoning_effort when dropping a bad effort and let reasoning_effort none clear thinking

* fix(deepseek): count only catalog-listed models as listed without reasoning

A proxy deployment registers an unlisted model into the cost map, so the old check stripped thinking, effort and temperature from it. Use is_known_non_reasoning_model, which reads the cost map as loaded

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-24 01:36:57 +00:00
..
chat fix(mcp): drop hosted MCP tool_choice under drop_params and honor drop_params in Bedrock batch rows (#53697) 2026-11-23 08:51:59 -08:00
count_tokens fix(deepseek): forward output_config.effort and thinking as sent on /v1/messages (#51317) 2026-11-24 01:36:57 +00:00
messages fix(deepseek): forward output_config.effort and thinking as sent on /v1/messages (#51317) 2026-11-24 01:36:57 +00:00
search feat(search): add DeepSeek as a /v1/search provider (#47401) 2026-10-19 20:35:04 +00:00
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_deepseek_common_utils.py fix(proxy): count tokens with the thinking, effort, and tool_choice that inference sends (#51079) 2026-11-14 02:29:16 +00:00
test_deepseek_cost_calculator.py test(llms): annotate local_model_cost_map fixtures in phase 6 tests 2026-09-20 07:50:30 +00:00