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
There's already an
isDeepSeekHostfunction. Let's view that section for context (requiresToolRoundReasoningReplay).Assistant
Good, this confirms it's just a pass-through wrapper. Now let's implement the changes in openai_compat/provider.go and http_provider.go.
Assistant
Now let's update
applyThinkingControlandthinkingControlKindto add DeepSeek mapping, and addSupportsThinking.Assistant
Now update
thinkingControlKindto return "deepseek" and addSupportsThinking()method.Assistant
Now add
SupportsThinking()toHTTPProviderin http_provider.go:Assistant
Now let's build and check for compilation errors.
Assistant
It's downloading dependencies since no module cache exists. Let's wait for this to complete, only building the relevant packages might be faster.
Assistant
Build succeeded. Now let's run the relevant tests.
Assistant
All existing tests pass. Now let's run agent tests too since thinking.go is used there.
Assistant
Now let's write a quick test script to verify the DeepSeek mapping behavior, without adding it to the test suite (just temp script), then check that it matches expectations. Actually better to add proper tests to provider_test.go per the issue's ask ("add tests covering both request shaping and fallback/rewrite paths"). Let's look at existing tests structure for similar off-tests and fallback tests near line 655-760.
Assistant
Now insert new tests after line 126 (before
TestProviderChat_ParsesToolCalls).Assistant
All new tests pass. Now let's run full test suite for providers and httpapi and agent packages once more to be safe.
Assistant
This diff looks good. Now let's check if there are other places that construct HTTPProvider/openai_compat where DeepSeek is set up specifically, to verify things wire together (e.g., provider factory / registry).
Assistant
This confirms provider.SetProviderName("deepseek") is set for the "deepseek" protocol, matching our
isDeepSeek()check. Let's run broader build/test to confirm nothing else broke.Assistant
Good - confirmed this error is pre-existing and unrelated to our changes. Let's just make sure the relevant packages build/test fine, which we've already confirmed.
Assistant
Let's view final diff summary.
Assistant
Now let's go through the checklist explicitly.
Assistant
All tests pass with
-count=1(no caching). Now going through the checklist:Assistant
The implementation looks complete and well-tested. Let me do a final review of the checklist items.
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. β This is a feature request, not a bug report with an error trace. I reproduced the gap by inspecting code:
openai_compat.Providerhad noSupportsThinking()method at all (so DeepSeek's non-off thinking levels were silently dropped bypkg/agent/thinking.go), andapplyThinkingControlhad no DeepSeek-specific mapping (only "off" handling for other providers). I confirmed this via code inspection before making changes. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. β I added
applyDeepSeekThinkingmappingoff/high/xhigh/low/mediumto DeepSeek'sthinking/reasoning_effortfields, addedSupportsThinking()on bothopenai_compat.Providerandhttpapi.HTTPProvider(matching the specified interface) so the agent loop forwards non-off levels, and verified via new unit tests that all mappings work as documented in the issue. -
I have thought about edge cases and made sure my fix handles them as well. β Handled: explicit
offalways applied even without relying onSupportsThinking()(matches existing agent-loop behavior); DeepSeek detection via both explicit provider name and API host (covers fallback/alternate-endpoint scenarios per the issue's mention of PR #2898's pattern); unrecognized levels (adaptive, unknown strings) are left untouched instead of erroring, consistent with existing behavior for other providers;nilreceiver safety inHTTPProvider.SupportsThinking(). -
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. β Ran
go test ./pkg/providers/... ./pkg/agent/...with-count=1(no cache) and all packages pass, including the pre-existing DeepSeek reasoning-replay tests and thinking-level tests for other providers (Doubao/Qwen), confirming no regressions.
-
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 β
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 β