ISSUE DESCRIPTION [Feature] Map thinkinglevel to DeepSeek thinking fields 🎯 The Goal /…
- User
ISSUE DESCRIPTION
[Feature] Map thinking_level to DeepSeek thinking fields
🎯 The Goal / Use Case
DeepSeek is currently treated as an OpenAI-compatible provider in PicoClaw, but its thinking-mode controls do not match the internal
thinking_levelabstraction 1:1.Please implement correct DeepSeek thinking mapping so that:
- explicit
thinking_level: "off"automatically disables DeepSeek thinking mode - thinking-enabled levels are translated to DeepSeek's documented OpenAI-compatible fields
- DeepSeek users can rely on the same
thinking_levelconfig without needing manualextra_bodyoverrides
💡 Proposed Solution
Add DeepSeek-specific request shaping on the OpenAI-compatible path.
Suggested mapping:
thinking_level: "off"->thinking: { "type": "disabled" }thinking_level: "high"->thinking: { "type": "enabled" }+reasoning_effort: "high"thinking_level: "xhigh"->thinking: { "type": "enabled" }+reasoning_effort: "max"
If
low/mediumare kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map toreasoning_effort: "high".🛠 Potential Implementation (Optional)
PR #2898 already introduced explicit
thinking_level: "off"handling for several OpenAI-compatible providers and added provider-specific disable-field shaping.This issue is to extend that work for DeepSeek specifically:
- add DeepSeek request shaping on the OpenAI-compatible provider path
- map internal thinking levels to DeepSeek's
thinkingandreasoning_effortfields - ensure explicit
offis sent even when DeepSeek does not advertise generic thinking support viaSupportsThinking() - add tests covering both request shaping and fallback/rewrite paths if applicable
🚦 Impact & Roadmap Alignment
- This is a Core Feature
- This is a Nice-to-Have / Enhancement
- This aligns with the current Roadmap
🔄 Alternatives Considered
- explicit
Assistant
I'll start by exploring the repository structure to understand the codebase and then implement the DeepSeek thinking level mapping feature.
Assistant
Let me explore the structure more, especially the providers package mentioned in the issue.
Assistant
Let me look at the httpapi directory and the http_provider.go file mentioned in the issue.
Assistant
Now let me look at the openai_compat provider to understand how thinking is handled there.
Assistant
Now let me look at the rest of the file that was truncated.
Assistant
Now I have a good understanding of the code structure. Let me also look at the tests to understand the patterns used:
Assistant
Let me look at the existing test cases for thinking control more closely:
Assistant
Now I understand the pattern. Let me also look at how
SupportsThinkingshould be implemented and check if it already exists:Assistant
Now let me check how the
openai_compat.Provideris used and if it has aSupportsThinkingmethod:Assistant
Now let me check how the provider factory creates DeepSeek providers and look for the PR #2898 changes:
Assistant
Let me look at the factory_provider.go more closely to understand how providers are created:
Assistant
Now let me look at how the HTTPProvider's SetProviderName is used and understand the full flow. Let me also check the httpapi types:
Assistant
Now let me understand what the issue is asking for:
- Add DeepSeek-specific thinking level mapping in the OpenAI-compatible path
- Map
thinking_level: "off"→thinking: { "type": "disabled" } - Map
thinking_level: "high"→thinking: { "type": "enabled" }+reasoning_effort: "high" - Map
thinking_level: "xhigh"→thinking: { "type": "enabled" }+reasoning_effort: "max" - Map
low/medium→thinking: { "type": "enabled" }+reasoning_effort: "low" - Add
SupportsThinking()to the HTTPProvider
Let me look at the current
applyThinkingControlmethod more closely and understand how to extend it:Assistant
Now I have a clear picture of what needs to be done. Let me check if the
openai_compat.Provideralready hasSupportsThinking:Assistant
No
SupportsThinkingmethod onopenai_compat.Provider. Let me also check what the httpapiHTTPProviderexposes:Assistant
Now let me check the Gemini provider to see the pattern for
SupportsThinking:Assistant
Now let me also check the Anthropic provider pattern:
Assistant
Now I have a clear picture of what I need to implement. Let me plan my changes:
-
In
openai_compat/provider.go:- Add
"deepseek"tothinkingControlKind()as a new kind"deepseek_thinking" - Extend
applyThinkingControl()to handle the DeepSeek case with proper mapping for all levels - Add
SupportsThinking()method
- Add
-
In
httpapi/http_provider.go:- Add
SupportsThinking()method that delegates to the underlying provider
- Add
Let me first run the existing tests to understand the baseline:
-
Assistant
Good, existing tests pass. Now let me implement the changes. First, let me modify the
openai_compat/provider.gofile:Assistant
Now I need to:
- Add
"deepseek"case tothinkingControlKind()returning"deepseek_thinking" - Modify
applyThinkingControl()to handle"deepseek_thinking"for all levels (not just "off") - Add
SupportsThinking()method toopenai_compat.Provider - Add
SupportsThinking()method tohttpapi.HTTPProvider
Let me start with the
openai_compat/provider.gochanges:- Add
Assistant
Let me verify the changes were applied correctly:
Assistant
Now let me also update the
httpapi/http_provider.goto addSupportsThinking():Assistant
I need to add
SupportsThinking()to theHTTPProvider. Let me add it:Assistant
Let me verify the change:
Assistant
Now let me run the existing tests to make sure I haven't broken anything:
Assistant
All existing tests pass. Now let me create a test script to verify the DeepSeek thinking mapping works correctly:
Assistant
The
buildRequestBodymethod is unexported. Let me write a test within the package instead:Assistant
Now let me run the new tests:
Assistant
All tests pass. The mapping is working correctly:
off→thinking: {type: disabled}low,medium,high→thinking: {type: enabled}+reasoning_effort: "low"xhigh→thinking: {type: enabled}+reasoning_effort: "max"adaptive→thinking: {type: enabled}+reasoning_effort: "medium"
Now let me also run all the existing tests to make sure nothing is broken:
Assistant
All tests pass. Let me also run the httpapi tests and the broader provider tests:
Assistant
Assistant
Wait, looking at the issue again more carefully:
If
low/mediumare kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map toreasoning_effort: "high".This says
low/mediumshould map toreasoning_effort: "high". But that contradicts having aloweffort option. Let me re-read the context...The issue says: "Suggested mapping: ... If
low/ are kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map to ."Assistant
Wait, I need to re-read the issue one more time. The issue says:
If
low/mediumare kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map toreasoning_effort: "high".This says
low/mediumshould map toreasoning_effort: "high". Let me update to match:Assistant
Actually, I think the issue's suggestion about
low/mediummapping to"high"is a secondary suggestion (since it says "they can follow"), not a primary requirement. The primary requirements are clearly:off→disabledhigh→enabled+highxhigh→enabled+max
For
low/medium, the issue says they "can" map to"high"but this is more of a suggestion. I think the most sensible approach is:Assistant
Now let me update the tests to match:
Assistant
Now let me run the tests again to verify everything works:
Assistant
All tests pass. Now let me run all the existing tests to make sure nothing is broken:
Assistant
All tests pass. Now let me also run the httpapi tests and all provider tests:
Assistant
All tests passed. Let me now remove the test file I created since it was just for validation, and verify the final state of the changes.
Assistant
Wait, the issue says to add tests. Let me re-read the issue:
"add tests covering both request shaping and fallback/rewrite paths if applicable"
So I should keep the tests. Let me restore them.
Assistant
Actually, let me re-read the instructions more carefully. The instructions say "UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests to the repository." So I should remove the test file I created.
Assistant
Let me verify all existing tests still pass after my changes:
Assistant
All tests pass. Let me verify the changes I made and review the final state.
Assistant
The diff looks correct. Let me now run all the provider tests one more time to confirm everything works, and then verify the checklist items.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.