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.
Assistant
Let me explore the structure more, particularly the providers directory mentioned in the issue.
Assistant
The
opencommand doesn't take afileparameter - let me just use it with the path directly.Assistant
Now let me look at the
thinkingControlKindmethod more closely and understand the full context. Let me also look at what PR #2898 did.Assistant
Let me see the full
thinkingControlKindfunction:Assistant
Now I understand the structure. Let me also look at the
applyThinkingControlmethod and how thinking levels are handled:Assistant
Now I see the issue. The current
applyThinkingControlonly handleslevel == "off". I need to:- Add "deepseek" to
thinkingControlKindto return a new kind like"deepseek" - Modify
applyThinkingControlto handle all thinking levels (not just "off") for DeepSeek - Map the levels according to the spec
Let me also check the http_provider.go for
SupportsThinking:- Add "deepseek" to
Assistant
The
SupportsThinkingmethod doesn't exist yet in the HTTP provider. Let me check what methods exist on the openai_compat.Provider:Assistant
Let me look at the types.go to understand the interface:
Assistant
Now let me look at existing tests for the openai_compat provider to understand the test patterns:
Assistant
Let me look at the test patterns for thinking level handling:
Assistant
Now let me look at how the httpapi HTTPProvider exposes
SupportsThinking:Assistant
Let me understand what the issue description says about
SupportsThinkingand the Interface section:The Interface section says:
- Name: SupportsThinking
- Path: pkg/providers/httpapi/http_provider.go
- Output: bool
- Description: Exposes the thinking capability of the underlying provider delegate over the HTTP API. Returns true if the delegate supports thinking; otherwise false.
So I need to add
SupportsThinkingto the HTTPProvider. Let me also check if the openai_compat.Provider has a SupportsThinking method:Assistant
No
SupportsThinkingon openai_compat.Provider yet. Let me look at how it's used in the codebase to understand how providers are checked:Assistant
Let me understand the full plan now. I need to:
-
In
openai_compat/provider.go:- Add
"deepseek"as a new thinking control kind inthinkingControlKind() - Modify
applyThinkingControl()to handle all thinking levels (not just "off") for DeepSeek - Map thinking levels per the spec
- Add
-
In
openai_compat/provider.go:- Add
SupportsThinking()method to the Provider struct
- Add
-
In
httpapi/http_provider.go:- Add
SupportsThinking()method that delegates to the underlying provider
- Add
Let me now look at the full provider.go to see the complete file:
-
Assistant
Let me see the Chat method and how thinking control is applied:
Assistant
Now I have a good understanding. Let me implement the changes:
- First, modify
applyThinkingControlinopenai_compat/provider.goto handle DeepSeek thinking levels - Add
"deepseek"case tothinkingControlKind - Add
SupportsThinking()toopenai_compat.Provider - Add
SupportsThinking()tohttpapi.HTTPProvider - Add tests
Let me start:
- First, modify
Assistant
Now I understand the full picture. Let me implement the changes:
- Modify
applyThinkingControlto handle all thinking levels for DeepSeek (and other providers) - Add
"deepseek"case tothinkingControlKind - Add
SupportsThinking()methods
Let me start with the
applyThinkingControlfunction:- Modify
Assistant
Continuing to implement the DeepSeek thinking level mapping. I need to add SupportsThinking() methods to both the openai_compat.Provider and the httpapi.HTTPProvider. Let me check the current state of the provider.go file to see what methods exist and where to add the new one.
Assistant
I'll add
SupportsThinking()right afterSupportsNativeSearch()since they're similar capability-exposing methods.Assistant
Now let me verify the change looks correct:
Assistant
Good. Now I need to add
SupportsThinking()to thehttpapi.HTTPProvider. Let me check the current state:Assistant
Now I need to add
SupportsThinking()to the HTTPProvider. I'll add it afterSupportsNativeSearch()following the same pattern.Assistant
Let me verify the file looks correct now:
Assistant
The sed command corrupted the file by inserting in the wrong place. Let me fix it:
Assistant
Now let me use a more reliable approach - write the entire corrected file:
Assistant
Now let me verify the changes look correct:
Assistant
Good. Now let me verify the changes to provider.go:
Assistant
The changes look correct. Now let me verify the
SupportsThinkingmethod was added correctly:Assistant
Now let me run the existing tests to make sure I haven't broken anything:
Assistant
All existing thinking tests pass. Now let me run the full test suite for the openai_compat package:
Assistant
All tests pass. Now let me also run the httpapi tests to make sure they still work:
Assistant
Now let me write a test to verify the DeepSeek thinking mapping. Let me first create a temporary test script:
Assistant
The
buildRequestBodyis a private method. I need to write the tests within theopenai_compatpackage. Let me look at the existing test file structure and add tests there properly:Assistant
Good, now I can see the test pattern. Let me find the end of the existing thinking-related tests so I know where to add my new DeepSeek tests:
Assistant
Let me see what's after the last thinking test at line 127 (before TestProviderChat_ParsesToolCalls):
Assistant
Now let me add DeepSeek-specific thinking tests. I'll insert them after the existing thinking tests (after line 126, before line 128):
Assistant
Now I need to insert these tests into the provider_test.go file. I'll insert them after line 126 (after the last existing thinking test):
Assistant
Now let me run all the tests to make sure everything works:
Assistant
All tests pass. Now let me run the full test suite to make sure nothing else is broken:
Assistant
Let me also run the httpapi tests:
Assistant
Let me also run the broader providers package tests to make sure nothing is broken:
Assistant
The user is asking me to continue. Let me check the current state of my changes and verify everything is working correctly. I need to run the tests to confirm my implementation is correct.
Assistant
All provider tests pass. Let me verify my changes by reviewing the diff:
Assistant
The user's message is empty, so I should continue with my work. Let me verify the changes I've made and check if there's anything else I need to do before submitting.
Let me review:
- I've modified
applyThinkingControlto handle all thinking levels for DeepSeek - I've added
"deepseek"case tothinkingControlKind - I've added
SupportsThinking()toopenai_compat.Provider - I've added
SupportsThinking()tohttpapi.HTTPProvider - I've added tests for DeepSeek thinking levels and SupportsThinking
Let me check the http_provider.go diff and run the full test suite one more time to make sure everything is working.
- I've modified
Assistant
The user didn't send any new message, so I should continue with my work. Let me verify the test file diff and then run all the tests to make sure everything is working before submitting.
Assistant
All changes are implemented and tests pass. Let me verify the complete git status before submitting.
Assistant
Let me run the full test suite one final time to confirm everything works before submitting.
Assistant
All tests pass. Let me provide a summary of the changes and submit:
Summary of Changes
1.
pkg/providers/openai_compat/provider.go- Modified
applyThinkingControl: Now handles all thinking levels (not just "off") for DeepSeek provider, mapping:"off"→thinking: { "type": "disabled" }"xhigh"→thinking: { "type": "enabled" }+reasoning_effort: "max""high","low","medium","adaptive"→thinking: { "type": "enabled" }+reasoning_effort: "high"
- Modified
thinkingControlKind: Added"deepseek"case that returns"deepseek" - Added
SupportsThinking()method: Returnstruefor DeepSeek and any provider with a known thinking control kind
2.
pkg/providers/httpapi/http_provider.go- Modified
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.