Repository navigation
Conversation
Greptile SummaryThis PR forwards graded DeepSeek reasoning effort values and includes several additional resilience, MCP health, cache, spend-counter, and generated-schema updates
Confidence Score: 4/5The behavior appears safe, but the explicit repository type and source-comment requirements must be satisfied before merging No blocking runtime failure was established; the remaining findings concern two confirmed repository-rule violations and missing coverage for a public effort value Files Needing Attention: litellm/llms/deepseek/chat/transformation.py, tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py
|
| Filename | Overview |
|---|---|
| litellm/llms/deepseek/chat/transformation.py | Forwards graded reasoning effort, but violates optional-type and source-comment rules and lacks coverage for the public default value |
| tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py | Covers documented graded levels and explicit thinking precedence, while omitting the public default effort |
| litellm/llms/custom_httpx/http_handler.py | Adds bounded streaming GET support with redirect, compression, size, and cleanup handling |
| litellm/proxy/_experimental/mcp_server/mcp_server_manager.py | Adds bounded, coalesced OpenAPI specification health checks without forwarding server credentials |
| litellm/caching/redis_cache.py | Prevents stale successes from closing a newer breaker generation and guards synchronous reads |
| litellm/caching/dual_cache.py | Preserves in-memory batch results when Redis rejects reads through an open circuit breaker |
| litellm/proxy/proxy_server.py | Invalidates local spend counters and quietly handles known open-breaker increment failures |
| litellm/proxy/_experimental/mcp_server/gateway_dcr_flow.py | Allows four validated redirect URIs while preserving encoded client-size checks |
Reviews (1): Last reviewed commit: "fix(deepseek): forward graded reasoning_..." | Re-trigger Greptile
| optional_params: dict, reasoning_effort: Optional[str] | ||
| ) -> None: |
There was a problem hiding this comment.
This parameter uses Optional[str], but repository guidance requires str | None. This requirement must be satisfied before merging
Rule Used: In this repo, prefer str | None (PEP 604 union syntax) over Optional\[str\] for optional parameters. Do not flag str | None as a style inconsistency. (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| """Pass a graded effort through to DeepSeek instead of discarding it. | ||
|
|
||
| DeepSeek's thinking mode accepts `reasoning_effort` directly and applies | ||
| its own documented mapping server-side (minimal/low -> low, | ||
| medium/high/xhigh -> high, max/ultra -> max). Collapsing the value to a | ||
| bare `thinking: {"type": "enabled"}` here made every graded level | ||
| identical to the default, so callers could not request `low` at all -- | ||
| the one level that shortens deliberation. | ||
|
|
||
| The mapping is deliberately not reimplemented here: it is DeepSeek's | ||
| table, published in their docs, and duplicating it means this client | ||
| silently diverges whenever they change or extend it. | ||
|
|
||
| Reference: https://api-docs.deepseek.com/guides/thinking_mode | ||
| """ |
There was a problem hiding this comment.
The new comment and docstring restate straightforward control flow, violating the repository rule against unnecessary source comments. Please resolve before merging
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| Reference: https://api-docs.deepseek.com/guides/thinking_mode | ||
| """ | ||
| if reasoning_effort not in (None, "none"): |
There was a problem hiding this comment.
The public API accepts reasoning_effort="default", but forwarding tests omit it, leaving its DeepSeek request behavior unverified
Knowledge Base Used: Provider adapters and capabilities
6f7a407 to
5687e9d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
fa9900d to
ee779d4
Compare
Move the client-side activation notes out of DESIGN §9 into reasoning_route_adapter/DEPLOYMENT.md (pi models.json compat delta + amartinr/pi-deepseek-reasoning-chain-fix), linked from the READMEs. Record the measured finding that the reasoning-effort *level* is ineffective through this gateway (LiteLLM v1.99.0): inert on native (DeepSeekChatConfig discards the value, BerriAI/litellm#27439) and erratic on OR (provider-side; object-vs-root isolation test). Only the ON/OFF kill switch is reliable. Track upstream fix PR BerriAI/litellm#40717 (open) and the recorded adapter activation path (drop the redundant thinking toggle on native-ON). See DESIGN §1.4 and PLAN.md. Co-Authored-By: Pi <noreply@pi.dev>
map_openai_params collapsed every non-"none" reasoning_effort into a bare
thinking: {"type": "enabled"} and dropped the level, so low, high and max
were all indistinguishable from the default and callers could not ask for
reduced reasoning at all
DeepSeek accepts reasoning_effort directly in thinking mode and grades it
server-side, so the value is forwarded rather than remapped here
Fixes #27439
ee779d4 to
6cd2585
Compare
|
Rebased on current |
|
Closing this since #38736 already fixes the same problem on main. Thanks for contributing, and please reopen if anything is missing |
TLDR
Problem this solves:
reasoning_effortis dropped for DeepSeek, solowbehaves likehighHow it solves it:
thinking: enabledUser Flow
Before: a developer running an agent loop on
deepseek-flashtries to stop the model over-thinking, and nothing they set makes any differencemax_tokensfinish_reason: "length", emptycontentand notool_calls, so the loop has nothing to act onreasoning_effort="low"and send the same request"thinking": {"type": "enabled"}, with no effort, so the model reasons exactly as much as beforemax_tokensinstead, and the model simply deliberates further into the larger budgetAfter: the same developer sets
reasoning_effort="low"and the model reasons roughly half as much and reaches an answerreasoning_effort="low"and send the request"reasoning_effort": "low"alongside"thinking": {"type": "enabled"}finish_reason: "stop"and a usable tool call, having used about half the reasoning tokensEvidence
Measured against
deepseek-flash, four samples per setting on a bounded reasoning task:reasoning_effortlowhighOn an unbounded task with a 45,000 token budget,
lowfinished at 19,554 reasoning tokens whilehighran into the cap without finishingCaveats
thinkingtoggle is still honoured exactly as given, and no effort is merged into it. I could not establish whether DeepSeek applies an effort alongside an explicit toggle: four samples per condition put the combined case betweenlowandhigh, overlapping both, so the patch does not guessminimal/low→ low,medium/high/xhigh→ high,max/ultra→ max) and applies it server-side, so duplicating it in the client would diverge whenever they change it. (deepseek family) Fix reasoning_effort parameter mapping: correctly disable thinking for "none", and map deepseek's high/max reasoning_effort #27829 took the client-side approach and collapsedlowintohigh, which loses the only level that shortens reasoningTesting
Extends
tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py:default, reaches the request bodythinkingtoggle carries no effort16 thinking and effort tests pass. Two vision tests in the same file fail identically before and after this change