mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-29 01:42:19 +00:00
fix(deepseek): exclude reasoning_effort=none sentinel from passthrough
"none" is the thinking-OFF sentinel, not a real effort value. Passing it alongside explicit thinking:enabled would send contradictory instructions to DeepSeek. Only forward real effort values (low/medium/high/xhigh/max). Addresses review feedback on the reasoning_effort passthrough change.
This commit is contained in:
parent
43f319b57f
commit
b84eff2c1f
2 changed files with 12 additions and 2 deletions
|
|
@ -70,8 +70,10 @@ class DeepSeekChatConfig(OpenAIGPTConfig):
|
|||
# can run away, exhausting max_tokens during reasoning and returning empty content
|
||||
# (finish_reason="length", content:null). Preserve the value into the request body
|
||||
# when thinking is on so callers can bound effort (e.g. reasoning_effort="low").
|
||||
# See https://api-docs.deepseek.com/guides/thinking_mode
|
||||
if thinking_enabled and reasoning_effort is not None:
|
||||
# Exclude the "none" sentinel: it is an OpenAI-style thinking-OFF switch, not a real
|
||||
# effort value, so passing it alongside explicit thinking:enabled would be
|
||||
# contradictory. See https://api-docs.deepseek.com/guides/thinking_mode
|
||||
if thinking_enabled and reasoning_effort not in (None, "none"):
|
||||
optional_params["reasoning_effort"] = reasoning_effort
|
||||
|
||||
return optional_params
|
||||
|
|
|
|||
|
|
@ -39,3 +39,11 @@ def test_explicit_thinking_disabled_wins_and_drops_effort():
|
|||
def test_no_reasoning_effort_leaves_no_key():
|
||||
out = _map({})
|
||||
assert out.get("reasoning_effort") is None
|
||||
|
||||
|
||||
def test_explicit_enabled_thinking_with_none_effort_not_contradictory():
|
||||
# "none" is a thinking-OFF sentinel, not a real effort value: it must not be
|
||||
# passed alongside explicit thinking:enabled (would contradict the provider).
|
||||
out = _map({"thinking": {"type": "enabled"}, "reasoning_effort": "none"})
|
||||
assert out["thinking"] == {"type": "enabled"}
|
||||
assert "reasoning_effort" not in out
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue