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 mapping.
Assistant
The file
pkg/providers/httpapi/http_provider.gois mentioned in the issue. Let me explore the providers directory structure.Assistant
I see there are many provider files. The issue mentions
pkg/providers/httpapi/http_provider.gofor theSupportsThinking()interface. Let me look at that file first to understand the existing pattern, and also look at PR #2898's changes.Let me look at the http_provider.go file and the openai_compat provider to understand how thinking is currently handled.
Assistant
I see that
http_provider.godelegates toopenai_compat.Provider. Let me look at the openai_compat provider and understand the current thinking implementation.Assistant
Let me read the file in sections to see the complete
applyThinkingControland related functions:Assistant
Let me continue reading the rest of the file, especially the
applyThinkingControlfunction and how other providers are handled.Assistant
Let me look at how DeepSeek is configured and find where it's registered:
Assistant
Let me look at how DeepSeek is configured and where it's registered, particularly in the factory and provider_metadata files.
Assistant
Now let me look at the test file for the openai_compat provider to understand the testing patterns:
Assistant
Now let me look at how
SupportsThinking()is implemented and how providers are created, especially the DeepSeek one:Assistant
Let me look at the
SupportsThinking()interface and thetypes.gofile:Assistant
Now let me look at the factory_provider.go to understand how DeepSeek is created:
Assistant
Let me look at the complete factory_provider.go to understand how providers are created and how we might need to modify the DeepSeek creation. I also need to understand how the
http_provider.goand the openai_compat provider work together, especially looking at how the provider name is set and how theSupportsThinking()interface is used.Assistant
Now I understand the structure. Let me look at the http_provider.go more carefully to see if
SupportsThinking()is implemented there:<tool_call> <function=bash_terminal> <parameter=command> grep -n "SupportsThinking" /picoclaw/pkg/providers/httpapi/http_provider.go </tool_call>
Assistant
The
SupportsThinking()method is not implemented in http_provider.go. Let me check if the openai_compat provider has it.Assistant
Now I have a good understanding of the codebase. Let me look at the full file structure to understand the exact lines I need to modify:
Assistant
Now I have a good understanding of the codebase. Let me look at the specific lines I need to modify:
Assistant
Now I have a complete understanding of the codebase. Let me plan and implement the solution:
Summary of changes needed:
-
pkg/providers/openai_compat/provider.go:- Add DeepSeek case to
thinkingControlKind()method - Update
applyThinkingControl()to handle all thinking levels for DeepSeek (not just "off") - Add
SupportsThinking()method to the provider
- Add DeepSeek case to
-
pkg/providers/httpapi/http_provider.go:- Add
SupportsThinking()method that delegates to the underlying provider
- Add
-
pkg/providers/openai_compat/provider_test.go:- Add tests for DeepSeek thinking level mapping
Let me start implementing:
-
Assistant
Now I have a complete understanding. Let me implement the changes:
- First, I'll update the
applyThinkingControlfunction to handle DeepSeek mapping for all thinking levels - Then add the DeepSeek case to
thinkingControlKind - Add
SupportsThinking()method
- First, I'll update the
Assistant
Let me use the correct edit syntax:
Assistant
Let me try using a different approach - I'll write the changes using bash commands:
Assistant
Let me create a temporary Python script to make the edits:
Assistant
Good, now let me verify the change and continue with adding the DeepSeek case to
thinkingControlKind:Assistant
Good! Now let me update the
thinkingControlKindmethod to add the DeepSeek case:Assistant
Now let me add the DeepSeek case to
thinkingControlKind. I'll use sed to insert the case:Assistant
Now I need to:
- Add
SupportsThinking()method to the HTTPProvider in http_provider.go - Add tests for the DeepSeek thinking level mapping
Let me first verify the changes to thinkingControlKind.
- Add
Assistant
Now I need to add the
SupportsThinking()method to the HTTPProvider in http_provider.go:Assistant
Let me use a simpler approach to add the
SupportsThinking()method:Assistant
Now I need to verify the change and also add the
SupportsThinking()method to the openai_compat.Provider:Assistant
Now I need to add the
SupportsThinking()method to the openai_compat.Provider:Assistant
The SupportsThinking method is not yet implemented in the openai_compat provider. I need to add it. Let me find a good place to add it, likely after the SupportsNativeSearch method.
Assistant
I need to add the
SupportsThinking()method to the openai_compat provider. Let me look at the end of the file to find where to add it.Assistant
I need to add the
SupportsThinking()method to the openai_compat provider. This method should return true if the provider is DeepSeek. Let me add it after theSupportsNativeSearch()method.Assistant
Good progress! Now let me verify the changes are correct and run the existing tests:
Assistant
I need to set the HOME variable to build the Go code. Let me do that first.
Assistant
The build succeeded. Now let me run the existing tests:
Assistant
I see the issue - the test is failing because I changed the
applyThinkingControlfunction to handle all levels for all providers, but it should only handle "off" for non-DeepSeek providers. Let me fix this:Assistant
I see the issue. The test is failing because for non-DeepSeek providers (like Doubao), we should only handle
thinking_level: "off"and leave other levels untouched. My change removed the early return for non-off levels. Let me fix this:Assistant
Now let me run the tests again:
Assistant
All existing tests are passing. Let me run all the tests to completion:
Assistant
All existing tests pass. Now let me add tests for the DeepSeek thinking level mapping. Let me also run the httpapi tests:
Assistant
Both test suites pass. Now let me add tests for the DeepSeek thinking level mapping. I'll add them to the provider_test.go file:
Assistant
Now let me run all the tests again to make sure my new tests pass:
Assistant
All the new DeepSeek tests pass. Now let me run the full test suite to ensure everything works together:
Assistant
All tests pass. Let me also verify that the provider metadata correctly indicates that DeepSeek is an httpAPI provider:
Assistant
Let me also run a broader set of tests to ensure the entire provider system still works:
Assistant
All provider tests pass. Let me verify the final state of the changes:
Assistant
Let me verify the changes are complete and correct by reviewing the final diff.
Assistant
The implementation is complete. Let me verify one more time that all tests pass:
Assistant
All tests pass. Let me provide a summary of the changes made and then submit.
Assistant
All tests pass and the implementation is complete. Let me submit the changes.
Summary of Changes
The implementation adds DeepSeek-specific thinking mapping to the OpenAI-compatible provider path:
Changes Made:
-
pkg/providers/openai_compat/provider.go:- Modified
applyThinkingControl()to delegate toapplyDeepSeekThinking()for DeepSeek providers - Added
applyDeepSeekThinking()function with the mapping:thinking_level: "off"→thinking: {"type": "disabled"}(no reasoning_effort)thinking_level: "high"→thinking: {"type": "enabled"}+reasoning_effort: "high"thinking_level: "xhigh"→thinking: {"type": "enabled"}+reasoning_effort: "max"thinking_level: "low"/"medium"/"adaptive"→thinking: {"type": "enabled"}+ (maps to DeepSeek's "high" behavior)
- Modified
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.