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
Let me look at the relevantdirectory structure.
Assistant
Now I see the file mentionedin the issue. The interface mentioned is
SupportsThinkinginpkg/providers/httpapi/http_provider.go. Let me look at the openai_compat package.Assistant
Now let me look at the truncated portion of the provider.go to understand what else is there.
Assistant
Let me look at the test file to understand what's already tested.
Assistant
Now let me look at related test code and also see how the SupportsThinking feature might be implemented.
Assistant
Now let me look at the PR #2898 mentioned in the issue to understand the existing pattern.
Assistant
Now let me understand how DeepSeek is currently set up. Let me look at the DeepSeek references and the agent pipeline to see the thinking logic.
Assistant
Now let me look at the agent.go or related files to see how the provider is called with these options.
Assistant
Let me look at the anthropic provider to see how it handles thinking levels.
Assistant
Now let me also look at how the gemini provider handles thinking and the
SupportsThinking()method.Assistant
Now let me also check the existing tests pattern more thoroughly.
Assistant
Now let me check how the http_provider.go (the one mentioned in the issue) is used to register the HTTPProvider.
Assistant
Let me look at the gemini_provider_test.go file to understand the pattern.
Assistant
Now I have a clear picture. Let me also look at how the
SupportsThinkingmethod is tested and called.Assistant
Let me also see the openai_compat tests for the thinking off behavior.
Assistant
Now let me also look at how the model provider option knows about deepseek default api base:
Assistant
Now I have a clear picture. Let me check the structure of the codebase once more and then start implementing.
Assistant
Let me first look at the exact lines I need to modify in openai_compat/provider.go.
Assistant
Let me first reproduce the issue with a quick test to confirm the current behavior.
Assistant
Let me create a temporary test file inside the package to verify the current behavior.
Assistant
I've confirmed the issue. The current behavior is that no thinking fields are added for DeepSeek, regardless of the
thinking_levelvalue. Now let me implement the fix.Assistant
Now let me modify the
openai_compat.Providerto add DeepSeek-specific thinking mapping.Assistant
Now let me add the
SupportsThinking()method to theopenai_compat.Provider. Let me see the existingSupportsNativeSearchmethod and addSupportsThinkingnext to it.Assistant
I need to add a blank line between the
SupportsThinking()function and the next comment.Assistant
There's a duplicate line at 864. Let me remove it.
Assistant
I removed too many lines. Let me re-add the missing lines.
Assistant
The file is in a bad state. Let me look at the entire file and rewrite the broken section.
Assistant
The file is now corrupted. Let me restore it from git and start over.
Assistant
Now let me re-apply my changes carefully, this time using a simpler approach with a single edit.
Assistant
There's a duplicate line at 820. Let me remove it.
Assistant
Now let me re-apply the applyThinkingControl changes. Let me find the current state of the file:
Assistant
Now let me carefully edit the function with a single replace operation.
Assistant
I see, the file uses tabs. Let me redo this using actual tabs.
Assistant
Now let me also add the "deepseek" handling in
thinkingControlKind:Assistant
Now let me verify the SupportsThinking method is also correctly placed.
Assistant
Now let me verify the file compiles correctly.
Assistant
Now let me run the existing tests to make sure I haven't broken anything:
Assistant
All existing tests pass. Now let me verify the fix with my reproduction script:
Assistant
Excellent! The implementation is working correctly:
off→thinking: {type: "disabled"}high→thinking: {type: "enabled"}+reasoning_effort: "high"xhigh→thinking: {type: "enabled"}+reasoning_effort: "max"low/medium/adaptive→reasoning_effort: "high"(no thinking.type field)- No thinking_level → no thinking fields (preserves existing behavior)
SupportsThinking()returnstruefor DeepSeek
Let me also test that the
HTTPProvider.SupportsThinking()needs to be added. Let me also add it:Assistant
Now let me add the
SupportsThinking()method onHTTPProvider:Assistant
Let me also verify the build:
Assistant
That's a pre-existing issue unrelated to my changes. Let me build only the relevant packages.
Assistant
The providers package builds cleanly. Now let me write proper tests to validate the new functionality. Let me check the existing test patterns again:
Assistant
Now let me add tests for the new DeepSeek thinking behavior. Let me find a good place to add them:
Assistant
Now let me add the new tests after the existing thinking-related tests in the test file:
Assistant
All my new tests pass. Now let me run all the existing tests in the openai_compat package to make sure I haven't broken anything:
Assistant
All tests pass. Now let me also add tests for the
HTTPProvider.SupportsThinking()method in the httpapi package:Assistant
Let me check if there's already a test file for HTTPProvider:
Assistant
Let me create a test file for HTTPProvider:
Assistant
The sanity check is unnecessarily strict. Let me remove it.
Assistant
All tests pass. Now let me also run the full agent tests to make sure my changes don't affect the agent's thinking logic:
Assistant
All agent tests pass. Let me also run the full providers tests:
Assistant
All provider tests pass. Let me also check whether I should handle the case where the apiBase is empty:
Assistant
Let me also test the agent-level integration to ensure the full flow works.
Assistant
Let me verify that the tool_schema_transform wrapper correctly forwards SupportsThinking:
Assistant
Let me verify end-to-end by running an integration test:
Assistant
There's an import cycle. Let me remove this test and put the integration test in httpapi instead.
Assistant
All tests pass. Now let me also think about edge cases:
-
Case sensitivity: Should
ThinkingLevel: "OFF"(uppercase) also work? Let me check. -
Extra body override: If user has
extra_bodyconfigured withreasoning_effort, should our thinking control take precedence? Looking at the code:
-
Assistant
Let me check the case sensitivity of the thinking level handling:
Assistant
Case sensitivity works correctly via the existing
normalizedThinkingLevelfunction. Let me clean up the temp test.Assistant
Now let me also test what happens with extra_body override:
Assistant
Let me also test the behavior with extra_body to verify the override logic:
Assistant
extra_body correctly overrides the thinking_level-derived defaults. Let me clean up the temp tests:
Assistant
Let me also look at how the openai-compat tests for
extra_bodymight interact with my change. Let me run a broader test to make sure everything works:Assistant
The only failure is
TestShellTool_TimeoutKillsChildProcess, which is unrelated to my changes. Let me verify it's a pre-existing issue:Assistant
The
TestShellTool_TimeoutKillsChildProcessfailure is a pre-existing issue unrelated to my changes. Let me run the full providers and agent tests one more time to verify:Assistant
All tests pass. Let me also look at the full view of my changes to make sure they are correct:
Assistant
Let me clean up the import grouping in the test file:
Assistant
All tests pass. Let me also clean up the temporary scripts:
Assistant
Let me also run the linter to ensure the code is clean:
Assistant
The only vet warning is pre-existing. Let me verify it's unrelated to my changes:
Assistant
Confirmed - the vet warning is pre-existing and unrelated to my changes. Let me also run all the related tests in verbose mode:
Assistant
All tests pass. Let me now look at the full final state of the changes:
Assistant
Let me re-verify the final state of all files and run the tests one more time:
Assistant
Now let me also check whether the openai_compat test file has the new tests correctly formatted:
Assistant
All tests are properly formatted. Let me run a final comprehensive test to make sure everything works:
Assistant
All tests pass. Let me also make sure the linter passes on my changes:
Assistant
All files are now properly formatted. Let me run the tests one final time to confirm everything works:
Assistant
All my new tests pass. Let me also check the wider test suite to make sure my changes don't break anything:
Assistant
The matrix and gateway failures are due to missing native dependencies (libolm). These are unrelatedto my changes.
Let me check the other FAIL:
Assistant
Confirmed - the failures in
pkg/channels/matrix,pkg/gateway,pkg/evolution, andpkg/tools/TestShellTool_TimeoutKillsChildProcessare pre-existing failures unrelated to my changes.Let me run a final summary check of the relevant tests:
Assistant
All relevant tests pass. Let me also do a final go vet check on my changes:
Assistant
All clean. Let me also do a final check on the file diffs:
Assistant
Let me also re-verify the final list of files I changed/added:
Assistant
Now let me run the final comprehensive test to confirm everything is working:
Assistant
All tests pass. Let me prepare a summary and review my final implementation:
Assistant
Now let me go over the final checklist:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.