[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_level abstraction 1:1.
Please implement correct DeepSeek thinking mapping so that:
If low / medium are kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map to reasoning_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 thinking and reasoning_effort fields
ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()
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
Assistant
Let me start by exploring the repository structure to understand the codebase.
Assistant
Now I have a good understanding of the existing code. Let me look at the entire applyThinkingControl and thinkingControlKind function to better understand:
Assistant
Now let me also check the http_provider.go and see where the SupportsThinking interface should be added:
Assistant
Now let's look at the gemini_provider for how SupportsThinking is implemented:
Assistant
Now let me look at the openai_compat provider to see if it has SupportsThinking:
Assistant
Let me look at the PR #2898 reference in the existing tests:
Assistant
Now I understand the existing code from PR #2898. Let me also examine the DeepSeek docs reference mentioned in the issue:
Assistant
Now let me look at the existing tests for applyThinkingControl:
Assistant
Now I have a clear understanding. Let me also check how the issue describes SupportsThinking and check where this needs to be added:
Assistant
Now I understand the design. The HTTPProvider in httpapi package is the wrapper that exposes the OpenAI-compat provider to the rest of the system. The SupportsThinking() method needs to be added to this wrapper.
The issue says:
Interface: SupportsThinking in 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."
So I need to:
Add SupportsThinking() to openai_compat.Provider (the delegate) that returns true for DeepSeek.
Add SupportsThinking() to HTTPProvider in httpapi/http_provider.go that delegates to the underlying provider.
Add DeepSeek-specific request shaping: when thinking_level is "off", "high", "xhigh", "low", or "medium", map to DeepSeek fields.
Let me first look at the test for SuppportsThinking and existing tests:
Assistant
I see. So when SupportsThinking() returns true for DeepSeek, the agent loop will pass the thinking_level to the provider options. So we need to add a SupportsThinking() method that returns true for DeepSeek.
Now let me check the gemini_provider.go to understand the pattern fully:
Assistant
Assistant
Now I understand. The SupportsThinking() method needs to be added to:
The openai_compat.Provider (delegate)
The HTTPProvider (in httpapi/http_provider.go)
For DeepSeek specifically, this should return true so that the agent will pass the thinking_level to the provider.
Let me design the solution:
Add SupportsThinking() to openai_compat.Provider: Returns true if the provider is DeepSeek.
Add SupportsThinking() to HTTPProvider: Delegates to the underlying provider.
Extend applyThinkingControl to handle DeepSeek's thinking fields:
off → thinking: { "type": "disabled" }
high → thinking: { "type": "enabled" } + reasoning_effort: "high"
low, medium → reasoning_effort: "high" (compatibility behavior)
Let me also check how to identify DeepSeek provider in the thinkingControlKind:
Assistant
Now let me write the plan and implement it:
Plan:
Add SupportsThinking() method to openai_compat.Provider that returns true if provider is DeepSeek (or known thinking-capable provider like Qwen, etc., or true for any OpenAI-compatible provider that uses OpenAI API directly).
Add SupportsThinking() method to HTTPProvider in httpapi/http_provider.go that delegates to the underlying provider.
Extend in to handle DeepSeek-specific request shaping:
Assistant
Now let me also check what provider.SupportsThinking() would return by default. Looking at the issue description, it says "Returns true if the delegate supports thinking; otherwise false." For DeepSeek, it should return true. For other generic OpenAI-compatible providers, it should likely return false (or it could be based on the provider name).
Let me also check if the openai-compat provider is the only thing passed to the HTTPProvider:
Assistant
Let me look at how factory_provider creates the providers to see the provider name being set:
Assistant
Good. The provider name is set via SetProviderName(protocol). So for DeepSeek, the provider name would be "deepseek". This is what we need to check for.
Now, let me run the existing tests to make sure I have a baseline:
Assistant
Tests pass. Let me also check the httpapi tests:
Assistant
Now let me first write a small reproduction script to demonstrate the missing functionality:
Assistant
Wait, BuildRequestBody is lowercase, let me check the function name:
Assistant
It's a private function. Let me create the reproduction script as a test file inside the package:
Assistant
Confirmed the issue. As expected, with the current code:
For "off": No thinking field is sent (this is the bug)
For "high": No thinking or reasoning_effort field is sent
For "xhigh": No thinking or reasoning_effort field is sent
Let me clean up the reproduction file before making the actual changes:
Assistant
Now let me make the changes:
Step 1: Add SupportsThinking() to openai_compat.Provider and extend applyThinkingControl to handle DeepSeek.
Let me view the current applyThinkingControl and thinkingControlKind functions one more time:
Assistant
Now let me design the new applyThinkingControl. I'll refactor it to be DeepSeek-aware, and add a new case to handle the full set of levels for DeepSeek:
Here's my plan:
Extend applyThinkingControl to handle DeepSeek-specific level mapping. I'll:
Add a check at the start: if the provider is DeepSeek, use the DeepSeek-specific logic which handles ALL levels (not just "off").
Keep the existing logic for other providers.
Add SupportsThinking() method to openai_compat.Provider that returns true if the provider is DeepSeek.
Add SupportsThinking() method to HTTPProvider in http_provider.go that delegates to the underlying provider.
Let me first refactor the applyThinkingControl function:
Assistant
Now let me design the new applyThinkingControl and add the SupportsThinking() method:
Now let me implement the changes. First, update applyThinkingControl to handle DeepSeek:
Assistant
Let me try the replace approach:
Assistant
Now let me verify the changes:
Assistant
The applyThinkingControl is updated. Now let me add the SupportsThinking() to the HTTPProvider:
Assistant
Now let me build and run the tests to make sure nothing is broken:
Assistant
There's an error related to embed pattern, but this seems unrelated to my change. Let me check:
Assistant
This is a pre-existing error because the workspace dir doesn't exist. Let me check:
Assistant
The workspace dir does exist. The issue must be relative to the package. Let me check more carefully:
Assistant
My changes build successfully. Let me run the relevant tests:
Assistant
All existing tests pass. Now let me create a temporary test script to verify the fix:
Assistant
All my tests pass. Let me clean up the reproduction file:
Assistant
Now let me think about edge cases and make sure my solution handles them well:
DeepSeek by provider name - Works ✓
DeepSeek by host - Works ✓
Non-DeepSeek provider with thinking_level - Should preserve existing behavior (don't change anything for non-off levels) - Let me check.
OpenAI provider with thinking_level: "off" - Existing behavior preserved.
Qwen provider with thinking_level: "off" - Existing behavior preserved.
Let me check the existing behavior to make sure my refactor doesn't break anything:
Assistant
Existing tests pass. Now let me run all the tests to make sure nothing is broken:
Assistant
All tests pass. Let me also run the agent tests to make sure my change doesn't break anything in the agent flow:
Assistant
All tests pass. Now let me also check if my changes affect the fallback behavior:
Assistant
Now let me also test the full integration to ensure my fix works end-to-end. Let me look at how the tests are run in the agent package for thinking:
Assistant
Now let me also think about additional edge cases. Let me check if there are any other places where I should consider adding tests:
Assistant
Now let me look at the test that already exists for applyThinkingControl (the existing tests):
Assistant
The existing tests still pass. The pattern in those tests is to test request shaping for specific providers. Let me check now if there are any issues with the test I should add. Per the issue, I should add tests covering both request shaping and the SupportsThinking() method.
Let me check what the issue says specifically about tests:
add tests covering both request shaping and fallback/rewrite paths if applicable
Let me also check what the applyThinkingOption and the test for thinking tests:
Assistant
Let me also test that the request is being properly sent when going through the HTTPProvider. Let me write an integration-style test:
Assistant
Both tests pass. Now let me clean up the temporary tests:
Assistant
Now let me re-check the issue requirements and ensure my solution fully addresses them. Let me re-read the issue:
✅ Add DeepSeek-specific request shaping on the OpenAI-compatible provider path
✅ Map internal thinking levels to DeepSeek's thinking and reasoning_effort fields
❓ Ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()
Let me check the third point. The issue says "ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()".
This means: even if SupportsThinking() returns false, the off should still be sent. Let me look at the current applyThinkingOption in pkg/agent/thinking.go:
Assistant
I see. The applyThinkingOption function:
Always sends thinking_level: "off" if level is off (regardless of SupportsThinking())
Sends other levels only if SupportsThinking() is true
So the "off" case is already always sent. The issue's wording "ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()" is describing this existing behavior.
But there's a subtle issue. My SupportsThinking() returns true for DeepSeek (in openai_compat.Provider), but what if the agent uses a different code path that doesn't pass through openai_compat.Provider directly? Let me think about this...
Looking at the agent code, the applyThinkingOption is called with the provider, and checks if it implements ThinkingCapable. Since HTTPProvider (in httpapi) wraps the openai_compat.Provider, and now both implement for DeepSeek, the agent will pass through the option correctly.
Assistant
Yes, the provider name is set to "deepseek" (lowercase). My isDeepSeekProvider() checks for that.
Now let me also think about the case where a user manually configures DeepSeek via the openai protocol with a custom api_base. In that case, the provider name would be "openai" and the apiBase would be https://api.deepseek.com/v1. My isDeepSeekProvider() handles this case via isDeepSeekHost().
Let me double check the isDeepSeekHost function:
Assistant
Assistant
Let me also re-check the diff to make sure everything looks clean:
Assistant
The diff looks good. Let me think about whether I should add tests. The issue says:
add tests covering both request shaping and fallback/rewrite paths if applicable
The instructions say I should NOT modify existing tests or add new tests. But the issue says I should add tests. Let me re-read the instructions:
UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests to the repository.
This will lead to an error in the system that evaluates your performance. Instead, you can just create a temporary script, use it to test changes and remove it before submitting.
So I should not add tests. The tests would be evaluated separately.
Let me also think about other edge cases. What about the case when the user has thinking_level: "high" set but the provider is NOT DeepSeek (e.g., a generic OpenAI-compatible provider)?
Assistant
Both WithProviderName and SetProviderName lowercase the name, so my implementation is safe. Even if not, my isDeepSeekProvider() does strings.ToLower(strings.TrimSpace(p.providerName)) to be safe.
Now let me also verify with a script to demonstrate the fix:
Assistant
buildRequestBody is not exported. Let me skip the demo script. Let me also think about whether the applyThinkingControl change might have any unintended consequences. Let me trace through all the tests again:
Assistant
All existing tests pass. Now let me also run the agent tests one more time:
Assistant
Let me also run the providers tests:
Assistant
All tests pass. Let me also verify the final state of the changes:
Assistant
Let me also think about a corner case. What happens when the user has thinking_level: "adaptive"? Let me check the issue:
Looking at the issue, it says adaptive is not in the suggested mapping. Let me check what should happen.
The normalizedThinkingLevel function accepts "adaptive" as a valid level, but the issue's mapping doesn't include it. So for DeepSeek, the "adaptive" case would not match any case in applyDeepSeekThinkingControl, and no fields would be set.
This might be problematic. Let me think about what "adaptive" should mean for DeepSeek. Looking at the issue's wording, it specifically says "high", "xhigh", "low", "medium" should be mapped. It doesn't say "adaptive".
Assistant
Assistant
So extraBody is merged in last, and overrides our defaults. This means:
If user has set extra_body: {thinking: {type: "enabled"}, reasoning_effort: "low"} for DeepSeek
And thinking_level: "high" is set
Then applyThinkingControl sets thinking: {type: "enabled"} and reasoning_effort: "high"
Then extraBody overrides to thinking: {type: "enabled"} and reasoning_effort: "low"
This is the expected behavior - user's explicit extra_body takes precedence.
Now let me also verify that the tests for extraBody still pass:
Assistant
Excellent! Now let me also check the isDeepSeekProvider to see if it works with the existing tests:
Assistant
All DeepSeek-related tests pass. Now let me also check the full test suite to make sure nothing is broken:
Assistant
All tests pass. Let me also do a final check to ensure my implementation is correct:
Assistant
Let me also check the final code once more:
Assistant
The code looks good. Let me also check whether the issue's suggested mapping for "low"/"medium" really should not set thinking.type: "enabled". Looking at the DeepSeek API docs more carefully...
Actually, looking at the issue more carefully:
thinking-enabled levels are translated to DeepSeek's documented OpenAI-compatible fields
This suggests that "high" and "xhigh" are thinking-enabled levels. And "low"/"medium" are NOT necessarily thinking-enabled levels per the issue (they just map to ). The issue might be saying that "low"/"medium" are not actually "enabled" but use the documented compatibility behavior (just setting ).
Assistant
All my edge case tests pass. Let me also check that the final state of the code is clean:
Assistant
The diff looks clean. Let me also do a final check by running the tests:
Assistant
All tests pass. Let me also think about whether I should run the larger test suite to ensure nothing is broken:
Assistant
There's a failure in TestShellTool_TimeoutKillsChildProcess, but this is unrelated to my changes. Let me check it:
Assistant
This test fails because of a timing issue with the shell timeout, not related to my changes. Let me verify it's failing without my changes:
Assistant
Confirmed - this test failure is unrelated to my changes. It happens without my changes too. This is a pre-existing flaky test.
Now let me also verify that I have addressed all the points in the issue. Let me re-read the issue's requirements:
PR #2898 is closely related because it establishes the explicit-off behavior 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 using git reset --hard command.
Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later.
Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands.
However you don't need to use git add or git commit before submitting your changes. In fact,
submit only submits currently unstaged changes because it uses git diff to 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-$
Now let me understand the full flow. The issue is specifically about adding DeepSeek thinking support, but the relevant question is: which method on the openai_compat.Provider and HTTPProvider should return true for SupportsThinking()?
Looking at the issue:
"ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()"
This means:
We need to add SupportsThinking() that returns true when configured for DeepSeek, so the thinking_level options will be passed through.
AND, we need to make sure the "off" case is sent even when SupportsThinking() is not advertising thinking support.
Let me trace through the flow again. Looking at applyThinkingOption in thinking.go:
If settings.level == ThinkingOff → just sets opts["thinking_level"] = "off", no SupportsThinking check.
If settings.level != ThinkingOff and provider.SupportsThinking() is true → sets opts["thinking_level"] = "high", etc.
If settings.level != ThinkingOff and provider.SupportsThinking() is false → ignores it.
So for SupportsThinking() to be useful, it should return true for DeepSeek (and other providers that have thinking capability). Then the off-level case is already handled.
Now let me look at the existing PR 2898 behavior more carefully. The issue says:
"ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()"
This wording is a bit tricky. It says the off case should be sent even when SupportsThinking() returns false. This is already the case in applyThinkingOption since the off case is handled BEFORE the SupportsThinking check. So the off case is always sent regardless.
The point of the issue is to add the request shaping on the OpenAI-compatible provider path. The DeepSeek-specific behavior is:
"low", "medium" → reasoning_effort: "high" (the issue says to follow DeepSeek's documented compatibility behavior)
Now, let me understand the design. Currently applyThinkingControl only handles the "off" case. We need to extend it to handle all levels for DeepSeek.
Let me also check the issue's note about SupportsThinking(): "ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking()". This means that if a user has set thinking_level: "off" for DeepSeek, the off should be sent even if SupportsThinking() returns false. But the off is already always sent (line 89-92 of thinking.go). So this wording might be a bit of misdirection or simply stating the contract clearly.
Looking at the Interface section more carefully:
Interface: 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."
This is a method SupportsThinking() to be added on the HTTPProvider (in httpapi/http_provider.go) that returns bool. So the main task is to add this method to the HTTPProvider. The underlying delegate (openai_compat.Provider) also needs this method to be called. Let me think about this.
Let me look at how other providers use the SupportsThinking() interface:
applyThinkingControl
openai_compat/provider.go
For DeepSeek:
off → thinking: { "type": "disabled" }
high → thinking: { "type": "enabled" } + reasoning_effort: "high"
Add a new thinkingControlKind value like "deepseek" to identify the DeepSeek provider.
Add tests for:
DeepSeek request shaping for "off"
DeepSeek request shaping for "high" (thinking enabled + reasoning_effort: high)
DeepSeek request shaping for "xhigh" (thinking enabled + reasoning_effort: max)
DeepSeek request shaping for "low"/"medium" (reasoning_effort: high)
SupportsThinking() returns true for DeepSeek
Let me also check how SupportsThinking() should behave for non-DeepSeek OpenAI-compat providers. The issue is specifically about DeepSeek, but the request is to add SupportsThinking as a method on HTTPProvider. Let me re-read the issue...
PR #2898 is closely related because it establishes the explicit-off behavior and provider-specific request shaping pattern. DeepSeek appears to still need its own mapping added on top of that work.
The issue says SupportsThinking should be added to http_provider.go. This means it should return true for DeepSeek specifically.
But how should it behave for other providers? Let me look at how the openai-compat provider is used:
ThinkingCapable
thinking_level
Now, what if someone uses the openai_compat.Provider directly (not through HTTPProvider)? They would still have SupportsThinking() available, but only the openai_compat.Provider.SupportsThinking() would be called. This is fine.
Now let me think about an edge case: what if DeepSeek's provider name is set via the SetProviderName method? In the factory, the provider name is set to "deepseek" (the protocol). Let me verify:
Good, isDeepSeekHost matches api.deepseek.com and any subdomain.
Now let me also check what happens when the agent sees SupportsThinking() = true and the user has thinking_level: "off" set. Let me trace through:
Agent has thinking_level: "off" in config
applyThinkingOption is called with provider (the HTTPProvider)
Since level == ThinkingOff, it sets opts["thinking_level"] = "off" (regardless of SupportsThinking)
The provider's Chat() is called with opts["thinking_level"] = "off"
buildRequestBody is called
applyThinkingControl is called
Since level == "off" and provider is DeepSeek, applyDeepSeekThinkingControl is called
requestBody["thinking"] = {"type": "disabled"} is set
Now let me also check the thinking_level: "high" case:
Agent has thinking_level: "high" in config
applyThinkingOption is called with provider (the HTTPProvider)
Since level != ThinkingOff, it checks if provider is ThinkingCapable and SupportsThinking() == true
Since my change makes SupportsThinking() return true for DeepSeek, it sets opts["thinking_level"] = "high"
The provider's Chat() is called with opts["thinking_level"] = "high"
buildRequestBody is called
applyThinkingControl is called
Since level == "high" and provider is DeepSeek, applyDeepSeekThinkingControl is called
requestBody["thinking"] = {"type": "enabled"} and requestBody["reasoning_effort"] = "high" are set
Now let me check what happens for the low/medium case for DeepSeek. The issue says: "If low / medium are kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map to reasoning_effort: "high"."
Per the issue, low and medium should map to reasoning_effort: "high" (without setting thinking.type to enabled). This is what my implementation does. However, the question is: should thinking also be set to enabled for low/medium?
The issue says the mapping is JUST reasoning_effort: "high". So we don't set thinking.type for these. But this might mean DeepSeek defaults to enabled thinking. Let me think about this more carefully.
Actually, looking at the issue:
thinking-enabled levels are translated to DeepSeek's documented OpenAI-compatible fields
The thinking-enabled levels are: high, xhigh. low/medium are compatibility levels that just set reasoning_effort: "high". This is what the issue specifies.
However, this might be ambiguous. Let me re-read the issue:
thinking_level: "xhigh" -> thinking: { "type": "enabled" } + reasoning_effort: "max"
If low / medium are kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map to reasoning_effort: "high".
So the issue's suggested mapping is:
low/medium -> just reasoning_effort: "high" (no thinking.type set)
This is the most conservative interpretation. My implementation does this.
Now let me also check that the existing tests still pass:
applyThinkingOption would see level != ThinkingOff
It checks provider.SupportsThinking() - my SupportsThinking() returns false for non-DeepSeek providers
So thinking_level would not be set in opts
The provider's Chat() is called without thinking_level
applyThinkingControl is called but the level is not set, so it's a no-op
This is the correct behavior - the thinking option is ignored if the provider doesn't support it.
What about a generic OpenAI-compatible provider that has DeepSeek-like capabilities? This is harder to detect without explicit configuration. My implementation requires explicit DeepSeek provider name or DeepSeek host. This is correct per the issue.
Now let me also think about whether there could be any issue with the case where DeepSeek provider name is set to "DeepSeek" (capitalized) instead of "deepseek" (lowercase). Let me check:
However, "adaptive" is a valid internal level. Let me check how the original code handles it - it doesn't do anything for non-off levels (the original code returns early if level != "off"). So "adaptive" was also a no-op for the non-DeepSeek code path.
For DeepSeek specifically, the issue says nothing about "adaptive". To be safe and match the issue's suggested mapping, I should not add specific handling for "adaptive" (it would be a no-op).
Actually, looking at the issue more carefully, the mapping is for "thinking-enabled levels" - "high", "xhigh", "low", "medium" - but not "adaptive". The "adaptive" level is in normalizedThinkingLevel as a valid level but might not be widely used. Let me leave it as a no-op for now, which matches the issue's intent.
Wait, let me also reconsider. The issue says:
thinking-enabled levels are translated to DeepSeek's documented OpenAI-compatible fields
So thinking-enabled levels should be translated. If "adaptive" is a thinking-enabled level, then maybe we should treat it like "high" (the default). Let me think...
Actually, looking at the thinkingSettingsFromModelConfig, let me see what levels are possible:
So "adaptive" is a valid level. Let me check the issue more carefully to see if "adaptive" should be supported.
thinking_level: "xhigh" -> thinking: { "type": "enabled" } + reasoning_effort: "max"
If low / medium are kept as valid internal levels, they can follow DeepSeek's documented compatibility behavior and map to reasoning_effort: "high".
The issue doesn't mention "adaptive" in the suggested mapping. So I should leave it as a no-op for now, since the issue is specifically about high, xhigh, low, medium, off.
However, since "adaptive" is a valid internal level, perhaps it should map to something. Let me think... The "adaptive" level usually means "let the model decide". For DeepSeek, this could mean enabling thinking and not setting reasoning_effort (let DeepSeek decide). But the issue doesn't specify this.
To be safe, I'll leave "adaptive" as a no-op for DeepSeek, matching the issue's intent. If the user wants to be more permissive, they can manually add reasoning_effort via extra_body.
Actually wait, let me think again. If "adaptive" is sent to DeepSeek, what would happen?
If we don't set anything, DeepSeek would default to its standard behavior (which might or might not include thinking).
This is a no-op from our side, which is fine.
But what if the user expects "adaptive" to mean "enable thinking and let DeepSeek decide"? Then we'd need to set thinking: {"type": "enabled"} without setting reasoning_effort.
I think the safest interpretation is to follow the issue's suggested mapping exactly. So "adaptive" is a no-op for DeepSeek.
Let me also check the applyThinkingControl flow for non-DeepSeek providers. The non-DeepSeek code path:
level is normalized (e.g., "adaptive" → "adaptive")
If level is "off" and provider uses thinking_type or enable_thinking → set the disable field
If level is not "off" → return (no-op)
This is the existing behavior. My change preserves this for non-DeepSeek providers.
Now let me also think about what happens if the user has thinking_level: "adaptive" for DeepSeek. My code:
level is normalized to "adaptive"
isDeepSeekProvider() returns true
applyDeepSeekThinkingControl(requestBody, "adaptive") is called
None of the cases match (off, high, xhigh, low, medium)
No fields are set
This is consistent with the issue's mapping.
Let me also check the integration with the extra_body feature. What if the user has set extra_body: {thinking: {type: "enabled"}, reasoning_effort: "low"} for DeepSeek? My code adds the thinking fields first, then the extra_body is merged in. Let me check:
reasoning_effort: "high"
reasoning_effort
Looking at this more carefully, I think the issue's intent is:
off → explicitly disable thinking
high → enable thinking with high effort
xhigh → enable thinking with max effort
low/medium → set reasoning_effort: high (compatibility - no explicit thinking.type)
This is what I implemented. The behavior is:
If the user wants explicit off, use off
If the user wants high thinking, use high
If the user wants max thinking, use xhigh
If the user has low or medium, use the compatibility mapping
This is consistent with the issue.
Let me also double-check that my implementation properly handles the case when the user is using a custom OpenAI-compatible endpoint that happens to be DeepSeek-compatible but uses a different provider name. For example, if the user has set up a proxy that forwards to DeepSeek. In that case:
The apiBase would not match isDeepSeekHost
The provider name would be something else (e.g., "openai")
isDeepSeekProvider() would return false
The thinking fields would not be set
This is the correct behavior, since the user has explicitly set the provider to something other than DeepSeek.
If the user wants DeepSeek-like behavior, they should either:
Set the provider name to "deepseek"
Set the apiBase to https://api.deepseek.com/v1 (or a DeepSeek-compatible host)
My implementation handles both cases correctly.
Now let me also make sure the applyThinkingControl is correctly returning early for the non-DeepSeek case when level is not "off":
applyDeepSeekThinkingControl sets thinking: {"type": "disabled"} for "off"
thinking-enabled levels are translated to DeepSeek's documented OpenAI-compatible fields ✅
DeepSeek users can rely on the same thinking_level config without needing manual extra_body overrides ✅
The thinking_level is automatically translated to DeepSeek fields
Add DeepSeek request shaping on the OpenAI-compatible provider path ✅
Added in applyDeepSeekThinkingControl which is called from applyThinkingControl
Map internal thinking levels to DeepSeek's thinking and reasoning_effort fields ✅
Mapping is in applyDeepSeekThinkingControl
Ensure explicit off is sent even when DeepSeek does not advertise generic thinking support via SupportsThinking() ✅
The applyThinkingOption in pkg/agent/thinking.go always sends "off" regardless of SupportsThinking(). Additionally, my SupportsThinking() returns true for DeepSeek, so the option is forwarded.
Add tests covering both request shaping and fallback/rewrite paths if applicable
Per the instructions, I cannot add new tests. But I've verified the behavior with temporary scripts.
Add SupportsThinking method on http_provider.go ✅
Added in HTTPProvider.SupportsThinking()
Let me also verify that my implementation matches the suggested mapping from the issue:
Added SupportsThinking() method that returns true when the provider is configured for DeepSeek.
Added isDeepSeekProvider() helper that checks both the provider name and the API base host.
Let me also address the checklist from the instructions:
Checklist:
If an error was reported in the issue description, I have successfully reproduced it.
I created a reproduction script that demonstrated the missing functionality: for DeepSeek with thinking_level: "off", the request body was missing the thinking: {"type": "disabled"} field. After my fix, the field is present.
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
I verified the fix with my reproduction script. After the fix: