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 to understand the structure and locate relevant files related to DeepSeek and thinking_level mapping. Let's first get an overview.
- Assistant
Let me explore the directory structure to understand the codebase better, particularly looking for DeepSeek and thinking_level related code.
- Assistant
No files with "deepseek" in the name. Let me search for deepseek in the codebase.
- Assistant
Let me also search for thinking_level related code:
- Assistant
Let me examine the key files - the openai_compat provider and the thinking-related code:
- Assistant
Let me read more of the file, focusing on thinking-related code:
- Assistant
Let me read the thinking-related functions more closely:
- Assistant
Let me check the test file to understand existing tests:
- Assistant
Let me search for deepseek-specific tests and thinking tests:
- Assistant
Let me read more of the test file around the deepseek tests:
- Assistant
Let me continue reading to see the assertion:
- Assistant
Let me check if there are any existing tests for thinking levels with DeepSeek:
- Assistant
Let me look at the httpapi provider for
SupportsThinking: - Assistant
Let me search for
SupportsThinkingin the codebase: - Assistant
Let me look at the types.go file to understand the
SupportsThinkinginterface: - Assistant
Let me check the thinking.go file to understand how thinking_level is used:
- Assistant
Let me look at the thinking-related test file:
- Assistant
Let me look at the provider.go file more completely to understand the structure:
- Assistant
Let me search for how thinking levels are handled for non-off cases:
- Assistant
Let me check how Anthropic provider handles thinking levels:
- Assistant
Let me check the Gemini provider's handling of thinking levels:
- Assistant
Let me also look at how
SupportsThinkingis implemented in the openai_compat provider: - Assistant
Let me look at the test file to see how thinking control is tested:
- Assistant
Let me check how DeepSeek is instantiated in the factory:
- Assistant
Let me look at the factory_provider.go around line 195:
- Assistant
Let me check if there's a method to implement
SupportsThinkingin the openai_compat provider: - Assistant
Let me look at
SupportsNativeSearchto understand the pattern: - Assistant
Let me search for any existing DeepSeek-specific helpers:
- Assistant
Let me look at the isDeepSeekProvider function:
- Assistant
Now I understand the codebase. Let me check if there are any existing tests for the thinking control:
- Assistant
Now I have a good understanding of the codebase. Let me start implementing the changes. First, I'll add
SupportsThinking()method to the openai_compat Provider: - Assistant
Let me find where
SupportsNativeSearchis defined: - Assistant
Let me look at the surrounding code around line 794:
- Assistant
Now let me add the
SupportsThinking()method afterSupportsNativeSearch(): - Assistant
Now I need to modify
applyThinkingControlto handle non-off thinking levels for DeepSeek. Let me look at the current implementation: - Assistant
Now I'll modify
applyThinkingControlto handle DeepSeek thinking levels. Let me update it: - Assistant
I see there's an issue with the edit - the
normalizedThinkingLevelfunction got cut off. Let me check the current state of the file: - Assistant
I need to fix the
normalizedThinkingLevelfunction that got corrupted. Let me add it back: - Assistant
I see there's a duplicate line. Let me fix that:
- Assistant
Now I need to expose the
SupportsThinkingmethod through the HTTPProvider. Let me check the httpapi/http_provider.go file: - Assistant
Let me look at the HTTPProvider structure:
- Assistant
Now I'll add the
SupportsThinking()method to the HTTPProvider: - Assistant
Now let me run the existing tests to make sure I haven't broken anything:
- Assistant
Let me set up the environment properly:
- Assistant
Great! All existing tests pass. Now I need to add tests for the DeepSeek thinking control. Let me add tests to the provider_test.go file:
- Assistant
Let me find a good place to add the DeepSeek thinking tests. Let me look for the end of the thinking tests section:
- Assistant
Now I'll add DeepSeek thinking tests after the existing thinking tests:
- Assistant
Now let me run the tests to make sure they pass:
- Assistant
Let me run the tests again to see if there are any issues:
- Assistant
There's a syntax error. Let me check line 349:
- Assistant
Let me check around line 349 more carefully:
- Assistant
Let me check the exact line 349:
- Assistant
Let me check lines around 128-130 where I inserted the tests:
- Assistant
I see the issue. I accidentally replaced the body of
TestProviderChat_ParsesToolCalls. Let me fix this by looking at the original test: - Assistant
I need to restore the original
TestProviderChat_ParsesToolCallsfunction. Let me do that: - Assistant
Good, I've restored the original file. Now let me add the DeepSeek tests properly, without replacing existing functions. Let me find a good place to insert them:
- Assistant
Let me find the end of that function:
- Assistant
Let me add the DeepSeek tests after line 126:
- Assistant
Now let me run the tests to see if they pass:
- Assistant
There's still an issue. Let me check line 320:
- Assistant
I see the issue - I accidentally duplicated the function declaration. Let me fix this:
- Assistant
Let me revert the test file and start fresh:
- Assistant
Let me try a different approach. Let me find the exact location and use a simpler method:
- Assistant
Let me create a Python script to insert the tests properly:
- Assistant
Now let me run the tests to see if they pass:
- Assistant
Excellent! All the new tests pass. Now let me run all the tests in the package to make sure I haven't broken anything:
- Assistant
Perfect! All tests pass. Now let me also run the tests for the httpapi package to make sure the SupportsThinking method works correctly:
- Assistant
Great! All tests pass. Now let me also run the agent tests to make sure the thinking integration works correctly:
- Assistant
Perfect! All tests pass. Now let me also run the thinking-specific tests:
- Assistant
Great! All tests pass. Now let me also check if there are any tests in the factory_provider_test.go that might be affected:
- Assistant
Let me run the tests for the factory_provider package properly:
- Assistant
Excellent! All tests pass. Now let me check the changes I've made so far by running
git diff: - Assistant
Let me see the full diff to make sure everything looks correct:
- Assistant
The changes look good! Let me now create a simple test script to verify the behavior end-to-end:
- Assistant
The
buildRequestBodymethod is unexported (lowercase). That's fine - the tests we added in the package test file can access it. The important thing is that all the tests pass. Let me now run a broader set of tests to make sure nothing is broken: - Assistant
There's one test failure in
pkg/tools-TestShellTool_TimeoutKillsChildProcess. This seems to be a flaky test related to process timeout handling, not related to my changes. Let me check if this test was already failing before my changes: - Assistant
Good, the test was already failing before my changes. Let me restore my changes:
- Assistant
Good, my changes are restored. Now let me run the specific tests that are relevant to my changes to make sure they all pass:
- Assistant
Great! All tests pass. Now let me also check if there are any other tests that might be affected by my changes. Let me also check if there are any tests that test the
SupportsThinkinginterface: - Assistant
Let me also check if there are any tests for the
tool_schema_transform.gofile that might be affected: - Assistant
Let me run the providers package tests:
- Assistant
Let me run the full test suite for the providers package to make sure everything is working:
- Assistant
Perfect! All tests pass. Now let me create a summary of the changes I made:
- Assistant
Let me also check if there are any tests in the agent package that test the thinking integration:
- Assistant
Let me now run the agent tests to make sure everything passes:
- Assistant
Perfect! All tests pass. Now let me check if there are any other provider tests that might be affected:
- Assistant
Excellent! All tests pass. Now let me clean up the temporary files:
- Assistant
Perfect! Now let me submit my changes. Let me first double-check the changes are correct:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.