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 issue is about mapping
thinking_levelto DeepSeek-specific thinking fields. Let me explore the repository structure first.Assistant
Let me explore the relevant files mentioned in the issue description. Let's look at the key files:
Assistant
Let me look at the key files. Let's start with the OpenAI-compatible provider and the thinking type definitions:
Assistant
Let me see the rest of the file, and also look at the test
Assistant
Let me get the rest of the file, starting from where we left off.
Assistant
Let me also look at the test file for the OpenAI-compatible provider and the thinking.go file in agent
Assistant
Let me now look at the factory provider to see how DeepSeek is set
Assistant
Let me get the full factory_provider.go to understand how DeepSeek is configured.
Assistant
Let me see the full
applyThinkingControlandthinkingControlKindfunctionsAssistant
Let me look at lines 196-280 of the provider.go file.
Assistant
Let me also check what
isDeepSeekHostdoes and how DeepSeek is detected. Let me also look at the HTTP provider that wraps this.Assistant
Let me also look at the
SupportsThinkingfunction and how DeepSeek's thinking support is determinedAssistant
Let me look at the HTTP provider to see how it handles Supports
Assistant
Let me search for where
SupportsThinkingis defined for the HTTP provider / OpenAI compatAssistant
Let me check if there's a
SupportsThinkingon the HTTP provider or if it needs oneAssistant
Let me look at the thinking.go in agent package to understand the thinking_level flow
Assistant
Let me look at how the thinking options flow from agent to provider. Let me check the pipeline_llm.go
Assistant
Let me look at the Gemini provider to see how it handles thinking
Assistant
Let me look at the git log for recent changes related to thinking
Assistant
Let me look at the changes from PR #2898 to understand the pattern
Assistant
Let me look at what that PR changed in the openai_compat provider
Assistant
Let me look at the thinking.go changes from PR #2898
Assistant
Let me look at how thinking controls flow in pipeline_llm.go
Assistant
Let me look at the types and the HTTPProvider to see if it can implement SupportsThinking
Assistant
Let me check what methods the openai_compat Provider has
Assistant
Let me search for deepseek in the test file and any related existing
Assistant
Let me check how extra_body flows through and if there's a direct path for thinking_level
Assistant
Now I have a thorough understanding. Let me implement the changes. Here's my plan:
-
openai_compat/provider.go:- Add
"deepseek"tothinkingControlKind(both provider name and host-based detection) - Modify
applyThinkingControlto handle non-"off" levels for deepseek with proper mapping - Add
SupportsThinking()method
- Add
-
httpapi/http_provider.go:- Add
SupportsThinking()method delegating to the underlying provider
- Add
-
openai_compat/provider_test.go:- Add tests for deepseek thinking control mapping
Let me start by modifying the `openai_compat/provider
-
Assistant
Now let me modify the
applyThinkingControlfunction to handle DeepSeek for all levels:Assistant
Let me edit the
applyThinkingControlfunction to handle all levels for deepseekAssistant
I need to open the file first.
Assistant
Now let me modify
applyThinkingControl:Assistant
Now let me add
deepseekto `thinkingControlKindAssistant
Now let me add the
applyDeepSeekThinkingControlandSupportsThinkingmethods. Let me add them afterapplyThinkingControl:Assistant
Let me verify the inserted code looks right:
Assistant
I need to add a blank line before
normalizedThinkingLevel. Let me fix that:Assistant
Let me fix the comment formatting for
SupportsThinking:Assistant
Let me verify the comments look correct:
Assistant
Good, the provider.go changes look correct. Now let me add
SupportsThinkingto the HTTP provider:Assistant
Now let me add
SupportsThinkingto the HTTP provider:Assistant
Let me add a blank line before
SetProviderName:Assistant
Let me look at the exact content around line 99-100:
Assistant
Let me fix with the proper indentation:
Assistant
Let me try using
editwith specific line numbers:Assistant
Now let me add tests. Let me open the test file:
Assistant
Let me find the end of the thinking-related tests:
Assistant
Let me add the deepseek thinking tests after the existing thinking tests. I'll insert them after line 126
Assistant
Now let me run the tests to make sure everything
Assistant
Let me set up a cache directory and try again
Assistant
All new tests pass. Let me also run the full test suite for the affected packages to make sure nothing is
Assistant
Let me also run the httpapi tests:
Assistant
Let me also run the agent thinking tests:
Assistant
All thinking tests pass. Let me run the full test suite for the providers package and the agent package:
Assistant
All provider tests pass. Let me run the agent tests
Assistant
Let me also verify the entire project builds:
Assistant
The build error is unrelated to our changes (it's a pre-existing issue with a missing
workspacedirectory). Let me verify the packages we changed compile correctlyAssistant
Let me view the full diff of our changes:
Assistant
Let me also verify the
tool_schema_transformproperly delegatesSupportsThinkingAssistant
All tests pass and the implementation is complete. Let me do a final summary verification
Assistant
All tests pass across all three affected packages. Here's a summary of what was implemented:
Changes Summary
1.
pkg/providers/openai_compat/provider.go-
Modified
applyThinkingControl: Restructured to support DeepSeek's full thinking level mapping (not just "off"). For DeepSeek, it now delegates to a newapplyDeepSeekThinkingControlmethod. For other providers, behavior is unchanged (only handles explicit "off"). -
Added
applyDeepSeekThinkingControl: New method mapping internalthinking_levelvalues to DeepSeek's OpenAI-compatible fields:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.