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 for implementing DeepSeek thinking mapping. Let's first look at the repository layout.
- Assistant
Let me look at the structure more broadly, especially focusing on the provider paths mentioned in the issue description.
- Assistant
Let me look for the provider files in the source code.
- Assistant
Let me look at the providers directory structure.
- Assistant
Let me look at the key files: the http_provider.go (mentioned in the issue), the openai_compat provider, and the types to understand the current thinking_level handling.
- Assistant
Let me explore the repository structure more, focusing on the providers directory and thinking-related code.
- Assistant
Let me look at the openai_compat provider to see how thinking levels are handled.
- Assistant
Let me see the full
applyThinkingControlandthinkingControlKindfunctions more completely. - Assistant
Let me look at the full
thinkingControlKindfunction and the area around it: - Assistant
Now let me look at the test file for the openai_compat provider to understand the existing test patterns:
- Assistant
Now I have a good understanding of the codebase. Let me check if there's a
SupportsThinkingmethod somewhere: - Assistant
Let me look at the types to understand the ThinkingCapable interface and SupportsThinking method.
- Assistant
Let me also look at the httpapi package more fully:
- Assistant
Now I need to check what the
SupportsThinkingmethod inhttpapi/http_provider.golooks like. Let me also look at the provider_catalog.go to understand how DeepSeek is configured: - Assistant
Let me look at the provider_metadata.go file to see how providers are registered, and how DeepSeek is configured.
- Assistant
Now let me look at the thinking-related code to understand how thinking levels are processed in the agent layer:
- Assistant
Now I have a good understanding of the codebase. Let me look at the existing tests related to DeepSeek and thinking:
- Assistant
Let me look at the thinking-related tests:
- Assistant
Let me check if there are any host detection functions for DeepSeek:
- Assistant
Let me see the context around these DeepSeek functions:
- Assistant
Now I understand the codebase well. Let me also check if there's a helper function to detect if the provider is DeepSeek:
- Assistant
Now let me look at the full
applyThinkingControlandthinkingControlKindfunctions: - Assistant
Now I have a clear picture of the codebase. Let me understand what needs to be done:
- Currently,
applyThinkingControlonly handles the "off" case - it returns early if the level is not "off". - For DeepSeek, I need to handle both "off" and enabled levels.
- DeepSeek needs
thinkingfield withtype: "disabled"for off, andthinkingfield withtype: "enabled"plusreasoning_effortfor enabled levels.
The current
thinkingControlKindreturns different kinds for different providers:thinking_typefor volcengine, zhipu, zaienable_thinkingfor qwen, modelscope (with qwen model)
For DeepSeek, I need to add a new kind or modify the existing logic to handle DeepSeek's specific mapping.
Looking at the suggested mapping:
- Currently,
- Assistant
Now I have a complete understanding. Let me also look at how the
applyThinkingControlis called and the full pattern. Let me also check for MiMo's handling since it's related to DeepSeek: - Assistant
Now I have a complete understanding. Let me run the existing tests first to establish a baseline:
- Assistant
Need to set up environment for Go.
- Assistant
Now I have a complete understanding. Let me now implement the changes. Here's my plan:
- Modify
thinkingControlKindto return a new kind"deepseek_thinking"for DeepSeek providers - Extend
applyThinkingControlto handle all thinking levels (not just "off") for DeepSeek - Add
SupportsThinking()method to bothopenai_compat.Providerandhttpapi.HTTPProviderso DeepSeek is recognized as thinking-capable - Add tests covering DeepSeek thinking mapping
Let's start implementing:
- Modify
- Assistant
Now let me implement the changes. First, modify
thinkingControlKindto include DeepSeek: - Assistant
Now let me implement the changes. First, I'll modify
thinkingControlKindto add the DeepSeek case: - Assistant
Now let me check if the openai_compat provider already has a
SupportsThinkingmethod: - Assistant
Now I understand the full picture. Let me implement the changes. I'll start with modifying
thinkingControlKindto add DeepSeek support: - Assistant
Let me use the line-range approach:
- Assistant
Now let me edit the
thinkingControlKindfunction to add DeepSeek support: - Assistant
Let me try using sed to make the changes instead:
- Assistant
I'll use sed to insert the DeepSeek case into the switch statement.
- Assistant
Now let me verify the change and also add the DeepSeek host check for the fallback case.
- Assistant
Now I need to add the DeepSeek host check in the fallback case (where providerName == "openai" || ""). Let me add it:
- Assistant
Now I need to add the DeepSeek host check in the fallback case. I'll insert it after the Volcengine check:
- Assistant
Let me verify the change:
- Assistant
The sed insertion went wrong. Let me fix this properly by replacing the entire function with a correct version. Let me first see the exact lines and then write the correct content:
- Assistant
Let me revert the file to its original state and start over with proper edits:
- Assistant
Let me verify the file is back to its original state:
- Assistant
Good, back to original. Now let me use a Python script to make the changes properly:
- Assistant
Now let me add a
SupportsThinkingmethod to the openai_compat Provider so that DeepSeek is recognized as thinking-capable: - Assistant
Now I need to add a
SupportsThinkingmethod to the HTTPProvider in the httpapi package: - Assistant
Good. Now let me verify the changes to both files:
- Assistant
Let me check the
applyThinkingControlfunction: - Assistant
Now I need to check if the SupportsThinking method was added properly. Let me look for it:
- Assistant
Let me check the SupportsThinking method:
- Assistant
Now let me check the httpapi/http_provider.go file:
- Assistant
The changes look good. Now let me run the existing tests to make sure we haven't broken anything:
- Assistant
All existing tests pass. Now let me also run the httpapi package tests:
- Assistant
All existing tests pass. Let me also run the full providers test suite:
- Assistant
All tests pass. Now I need to add tests covering the DeepSeek thinking mapping. Let me add tests to the openai_compat/provider_test.go file:
- Assistant
Let me add tests for the DeepSeek thinking mapping:
- Assistant
Now let me run the new tests to make sure they pass:
- Assistant
Let me run all the new tests including the ones for thinking level mapping:
- Assistant
All tests pass. Now let me run the full test suite to make sure we haven't broken anything:
- Assistant
All tests pass. Now let me also check if there are any facades that need updating to expose
SupportsThinking: - Assistant
Let me look at the tool_schema_transform.go to understand how it delegates:
- Assistant
Let me check the rest of this file:
- Assistant
Good. The tool_schema_transform.go already properly delegates SupportsThinking() to the underlying provider via interface assertion. Now let me check the facade files:
- Assistant
The facade already uses type aliases so the
SupportsThinking()method is already exposed through the facade. Let me also check the facade test: - Assistant
Now let me check the agent thinking code to ensure DeepSeek will properly receive the thinking_level option:
- Assistant
The implementation looks correct. Let me verify the complete picture by checking that the
thinking_leveloption will properly flow through for DeepSeek. Let me also run the agent tests to make sure nothing breaks: - Assistant
All tests pass. Let me now review the final state of all changes:
- Assistant
Let me view the full diff to review all changes:
- Assistant
The diff looks clean and correct. Let me now run the complete test suite one more time to make sure everything is working:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.