Repository navigation
fix(deepseek): promote reasoning_content on multi-turn default thinking models - #42158
truecallerabreham wants to merge 3 commits into
Conversation
…ng models
DeepSeek dedicated reasoning models (deepseek-reasoner, deepseek-r1) and default-on models (deepseek-v4) run thinking mode server-side without requiring explicit client-side thinking parameters. Previously, _thinking_mode_active required thinking={'type': 'enabled'}, which caused _fill_reasoning_content to be bypassed when calling these models without the parameter, resulting in HTTP 400 errors from DeepSeek's API in multi-turn conversations.
Treat default reasoning models as active in _thinking_mode_active unless explicitly disabled with thinking={'type': 'disabled'}, prune empty provider_specific_fields after promotion, and preserve opt-in behavior for dual-mode models like deepseek-v3.2. Add unit regression tests covering parameter matrices and multi-turn message transformation.
|
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ee2b318 to
446ddf8
Compare
|
Please review the updated commit with get_model_info metadata lookup and added tests under tests/test_litellm @greptileai |
|
Added thinking_always_on to model_prices_and_context_window.json, removed hardcoded markers from transformation logic, and deleted the duplicate test file @greptileai |
…efault thinking models
83e7175 to
02b4d52
Compare
…thinking payloads
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a developer makes a multi-turn conversation call to deepseek-reasoner or deepseek-r1 through LiteLLM
After: the second request succeeds and preserves the reasoning chain
Relevant issues
Fixes #37636
Pre-Submission checklist
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Before (d9a3381)
multi-turn reasoning_content promotion on default reasoning model
deepseek-reasonerwith prior assistant message containingprovider_specific_fields={"reasoning_content": "step 1"}_fill_reasoning_contentbecause_thinking_mode_activereturns False whenthinkingparam is omitted; assistant message has noreasoning_contentfield on wire messageAfter (ee2b318)
multi-turn reasoning_content promotion on default reasoning model
deepseek-reasoner_thinking_mode_activeidentifies default reasoning model and runs_fill_reasoning_content; assistant message hasreasoning_content: "step 1"promoted and emptyprovider_specific_fieldsremoved$ pytest tests/unit/llms/deepseek/chat/test_deepseek_chat_transformation.py -v ============================= 63 passed in 0.26s ==============================Type
🐛 Bug Fix
Caveats (if any)
Low
Final Attestation