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
Let me start by understanding the repository structure and the existing codebase to implement the DeepSeek thinking level mapping feature. I need to:
- Explore the repository structure
- Find the existing provider implementation, especially the OpenAI-compatible path
- Understand the
thinking_levelabstraction and how it's currently handled - Find PR #2898's pattern for provider-specific request shaping
- Implement DeepSeek-specific mapping
- Add tests
Let me start by exploring the repository.
Assistant
Let me explore the pkg directory structure and find the providers package.
Assistant
Now let me look at the
openai_compatpackage and also search for existing thinking level handling.Assistant
Now I can see the existing code structure. Let me look at the key parts:
applyThinkingControl- currently only handlesthinking_level: "off"thinkingControlKind- determines which kind of thinking control to use per providernormalizedThinkingLevel- normalizes thinking levels
I need to see the full
thinkingControlKindfunction and understand the current pattern. Let me also look for "deepseek" references and the test file.Assistant
Now I understand the current implementation. The
applyThinkingControlmethod only handlesthinking_level: "off", and I need to extend it to handle all thinking levels for DeepSeek. Let me also look at the test file to understand the testing patterns.Assistant
Now let me also check if there's a
SupportsThinkingmethod mentioned in the issue:Assistant
Now let me search for how DeepSeek is used in the codebase and look at the httpapi types:
Assistant
Now let me look at the
httpapi/types.goto understand theSupportsThinkinginterface and how it's exposed:Assistant
Let me check if there's already a
SupportsThinkingon the openai_compat provider and how the httpapi exposes it:Assistant
So
openai_compat.Providerdoesn't implementSupportsThinking. Let me check the issue more carefully - it says the interface is atpkg/providers/httpapi/http_provider.go. Let me look at the agent code that usesThinkingCapable:Assistant
Now I understand the issue better. The
ThinkingCapableinterface checksSupportsThinking()to decide whether to passthinking_levelto the provider. For DeepSeek to work properly, I need to:- Add
SupportsThinking()toHTTPProvider(which delegates to the underlying provider) - Add DeepSeek-specific thinking mapping in
applyThinkingControl - Add DeepSeek to
thinkingControlKindwith a new kind for its thinking + reasoning_effort fields
Let me look at more of the provider.go to understand the full structure:
- Add
Assistant
Now let me understand the complete picture by looking at the full
applyThinkingControlandthinkingControlKindfunctions, and how the request body is built:Assistant
Now I have a clear picture. I need to:
- Add
SupportsThinking()toHTTPProvider- as mentioned in the issue description, it should expose the thinking capability of the delegate - Add DeepSeek to
thinkingControlKind- return a new kind like"deepseek_thinking" - Extend
applyThinkingControlto handle DeepSeek's specific thinking 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"thinking_level: "low"/"medium"→thinking: { "type": "enabled" }+reasoning_effort: "high"(as per DeepSeek's compatibility behavior)
- Add tests covering both request shaping and fallback/rewrite paths
Let me also check if there's a
SupportsThinkingthat the delegate already has, or if I need to add it toopenai_compat.Providertoo:- Add
Assistant
So
openai_compat.Providerdoesn't haveSupportsThinking. I need to add it. Let me also look at how the fallback and other providers work:Assistant
Good. Now let me check if the
isDeepSeekHostfunction is used:Assistant
Now I have a complete picture. Let me also check the
SetProviderNameonHTTPProvider:Assistant
Now I have a complete understanding. Let me plan the implementation:
-
In
openai_compat/provider.go:- Add
SupportsThinking()method toProvider- returnstruefor DeepSeek provider - Modify
thinkingControlKind()to return"deepseek_thinking"for DeepSeek - Modify
applyThinkingControl()to handle the"deepseek_thinking"case with full level mapping
- Add
-
In
httpapi/http_provider.go:- Add
SupportsThinking()method that delegates to the underlying provider
- Add
Let me implement these changes:
-
Assistant
Now I have a clear understanding. Let me implement the changes:
- Modify
thinkingControlKind()to add DeepSeek detection - Modify
applyThinkingControl()to handle all DeepSeek thinking levels - Add
SupportsThinking()to bothopenai_compat.ProviderandHTTPProvider - Add tests
Let me start implementing:
- Modify
Assistant
Good, the
applyThinkingControlis updated. Now I need to updatethinkingControlKindto add DeepSeek:Assistant
Good. Now I need to add
SupportsThinking()method to theopenai_compat.Provider. Let me find a good place to add it:Assistant
Now I'll add
SupportsThinking()method afterSupportsNativeSearch():Assistant
I need to look at the exact context around line 820 to get the precise search string.
Assistant
Now I need to add
SupportsThinking()to theHTTPProviderinhttpapi/http_provider.go. Let me add it:Assistant
Now let me verify the changes compile correctly:
Assistant
Now let me run the existing tests to make sure nothing is broken:
Assistant
All existing thinking-related tests pass. Now let me add tests for the new DeepSeek thinking mapping. Let me look at the test file structure:
Assistant
Now I need to add tests for DeepSeek thinking mapping. Let me find the end of the test file or a good place to add the tests:
Assistant
Let me add tests for DeepSeek thinking mapping. I'll insert them after the existing thinking-related tests (after line 125):
Assistant
Now let me run all the new DeepSeek thinking tests:
Assistant
All tests pass. Now let me also run all the existing tests to make sure I didn't break anything:
Assistant
All tests pass. Let me also run the httpapi tests:
Assistant
Let me also run the full provider tests to make sure nothing is broken:
Assistant
All tests pass. Now let me also verify the
ThinkingCapableinterface is properly implemented by checking the agent package:Assistant
All agent thinking tests pass too. Let me also run the full test suite to make sure everything still works:
Assistant
The only failing test is
TestShellTool_TimeoutKillsChildProcesswhich is inpkg/tools- unrelated to my changes. This is a pre-existing test failure (likely a timing issue with child process timeout in the test environment).Let me verify by checking that the providers and agent tests all pass:
Assistant
All provider and agent tests pass. Let me review the changes I made:
Assistant
cd /picoclaw && git diff
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.