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
- Ask users to configure DeepSeek manually with
extra_body - Keep DeepSeek on the generic OpenAI-compatible path without provider-specific thinking mapping
Both alternatives are weaker because they make DeepSeek behavior inconsistent with the project-wide
thinking_levelabstraction.💬 Additional Context
https://api-docs.deepseek.com/zh-cn/guides/thinking_mode
DeepSeek's documented OpenAI-compatible thinking controls use:
thinking.typereasoning_effortreasoning_contentin responses
PR #2898 is closely related because it establishes the explicit-
offbehavior and provider-specific request shaping pattern. DeepSeek appears to still need its own mapping added on top of that work.Interface
Type: Function Name: SupportsThinking Path: pkg/providers/httpapi/http_provider.go Input: () Output: bool Description: Exposes the thinking capability of the underlying provider delegate over the HTTP API. Returns true if the delegate supports thinking; otherwise false.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /picoclaw, current file: none) bash-$
- explicit
- Assistant
I'll start by exploring the repository structure to understand the codebase and locate relevant files. Let's first get an overview.
- Assistant
Let me look at the repository structure more broadly to understand the codebase.
- Assistant
Let me look at the pkg directory structure, especially for providers and HTTP API related code.
- Assistant
Let me look at the providers directory structure.
- Assistant
Let me look at the relevant files. First, let me find where
SupportsThinkingis defined and where DeepSeek is handled. - Assistant
Let me look at the httpapi directory and the types.
- Assistant
Let me look at the OpenAI-compatible provider and the thinking-related code:
- Assistant
Let me also look at the httpapi directory and the thinking-related code:
- Assistant
Now let me look at the thinking-related files to understand how thinking is handled in the codebase.
- Assistant
Now let me look at the provider types to understand the SupportsThinking interface:
- Assistant
Let me look at the provider metadata to understand how DeepSeek is handled:
- Assistant
Now let me look at the
applyThinkingControlmethod more closely and see how DeepSeek is currently handled. Let me also look at the existing tests for thinking control: - Assistant
Let me look at the thinkingControlKind function more closely:
- Assistant
Now I need to look at the test file for OpenAI-compatible provider to understand existing patterns:
- Assistant
Now let me check if DeepSeek currently has any special handling in the codebase. Let me search for DeepSeek in the thinking-related code:
- Assistant
Let me check what tests already exist for DeepSeek and thinking:
- Assistant
Now let me check if DeepSeek currently has any handling in the thinkingControlKind function:
- Assistant
Let me check if there's a SupportsThinking method in the HTTP provider:
- Assistant
Let me look at how providers are created in the factory:
- Assistant
Let me look at the factory_provider.go to understand how DeepSeek is created:
- Assistant
Let me look at the factory creation for the deepseek case:
- Assistant
Now let me look at how thinking_level is applied in the agent to understand the full flow:
- Assistant
Now I have a good understanding of the codebase. Let me check if there are any existing tests for DeepSeek thinking control:
- Assistant
Now I understand the full picture. Let me create a plan and implement the changes:
- Update
thinkingControlKindto include DeepSeek as"deepseek_thinking" - Update
applyThinkingControlto handle all thinking levels for DeepSeek (not just "off") - Add
SupportsThinkingto HTTPProvider so the agent knows DeepSeek supports thinking - Add tests for DeepSeek thinking mapping
Let me start by implementing the changes:
- Update
- Assistant
Let me also check the
applyThinkingControlfunction more closely: - Assistant
Now I understand the full picture. Let me implement the changes step by step.
Step 1: Add DeepSeek to
thinkingControlKind - Assistant
Now I'll modify the
thinkingControlKindfunction to add DeepSeek support: - Assistant
Let me check if there's already an
isDeepSeekHostfunction: - Assistant
Good, there's already an
isDeepSeekHostfunction. Let me see what it does: - Assistant
Now I'll update the
thinkingControlKindfunction in the actual file: - Assistant
Let me use the edit command to replace the function:
- Assistant
Let me check what the file looks like now:
- Assistant
I accidentally deleted too much. Let me restore the file from git:
- Assistant
Now let me use the
editcommand to make targeted changes. First, let me open the file: - Assistant
Let me find the exact line numbers for the functions I need to modify:
- Assistant
Let me find where the function ends:
- Assistant
Now I'll use the edit command to replace the function:
- Assistant
Now I need to update the
applyThinkingControlfunction to handle all thinking levels for DeepSeek. Let me look at the current function: - Assistant
Now I'll update the
applyThinkingControlfunction to handle all thinking levels for DeepSeek: - Assistant
Now I need to add
SupportsThinkingto HTTPProvider so the agent knows DeepSeek supports thinking. Let me look at the current HTTPProvider: - Assistant
Now I need to add a
SupportsThinkingmethod to HTTPProvider. Let me check if there's a way to get the provider name from the delegate: - Assistant
I need to add a method to the openai_compat provider to expose thinking support, then delegate from HTTPProvider. Let me add the method:
- Assistant
Let me add a
SupportsThinkingmethod to the openai_compat provider near the end of the file: - Assistant
Let me look at the
applyThinkingOptionfunction more carefully: - Assistant
Let me see more of this function:
- Assistant
Let me check how the provider is used in the factory and what the
ThinkingCapableinterface looks like: - Assistant
Now I need to add a
SupportsThinkingmethod. Let me add it to the openai_compat provider first: - Assistant
I'll add a
SupportsThinkingmethod afterSupportsNativeSearch: - Assistant
I see there's an issue - I accidentally replaced the closing brace of
SupportsNativeSearch. Let me fix that: - Assistant
Let me try again more carefully. First, let me restore and open the file:
- Assistant
Let me try a more careful approach. First, let me find the exact line numbers again:
- Assistant
Let me see what's around line 794:
- Assistant
Now I'll add the
SupportsThinkingmethod afterSupportsNativeSearch. I'll insert it between lines 796 and 797: - Assistant
I see there's still an issue - there's no blank line between the
SupportsNativeSearchfunction and the newSupportsThinkingfunction. Let me fix that: - Assistant
I see there's still an issue - there's no blank line between the
SupportsThinkingfunction and theisNativeOpenAIOrAzureEndpointfunction. Let me fix that: - Assistant
Wait, there's a problem with my
SupportsThinkingimplementation. ThethinkingControlKindmethod takes amodelparameter, but I'm calling it with an empty string. This means it will check the provider name, but for some providers (like "modelscope"), the thinking control kind depends on the model. Let me fix this: - Assistant
Now I need to update the
applyThinkingControlfunction and thethinkingControlKindfunction. Let me do that now: - Assistant
Let me update the
applyThinkingControlfunction: - Assistant
Now I need to update the
thinkingControlKindfunction to add DeepSeek support. Let me do that: - Assistant
Now I need to add
SupportsThinkingto the HTTPProvider. Let me update the HTTPProvider file: - Assistant
Now I need to add a
SupportsThinkingmethod to the HTTPProvider. Let me add it after theSupportsNativeSearchmethod: - Assistant
Now I need to add a
SupportsThinkingmethod. Let me add it after theSupportsNativeSearchmethod: - Assistant
Now let me also check the
tool_schema_transform.gowrapper: - Assistant
Good, the
tool_schema_transform.goalready has aSupportsThinkingmethod that delegates to the underlying provider. This will automatically work with our changes.Now let me run the tests to see if everything works:
- Assistant
Let me set up the environment and run the tests:
- Assistant
Let me continue to see all tests:
- Assistant
All tests pass. Now let me add tests for DeepSeek thinking mapping. Let me add them to the test file:
- Assistant
Let me find where to add the DeepSeek thinking tests. Let me look for existing thinking tests:
- Assistant
Let me look at what's after the existing thinking tests:
- Assistant
Now I'll add DeepSeek thinking tests after line 126. Let me add tests for all thinking levels:
- Assistant
I notice there's a missing blank line after line 126. Let me fix that:
- Assistant
Good, now let me run the tests to see if they pass:
- Assistant
Excellent! All the DeepSeek thinking tests pass. Now let me run all the tests to make sure I didn't break anything:
- Assistant
All tests pass. Now let me run the tests for the httpapi package as well:
- Assistant
All tests pass. Now let me also run the agent tests to make sure the thinking logic works correctly:
- Assistant
Let me check if there are any tests related to thinking in the agent package:
- Assistant
Let me check what tests exist in the agent package:
- Assistant
Let me run the thinking-related tests in the agent package:
- Assistant
Let me try running all tests in the agent package:
- Assistant
All tests pass. Now let me also run the factory provider tests to make sure everything works:
- Assistant
Let me check if there are any tests in the providers package that might be affected:
- Assistant
All tests pass. Now let me add a test to verify that the
SupportsThinkingmethod works correctly for DeepSeek: - Assistant
Let me add tests for
SupportsThinkingafter theSupportsNativeSearchtests: - Assistant
Let me add tests for
SupportsThinkingafter line 2000: - Assistant
I see there's a missing blank line before the
TestProviderChat_NativeSearchToolInjectedtest. Let me fix that: - Assistant
Now let me run all the tests again to make sure everything passes:
- Assistant
All tests pass. Now let me run the agent tests again to make sure everything works:
- Assistant
All tests pass. Now let me also check the
applyThinkingOptionfunction in the agent to make sure it will work correctly with our changes. Let me also check if there are any edge cases I need to handle: - Assistant
Let me check if there are any other wrappers that might need updating:
- Assistant
Let me check the
tool_schema_transform.goto make sure it delegates correctly: - Assistant
Good, the
tool_schema_transform.goalready delegates correctly. Let me now run the factory provider tests to make sure everything works: - Assistant
All tests pass. Let me also run the factory provider tests:
- Assistant
The factory_provider_test.go build failure is pre-existing and not related to my changes. Let me verify by running the tests properly:
- Assistant
All tests pass. Let me now verify the code compiles correctly:
- Assistant
Let me wait for the build to complete:
- Assistant
The build error is not related to my changes - it's about a missing
workspacedirectory. Let me check if there's aworkspacedirectory: - Assistant
The build error is not related to my changes. Let me just run the tests for the specific packages I modified:
- Assistant
All tests pass. Let me now review the changes I made and create a summary. Let me check the git status:
- Assistant
Let me view the changes I made:
- Assistant
I notice there's a missing blank line. Let me fix that:
- Assistant
Let me find the missing blank line. Let me look at around line 234-240:
- Assistant
I see there's a missing blank line between line 238 and 239. Let me fix that:
- Assistant
Good, now the blank line is fixed. Let me run the tests one more time to make sure everything passes:
- Assistant
Let me try a different approach to run the tests:
- Assistant
All tests pass. Let me now run all tests one more time to make sure everything is working correctly:
- Assistant
All tests pass. Let me now review the checklist from the issue description:
Checklist
1. If an error was reported in the issue description, I have successfully reproduced it.
Not applicable - This is a feature request, not an error report. The issue asks for DeepSeek thinking mapping to be implemented.
2. If an error was reported in the issue description, I have confirmed that my fix resolves the error.
Not applicable - Same as above.
3. I have thought about edge cases and made sure my fix handles them as well.
Yes - I considered:
- DeepSeek provider name detection
- DeepSeek API base host detection
- All thinking levels (off, low, medium, high, xhigh, adaptive)
- The agent's
applyThinkingOptionfunction behavior - Wrappers like
tool_schema_transformthat delegate to the underlying provider
4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
Yes - I ran:
go test ./pkg/providers/openai_compat/- All tests passgo test ./pkg/providers/httpapi/- All tests passgo test ./pkg/agent/- All tests passgo test ./pkg/providers/...- All tests pass
The changes I made are complete and all tests pass. Let me submit the changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →