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 issue at hand. The goal is to implement DeepSeek thinking mapping for the
thinking_levelabstraction in PicoClaw. I need to:- Explore the repository structure
- Understand how other providers handle thinking_level mapping
- Implement the DeepSeek-specific request shaping
- Test the changes
Let me begin by exploring the repository.
Assistant
Let me find the relevant files for HTTP API providers and DeepSeek.
Assistant
The cache files are not useful. Let me focus on the actual source files.
The issue mentions
pkg/providers/httpapi/http_provider.goandSupportsThinking(). Let me explore that path.Assistant
Let me read the main http_provider.go file first to understand the structure.
Assistant
Let me read the main http_provider.go file to understand how thinking is handled.
Assistant
Now let me look at the openai_compat provider:
Assistant
Let me see more of the file, especially the
SupportsThinkingmethod and the completeapplyThinkingControl:Assistant
Now let me see the full file from line 196 to line 280 to understand the current
applyThinkingControlandthinkingControlKindmethods in detail.Assistant
Now let me look at the types.go and understand the interface:
Assistant
Now let me find where
SupportsThinkingis defined and where DeepSeek provider is configured:Assistant
Let me look at the types.go to understand the interface and then find where DeepSeek is configured.
Assistant
Now I understand the structure. Let me look at:
- How DeepSeek is currently configured/used
- The test file to understand the expected behavior
- Where the
SupportsThinking()method is implemented for HTTPProvider
Let me check if there's a
SupportsThinkingon HTTPProvider or if it's missing.Assistant
Now let me see how DeepSeek provider is created/configured:
Assistant
Let me look at how DeepSeek is created/used in the factory and see the full provider.go file:
Assistant
Let me look at the factory_provider.go to understand how DeepSeek is created:
Assistant
Now let me see the test file for the openai_compat provider to understand the test patterns:
Assistant
Now I have a clear understanding. Let me read the full provider.go to see the complete structure:
Assistant
Let me see the rest of the provider.go file and the SupportsThinking method:
Assistant
Now I see the structure. Let me also check if there's a
SupportsThinkingmethod on the openai_compat Provider:Assistant
So the
SupportsThinking()method doesn't exist on theopenai_compat.Provider. Let me look at the GeminiProvider to see how it implements it:Assistant
Now I have a clear understanding of the codebase. Let me read the test file for existing thinking tests and the complete
applyThinkingControlarea:Assistant
Now I have a clear understanding of the codebase. Let me summarize:
openai_compat.ProviderhasapplyThinkingControlthat currently only handlesthinking_level: "off"thinkingControlKindreturns the kind of thinking control based on provider- DeepSeek needs:
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"
- HTTPProvider needs a
SupportsThinking()method
Let me first read the complete existing
applyThinkingControlmethod:Assistant
Now I have a clear understanding. Let me implement the solution:
- Extend
applyThinkingControlinopenai_compat/provider.goto handle DeepSeek's thinking fields for non-"off" levels - Add
SupportsThinking()method toopenai_compat.Providerfor DeepSeek - Add
SupportsThinking()method tohttpapi.HTTPProvider
Let me start by modifying the
applyThinkingControlfunction inopenai_compat/provider.go:- Extend
Assistant
Let me check how
adaptiveis handled elsewhere in the codebase:Assistant
Let me check the thinking.go file to understand the full context:
Assistant
Now I have a complete understanding. The key issue is:
applyThinkingOptioninthinking.goonly passesthinking_levelwhen provider implementsThinkingCapableandSupportsThinking()returns true- DeepSeek doesn't implement this interface yet, so its thinking control is being ignored for non-"off" levels
- The
applyThinkingControlmethod only handles "off" - it needs to handle "high"/"xhigh" for DeepSeek too
Let me implement the solution:
Assistant
Let me see the end of the file to understand where the SupportsThinking method should be added:
Assistant
Now I have a complete picture. Let me implement the changes step by step:
- First, extend
applyThinkingControlinopenai_compat/provider.goto handle DeepSeek thinking mapping for non-"off" levels - Add
SupportsThinking()method to the Provider inopenai_compat/provider.go - Add
SupportsThinking()method to HTTPProvider inhttpapi/http_provider.go - Add tests
Let me start:
- First, extend
Assistant
Now let me implement the changes. First, I'll modify the
applyThinkingControlfunction to handle DeepSeek thinking mapping:Assistant
The edit command failed because I used the wrong parameter format. Let me try again with the correct format.
Assistant
Let me use the
replacecommand instead:Assistant
Let me use a different approach - I'll use
bashto directly create a modified version of the file:Assistant
Let me try a different approach. I'll create the new code in a file and use
sedor similar to do the replacement.Assistant
Let me try a different approach - I'll construct the new file using bash commands.
Assistant
Let me try the edit command with the correct parameter name.
Assistant
The
edittool seems to have issues. Let me use a different approach - I'll create a complete patch usingbashand apply it.Assistant
Let me use
bashwithsedto perform the replacement:Assistant
I need to construct the file correctly. Let me create the new version of lines 205-259 and then append the rest.
Assistant
Now let me append the rest of the file from line 260 onwards:
Assistant
The user is asking me to continue working on the issue. Let me check the current state of the file I created and also add the
SupportsThinking()method to the provider.Assistant
Good, now let me verify the changes and add the
SupportsThinking()method. First let me check the file:Assistant
Good, the first part of the changes is in place. Now I need to:
- Check the rest of the thinkingControlKind function to make sure it's correct
- Add the
SupportsThinking()method to the Provider - Add the
SupportsThinking()method to the HTTPProvider - Add tests
Let me continue checking the file and then add the remaining changes.
Assistant
Let me verify that
isDeepSeekHostexists in the file:Assistant
Good,
isDeepSeekHostalready exists. Now let me add theSupportsThinking()method to theopenai_compat.Provider. Let me check the end of the file:Assistant
Now let me add the
SupportsThinking()method to theopenai_compat.Provider. I need to append it before the last closing brace:Assistant
The user seems to be waiting for me to continue with the task. Let me add the
SupportsThinking()method to the openai_compat.Provider and then to the HTTPProvider, then add tests.Assistant
Let me check if those helper functions already exist:
Assistant
I need to check if
isZhipuHost,isZaiHost, andisMimoHostexist:Assistant
Those functions don't exist. Let me simplify the
SupportsThinking()method:Assistant
I need to fix the
SupportsThinking()method to not use non-existent helper functions. Let me replace it:Assistant
Now I need to add the corrected version with the SupportsThinking method. Let me replace the broken version.
Assistant
Now let me copy the fixed file back and verify it compiles.
Assistant
Let me try to compile the code to see if there are any issues.
Assistant
The build cache is not set up. Let me try to set the environment and try again.
Assistant
The openai_compat package compiles. Now let me also check the httpapi package and add
SupportsThinking()to HTTPProvider:Assistant
The user wants me to continue with the task. I need to add the
SupportsThinking()method to the HTTPProvider in http_provider.go. Let me do that now.Assistant
Now let me verify the httpapi package compiles correctly:
Assistant
Good, both packages compile. Now let me verify the entire project builds and run existing tests:
Assistant
The build is downloading dependencies. Let me wait for it to complete and check if there are any compilation errors.
Assistant
The build completed with one minor issue about a missing workspace file (not related to my changes). Let me now run the existing tests for the openai_compat provider to verify my changes don't break anything:
Assistant
I see the test failure. The test expects that for non-DeepSeek providers (like Volcengine/Doubao with "thinking_type"), only the "off" level should trigger any thinking field changes. My change incorrectly extended the non-"off" handling to all provider types.
Let me re-read the test to understand the expected behavior and fix my implementation:
Assistant
I see the issue. The test expects that for non-DeepSeek providers, only the "off" level triggers thinking changes. Non-"off" levels should NOT set thinking fields for those providers. I need to fix my implementation to only handle non-"off" levels for the DeepSeek-specific case.
Assistant
I see the issue. The test expects that for non-DeepSeek providers, only the "off" level triggers thinking changes. Non-"off" levels should NOT set thinking fields for those providers (like Volcengine/Doubao). I need to fix my implementation to only handle non-"off" levels for the DeepSeek-specific case.
Assistant
Now I need to append the rest of the file from line 260 onwards, and then add the SupportsThinking method. Let me do this in steps.
Assistant
Let me continue with the task. I need to add the
SupportsThinking()method to the provider and then copy the fixed file.Assistant
Let me copy the fixed file back and verify it compiles and tests pass.
Assistant
The user hasn't specified what to do next. Let me continue verifying my changes by checking the file compiles and running tests.
Assistant
There are compilation errors. Let me check what went wrong in the file construction:
Assistant
Assistant
Let me look at the file to understand the structure.
Assistant
Assistant
Let me check the original file's line numbers for the
normalizedThinkingLevelandthinkingControlKindfunctions.Assistant
Let me check the current state of the file and verify the structure.
Assistant
I can see the problem now. There's a stray
}and a duplicatethinkingControlKindfunction in the file. My file construction was incorrect - I includedthinkingControlKindin my heredoc, but then appended the original file content which also hadthinkingControlKind. Let me fix this properly.Assistant
Let me take a more careful approach. I'll use Python to construct the new file properly.
Assistant
The replacement worked. Now let me verify the file compiles and add the
SupportsThinking()method.Assistant
Good, the file compiles. Now let me verify the thinking control tests pass.
Assistant
All existing thinking tests pass. Now let me add the
SupportsThinking()method to theopenai_compat.Providerand the HTTPProvider. Let me first check the current state of the file:Assistant
Good, the file ends cleanly. Now let me add the
SupportsThinking()method to the openai_compat.Provider.Assistant
Now let me verify it compiles and check the HTTPProvider.
Assistant
Now let me check the HTTPProvider already has the
SupportsThinking()method I added earlier:Assistant
The
SupportsThinking()method is already in the HTTPProvider. Let me verify the httpapi package compiles:Assistant
Let me verify the HTTPProvider and run all the tests.
Assistant
Let me run the full test suite for the openai_compat package to verify everything works:
Assistant
All tests pass. Now let me add tests for the new DeepSeek thinking mapping functionality. Let me create a test file:
Assistant
Let me run the tests to verify they compile and pass:
Assistant
All DeepSeek thinking tests pass. Let me run the full test suite to make sure nothing is broken:
Assistant
All tests pass. Now let me also add a test for the HTTPProvider's SupportsThinking method:
Assistant
The user hasn't specified what to do next. Let me run the tests for the httpapi package to make sure they pass.
Assistant
All tests pass. Now let me run the broader test suite to make sure nothing is broken elsewhere.
Assistant
The failure in
TestShellTool_TimeoutKillsChildProcessis unrelated to my changes - it's a flaky shell timeout test. Let me verify the tests related to my changes pass:Assistant
All provider tests pass. Let me run them without cache to confirm:
Assistant
All provider tests pass. Let me verify the final state of my changes and submit:
Assistant
Let me review the final changes and verify everything is correct.
Assistant
Let me verify the HTTP provider changes:
Assistant
I have made all the necessary changes to implement the DeepSeek thinking mapping feature. Let me submit the solution now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.