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 locate relevant files. Let's first see what's in the root.
- Assistant
Let me explore the repository structure more thoroughly.
- Assistant
Let me look for DeepSeek-related files and thinking-level related files.
- Assistant
Let me find the relevant source files in the repository, excluding the cache directory.
- Assistant
Let me explore the relevant files to understand the codebase structure.
- Assistant
No DeepSeek-specific files found. Let me look at the OpenAI-compatible provider code and the thinking-related code.
- Assistant
Let me continue reading the file to understand the thinking control logic better.
- Assistant
Let me look at the thinking.go file and the test file to understand how thinking levels work.
- Assistant
Now let me look at the
thinkingControlKindfunction more closely and understand the test file. - Assistant
Now let me look at the openai_compat provider test to understand the current test patterns.
- Assistant
Let me search for existing DeepSeek references and understand how providers are registered.
- Assistant
Let me look at the full provider.go file to understand the thinking control logic better.
- Assistant
Let me look at the thinkingControlKind function in detail to understand its logic.
- Assistant
Let me look at the test file to see if there are existing tests for thinking control for DeepSeek. Let me also look at how DeepSeek provider is used in the codebase.
- Assistant
Let me look at the existing provider registration to understand how DeepSeek provider is configured.
- Assistant
Let me look at the provider metadata to understand how DeepSeek is configured.
- Assistant
Let me look at the
SupportsThinkingmethod in the httpapi provider. - Assistant
SupportsThinking is not in the http_provider.go file. Let me search for it in the codebase.
- Assistant
Let me look at the providers types to understand the interface.
- Assistant
Let me look at the full
applyThinkingControlfunction to see the current implementation. - Assistant
Now I understand the issue. Let me check the existing tests for DeepSeek thinking control.
- Assistant
Let me look at the test around line 471-530 to understand the existing DeepSeek test.
- Assistant
Let me look at the existing tests for thinking control.
- Assistant
Now I understand the issue. Let me look at how the
thinkingControlKindfunction works and what changes are needed. Let me first run the existing tests to see the current state. - Assistant
I need to set up the environment properly.
- Assistant
Now I understand the codebase. Let me plan the implementation:
- The
thinkingControlKindfunction needs a "deepseek" case - The
applyThinkingControlmethod needs to be extended to handle all thinking levels (not just "off") for DeepSeek - We need to map thinking levels to DeepSeek's
thinkingandreasoning_effortfields - We need tests for this
Let me implement the changes:
- The
- Assistant
Now I understand the codebase. Let me implement the changes step by step.
First, let me check if the HTTPProvider has a SupportsThinking method and how provider names are propagated.
- Assistant
I need to check the current
SupportsThinkingmethod implementations. Let me look at how the Gemini provider does it: - Assistant
Let me check how providers are constructed to understand if DeepSeek gets its
providerNameset: - Assistant
Let me look at the factory to understand how DeepSeek providers are created.
- Assistant
Now I understand the codebase. Let me implement the changes:
- First, modify
thinkingControlKindto add DeepSeek support - Update
applyThinkingControlto handle all thinking levels (not just "off") - Add
SupportsThinkingtoHTTPProvider - Add tests
Let me start with the provider changes:
- First, modify
- Assistant
Let me see the full applyThinkingControl and thinkingControlKind functions in the file:
- Assistant
Now I need to implement the changes. Let me make the edits:
- First, modify
thinkingControlKindto add DeepSeek case - Modify
applyThinkingControlto handle all thinking levels for DeepSeek - Add
SupportsThinkingmethod to the openai_compat Provider - Add
SupportsThinkingto HTTPProvider - Add tests
- First, modify
- Assistant
Now I need to add the
applyDeepSeekThinkingfunction and updatethinkingControlKindto include DeepSeek. Let me also add theSupportsThinkingmethod. - Assistant
Now I need to add the
applyDeepSeekThinkingfunction. Let me add it right after thethinkingControlKindfunction: - Assistant
I notice there's a stray
}after line 294. Let me fix that: - Assistant
Now I need to add the
SupportsThinkingmethod to theHTTPProviderinhttp_provider.go: - Assistant
I need to add a
SupportsThinkingmethod to theHTTPProvider. Let me add it afterSupportsNativeSearch: - Assistant
I need to add a
SupportsThinkingmethod to the HTTPProvider. Let me add it afterSupportsNativeSearch: - Assistant
Wait, the interface assertion is unnecessary since
p.delegateis already a concrete*openai_compat.Provider. Let me simplify: - Assistant
Now let me verify the code compiles and run the existing tests to make sure nothing is broken:
- Assistant
Let me check the current state of the file around line 270:
- Assistant
I see the problem - the
thinkingControlKindfunction's closing brace is missing. Let me fix this: - Assistant
I need to open the correct file first:
- Assistant
I see the issue - the closing brace for
thinkingControlKindis missing. Let me fix this: - Assistant
Now let me verify the code compiles:
- Assistant
Now let me verify the httpapi package compiles:
- Assistant
Good! Now let me run the existing tests to make sure nothing is broken:
- Assistant
Now let me add tests for DeepSeek-specific thinking mapping to the provider_test.go file:
- Assistant
Let me find a good location to add tests. Let me search for where I can add DeepSeek tests:
- Assistant
Let me add the DeepSeek thinking tests after the existing thinking tests:
- Assistant
Now let me run the new tests to make sure they pass:
- Assistant
Let me check what's at line 126:
- Assistant
The issue is missing a blank line between the closing brace and the new function. Let me fix:
- Assistant
There's a duplicate function declaration and some issues. Let me look at the problematic area:
- Assistant
I see the problem - there's a duplicate
}on line 126 and duplicate function definitions. Let me fix this properly: - Assistant
Now let me run the tests again:
- Assistant
Excellent! All the new DeepSeek tests pass! Now let me run the full test suite for the openai_compat package to make sure I haven't broken anything:
- Assistant
All tests pass. Now let me also run the tests for the httpapi package:
- Assistant
Let me also run the agent tests to make sure nothing is broken:
- Assistant
All tests pass. Now let me verify my changes are correct by reviewing the diff:
- Assistant
Let me look at the full diff to make sure everything is correct:
- Assistant
The diff looks good. Let me run the full test suite one more time to make sure everything passes:
- Assistant
All tests pass! Let me also check if there's a test file for httpapi to add a test for the HTTPProvider's SupportsThinking method:
- Assistant
There's no test file for http_provider.go. Let me create one to test the SupportsThinking method:
- Assistant
Now I need to write the test file. Let me add tests for the HTTPProvider's SupportsThinking method:
- Assistant
Now let me run the httpapi tests to make sure the new tests pass:
- Assistant
All tests pass. Now let me run the full test suite one more time to make sure everything is still working:
- Assistant
Let me check if there are any other tests in the repository that might be affected by our changes:
- Assistant
Let me also check if there are any tests that test the thinking_level option being passed to providers:
- Assistant
Let me run the agent tests to make sure nothing is broken:
- Assistant
Let me search for the relevant agent tests that involve thinking:
- Assistant
Let me run some of the agent tests to make sure they still pass:
- Assistant
All tests pass! Let me now do a final review of my changes and run the complete test suite:
- Assistant
All tests pass. Let me verify the final state of my changes:
- Assistant
Let me check if there are any untracked files:
- Assistant
I need to make sure the new test file is included. Let me check the full diff including the new file:
- Assistant
Let me verify the new test file content:
- Assistant
Let me verify the final state of the main provider.go file to make sure everything is correct:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.