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 exploring the repository structure to understand how it's organized and find the relevant files for implementing the DeepSeek thinking mapping feature.
Assistant
Let me explore the relevant files. The issue mentions
pkg/providers/httpapi/http_provider.goand theSupportsThinking()interface. Let me look at the provider structure.Assistant
The user wants me to implement DeepSeek thinking mapping in the PicoClaw repository. Let me continue exploring the relevant files to understand the current implementation and then implement the fix.
I've already found:
- The relevant directory structure for providers
- The httpapi directory where the http_provider.go file lives
- The openai_compat directory which handles OpenAI-compatible providers
Let me explore the httpapi directory and the openai_compat provider to understand how thinking is currently handled.
Assistant
I need to explore the relevant files. Let me start by reading the http_provider.go file to understand the current implementation.
Assistant
Let me use the bash terminal to read the file instead.
Assistant
Let me look at the openai_compat provider since the HTTPProvider delegates to it. I need to understand how thinking is currently handled there.
Assistant
Let me explore more of the codebase to understand the full picture.
Assistant
Let me look at the types file and the factory to understand how providers are created and how
SupportsThinkingis defined.Assistant
Now let me look at the factory and how providers are created, particularly for DeepSeek.
Assistant
Now let me look at the factory_provider.go to understand how DeepSeek is configured:
Assistant
I need to understand the full picture. Let me look at:
- How
SupportsThinking()is implemented for the HTTPProvider / openai_compat Provider - How other providers (like Anthropic) handle thinking
- What the
ThinkingCapableinterface looks like - How the factory creates providers and handles thinking
Let me look at more of the factory_provider.go to understand the DeepSeek creation path.
- How
Assistant
Let me look at how the
SupportsThinking()interface is used and ifopenai_compat.ProviderorHTTPProviderimplements it:Assistant
Now I have a clearer picture. Let me look at the complete
thinkingControlKindfunction and the fullapplyThinkingControl:Assistant
Now I have a good understanding of the codebase. Let me look at a few more files to understand how
SupportsThinkingis used throughout:Assistant
Now let me read the agent/thinking.go to understand how
ThinkingCapableis used:Assistant
Let me also look at the existing tests to understand the test patterns used:
Assistant
Let me look at the full existing thinking-related tests and the complete applyThinkingControl function:
Assistant
Now I have a comprehensive understanding of the codebase. Let me outline my plan:
Current State:
openai_compat.Providerhandles OpenAI-compatible providers (including DeepSeek)applyThinkingControlonly handlesthinking_level: "off"for certain providersThinkingCapableinterface exists withSupportsThinking() bool- currently only Anthropic and Gemini implement itHTTPProviderwrapsopenai_compat.Providerbut doesn't implementThinkingCapable
What needs to be done:
- Add DeepSeek-specific thinking mapping in
applyThinkingControl(non-off levels →thinking+reasoning_effort) - Make
openai_compat.ProviderimplementThinkingCapablefor DeepSeek - Make
HTTPProvideralso implementThinkingCapable - Add tests
Let me start implementing:
Assistant
Now I have a complete understanding of the codebase. Let me implement the solution step by step.
First, let me verify the current state of the DeepSeek detection methods in the provider:
Assistant
Now I have a complete understanding. Let me implement the solution step by step.
Plan:
- Update
openai_compat/provider.go- Add DeepSeek-specific thinking mapping andSupportsThinking() - Update
httpapi/http_provider.go- AddSupportsThinking()delegation - Add comprehensive tests
Let me start with the provider implementation:
- Update
Assistant
Now I have a clear understanding of the code. Let me implement the solution step by step.
Step 1: Update
openai_compat/provider.goto add DeepSeek thinking mapping andSupportsThinking().Assistant
Now I have a comprehensive understanding of the code. Let me implement the solution step by step.
Summary of current state:
openai_compat.Provideris the delegate for DeepSeek (viaHTTPProvider)applyThinkingControlonly handlesthinking_level: "off"for certain providers (volcengine, zhipu, zai, qwen, modelscope)ThinkingCapableinterface exists butopenai_compat.ProviderandHTTPProviderdon't implement it- For DeepSeek,
thinkingControlKindreturns""so even "off" doesn't work
Implementation plan:
- Add
isDeepSeekProvider()helper to detect DeepSeek - Update
applyThinkingControlto handle DeepSeek non-off levels (map tothinking+reasoning_effort) - Add
SupportsThinking() booltoopenai_compat.Provider(returns true for DeepSeek) - Add
SupportsThinking() booltoHTTPProvider(delegates to inner) - Add tests
Let me start implementing:
Assistant
Now I have a clear picture. Let me implement the solution step by step.
Step 1: Update
openai_compat/provider.goto add DeepSeek thinking mapping andSupportsThinking()method.Assistant
Let me now implement the solution. I'll start by modifying the
openai_compat/provider.gofile.Assistant
Now I have a clear picture of the code. Let me implement the solution step by step.
Step 1: Update
openai_compat/provider.go- ExpandapplyThinkingControlfor DeepSeek and addSupportsThinking()method.Assistant
Let me use the
replacecommand instead for multi-line text:Assistant
Let me try a different approach - I'll use bash to edit the file directly:
Assistant
Let me try a different approach. I'll create a Python script to modify the file, or use sed to make the changes.
Assistant
Let me verify the changes were applied correctly and then update the
thinkingControlKindfunction to return "deepseek" for DeepSeek providers.Assistant
Now I need to update the
thinkingControlKindfunction to return "deepseek" for DeepSeek providers. Let me see the full function:Assistant
Now I need to update the
thinkingControlKindfunction to return "deepseek" for DeepSeek providers:Assistant
Let me verify the changes and then update the
httpapi/http_provider.goto addSupportsThinking()delegation:Assistant
The changes to
openai_compat/provider.golook correct. Now I need to updatehttpapi/http_provider.goto addSupportsThinking()delegation:Assistant
Now I need to add
SupportsThinking()delegation tohttpapi/http_provider.go:Assistant
Let me verify the changes and run the existing tests:
Assistant
Now let me verify the code compiles:
Assistant
The build failed due to missing Go module cache. Let me check what's available for building.
Assistant
The user wants me to continue working on the repository. Let me check if there's a GOPATH or GOMODCACHE set up and try to build/test the code.
Assistant
Let me check for environment variables and try to set up Go module cache properly.
Assistant
The user wants me to continue working. Let me set up Go module cache and try to build/test the code.
Assistant
Let me set up all required Go environment variables:
Assistant
The code compiles successfully. Now let me run the existing tests to make sure my changes don't break anything:
Assistant
The test failure shows that my change to
applyThinkingControlnow processes ALL levels (not just "off") for non-DeepSeek providers, which breaks the expected behavior. The test expects that for volcengine/doubao with non-off levels like "low", thethinkingfield should NOT be set.I need to fix this - only "off" levels should disable thinking for non-DeepSeek providers, while DeepSeek gets the full mapping.
Assistant
Let me verify the changes and run the tests again:
Assistant
Now let me run the tests again to verify the fix works:
Assistant
All existing tests pass. Now I need to add comprehensive tests for the DeepSeek thinking mapping. Let me look at the existing test file structure:
Assistant
Let me look at the end of the test file to see where I should add the new tests:
Assistant
The user wants me to continue working. I need to add tests for the DeepSeek thinking mapping. Let me add comprehensive tests to the provider_test.go file.
Assistant
Now let me run the tests to verify all the new DeepSeek thinking tests pass:
Assistant
All 18 DeepSeek-related tests pass. Let me run the complete test suite for the openai_compat package to make sure nothing is broken:
Assistant
All tests pass. Now let me run the broader provider package tests to make sure nothing is broken:
Assistant
All provider tests pass. Let me also run the agent tests to make sure the
ThinkingCapableinterface integration works correctly:Assistant
All tests pass. Let me verify the httpapi tests specifically pass since we added
SupportsThinking()there:Assistant
All tests pass. Let me now verify the complete implementation by reviewing the final state of the key files:
Assistant
The implementation is complete. Let me verify the thinking integration in the agent works correctly with our changes:
Assistant
The integration with the agent's
ThinkingCapableinterface is working correctly. When a DeepSeek provider is used:HTTPProvider.SupportsThinking()delegates toopenai_compat.Provider.SupportsThinking()openai_compat.Provider.SupportsThinking()returnstruefor DeepSeek- The agent's
applyThinkingOptions()passesthinking_levelto options applyDeepSeekThinking()maps the level to DeepSeek'sthinking+reasoning_effortfields
Let me run a full build to confirm everything compiles:
Assistant
The build error about
workspace: no matching files foundis a pre-existing issue unrelated to my changes. Let me verify my changes are complete by checking the modified files:Assistant
Let me verify all the changes are correct and complete:
Assistant
The implementation is complete. Let me summarize what I've done:
Summary of Changes
1.
pkg/providers/openai_compat/provider.go- Modified
applyThinkingControl: DeepSeek now gets full thinking-level mapping (bothoffand enabled levels), while non-DeepSeek providers only getoffhandling (as before) - Added
applyDeepSeekThinking: Maps internalthinking_levelvalues to DeepSeek's OpenAI-compatible fields:off→thinking: {type: "disabled"}+ removesreasoning_efforthigh→thinking: {type: "enabled"}+reasoning_effort: "high"low/medium→thinking: {type: "enabled"}+reasoning_effort: "high"xhigh→thinking: {type: "enabled"}+
- Modified
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.