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 the codebase.
Assistant
I see that the issue mentions an interface for
SupportsThinking. Looking at the currenthttp_provider.go, it doesn't haveSupportsThinking()method. I need to add it.Let me look at the openai_compat provider to understand how thinking is handled.
Assistant
Let me see the rest of the file. The output was truncated.
Assistant
Now let me look at the existing test file and look for the
SupportsThinkingmethod.Assistant
Let me look at the existing tests to understand the test structure.
Assistant
Let me look at the existing tests around the deepseek and reasoning sections.
Assistant
Now let me check what tests exist for the deepseek and look at the existing http_provider tests, if any.
Assistant
Let me look at the full provider.go file structure to understand the applyThinkingControl and related functions better.
Assistant
Let me look at the git history for relevant changes.
Assistant
Let me look at the agent/thinking.go to see how
SupportsThinkingis used.Assistant
Now I have a much better understanding. Let me look at the rest of the agent_test.go related to thinkingRecordingProvider.
Assistant
Now let me understand the full set of providers that are handled:
Assistant
Let me look at the existing tests around the applyThinkingControl function.
Assistant
Now let me understand the test structure and existing tests for the
applyThinkingControlto understand how I should structure the new tests for DeepSeek.Assistant
Now let me also see how HTTPProvider is used to understand its configuration:
Assistant
Now let me check the existing test for the HTTPProvider to see if there is one:
Assistant
Let me also check the
isDeepSeekHostandisMiMoHostfunctions to understand the DeepSeek detection logic.Assistant
Let me check what tests exist for the HTTPProvider:
Assistant
Now I have a clear understanding. Let me start implementing the changes.
Plan:
- Modify
applyThinkingControlin/picoclaw/pkg/providers/openai_compat/provider.goto add DeepSeek-specific thinking mapping for all levels. - Add
SupportsThinking()method toopenai_compat.Providerthat returns true for DeepSeek-like providers. - Add
SupportsThinking()method tohttpapi.HTTPProviderthat delegates to the underlying provider. - Add tests for the request shaping and
SupportsThinking().
Let me first reproduce the current behavior:
- Modify
Assistant
Tests work. Let me write a small script to verify the current behavior for DeepSeek:
Assistant
Let me write a test file to verify current behavior:
Assistant
Let me look at the openai_compat tests to understand the test patterns better:
Assistant
Now let me start implementing the changes. First, let me modify the
openai_compat/provider.goto add DeepSeek thinking level mapping:Assistant
Now I'll modify the
applyThinkingControlfunction to support DeepSeek:Assistant
Let me try a different syntax with the edit command:
Assistant
Let me use the
replacecommand instead:Assistant
Let me use sed to make the changes:
Assistant
Now let me add the
SupportsThinkingmethod toopenai_compat.Provider. Let me find a good place to add it:Assistant
Let me add
SupportsThinking()toopenai_compat.Provider. I'll place it right afterSupportsNativeSearch():Assistant
Now let me add
SupportsThinking()tohttpapi.HTTPProvider:Assistant
Now let me verify the code compiles:
Assistant
The error is unrelated to my changes. Let me check if this is a pre-existing issue:
Assistant
This is a pre-existing build issue. Let me restore my changes:
Assistant
Now let me build only the provider packages to verify:
Assistant
The providers package builds fine. Now let me run the existing tests to make sure I didn't break anything:
Assistant
All existing tests pass. Now let me create a temporary test script to verify my new code works:
Assistant
All my tests pass. Now let me also test the HTTPProvider.SupportsThinking() method:
Assistant
All tests pass. Now let me also test the end-to-end Chat flow to make sure the DeepSeek thinking control is applied to actual chat requests:
Assistant
Now let me run the agent tests to make sure my changes don't break them:
Assistant
All agent tests pass. Now let me run the httpapi tests:
Assistant
All tests pass. Now let me run the providers tests to make sure they pass:
Assistant
All tests pass. Now let me clean up the temporary test files:
Assistant
Let me check my final changes:
Assistant
Let me also look at the buildRequestBody test to ensure no existing test breaks:
Assistant
All existing DeepSeek and thinking-related tests still pass. Let me also run the agent tests once more to be safe:
Assistant
All thinking-related tests pass. Now let me check if my implementation properly handles a few edge cases:
Assistant
All edge cases pass. Now let me clean up the temporary test files:
Assistant
Let me also check the httpapi_facade_test.go and provider_metadata.go to make sure I haven't missed anything related to the SupportsThinking interface:
Assistant
Let me look at how SupportsThinking is used in tool_schema_transform.go:
Assistant
Let me run all tests one more time to make sure everything still passes:
Assistant
All tests pass. Let me also verify the final state of the code:
Assistant
Let me see the final diff:
Assistant
Let me also search for any other places that might need attention:
Assistant
Let me run a comprehensive test to ensure everything is in order:
Assistant
The failing test is in
pkg/toolsand is unrelated to my changes. Let me verify it's a pre-existing issue:Assistant
Yes, this is a pre-existing failure unrelated to my changes. Let me restore my changes:
Assistant
My changes are intact. Let me run the providers and agent tests one more time to make sure they all pass:
Assistant
All tests pass. Let me also do a final sanity check by looking at the full diff one more time:
Assistant
Let me do one final check that everything is clean and ready to submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.