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
I'll start by exploring the repository structure and understanding the codebase.
Assistant
Let me see the full file, especially around the thinking control area:
Assistant
Now let me look at the existing tests for the openai_compat provider:
Assistant
Let me look at the git log and the related thinking control tests:
Assistant
Now let me understand the
SupportsThinkinginterface and how the HTTP provider exposes it. Let me look at the types and the httpapi package:Assistant
Let me look at the httpapi package and the facade to understand how providers are wired up:
Assistant
Let me look at the agent thinking logic and how it uses
SupportsThinking:Assistant
Let me look at how the HTTPProvider is wired and where provider name is set:
Assistant
Let me look at the fallback provider and how it handles thinking:
Assistant
Let me look at the agent pipeline and the thinking recording test:
Assistant
Now I understand the flow. Let me look at the existing agent test for thinking recording to understand expectations:
Assistant
Let me look at the fallback thinking tests in the agent test:
Assistant
Let me look at
CreateProviderandfinalizeProviderFromConfig:Assistant
So
finalizeProviderFromConfigwraps the provider withwrapProviderWithToolSchemaTransform. Let me check that function and the tool_schema_transform provider to see how SupportsThinking propagates.Assistant
Let me check existing tests around the "does not support thinking" warning behavior:
Assistant
Let me look at the agent tests around line 540-620 to understand the existing thinking tests that I need to keep passing.
Assistant
Let me check whether any existing tests assert HTTPProvider thinking behavior or check the warning. Let me search the whole repo:
Assistant
Let me look at the openai_compat tests around lines 460-520 and 640-740 to understand the DeepSeek-specific tests:
Assistant
Let me look at the
captureRequestMessagesandrunCapturedChathelpers:Assistant
These tests pass
nilfor options, so they won't trigger thinking control. Good.Now let me look at the
captureRequestMessageshelper to confirm.Assistant
I now have a clear understanding. Let me implement the changes. First, let me open the relevant section of the openai_compat provider:
Assistant
Now let me edit the
applyThinkingControlfunction and add DeepSeek mapping:Assistant
Now let me add the DeepSeek case to
thinkingControlKind:Assistant
There's a stray closing brace at line 303. Let me fix that:
Assistant
There are stray lines 306-307. Let me remove them:
Assistant
Now the
thinkingControlKindlooks correct. Now let me add theSupportsThinkingmethod to the openai_compat Provider. Let me add it near theSetProviderNamemethod:Assistant
Now let me add the
SupportsThinkingmethod to the HTTPProvider inhttpapi/http_provider.go:Assistant
Now let me build the project to check for compile errors:
Assistant
The
workspace: no matching files founderror is pre-existing (an embed directive needing workspace files). Let me build just the relevant packages:Assistant
The providers package builds cleanly. Now let me run the existing openai_compat tests to make sure I didn't break anything:
Assistant
Now let me write a temporary test to verify my DeepSeek thinking mapping behavior:
Assistant
The off case failed because of my test logic - for off, reasoning_effort should be absent. Let me fix the test:
Assistant
All passing. Now let me test the HTTPProvider's
SupportsThinkingand the integration through the factory + tool_schema_transform wrapping:Assistant
Now let me test the full integration: factory creation + tool_schema_transform wrapping, and that the agent passes thinking_level through to DeepSeek request shaping. Let me write an integration test:
Assistant
The thinking wasn't shaped because I passed
niloptions. Thethinking_leveloption is set by the agent layer (translatingModelConfig.ThinkingLevel), and the provider reads it from options. Let me fix the test:Assistant
Now let me write a full agent-level integration test that simulates the real flow (agent reads
ThinkingLevelfrom config, checksSupportsThinking, passes through):Assistant
All my agent-level integration tests pass. The full flow works correctly. Now let me run the full providers and agent test suites to ensure I haven't broken anything:
Assistant
All providers tests pass. Now let me run the agent tests:
Assistant
All agent tests pass. Now let me verify the edge case from the issue: "ensure explicit
offis sent even when DeepSeek does not advertise generic thinking support viaSupportsThinking()". Let me check the scenario where a non-DeepSeek-host but deepseek-style model is configured without SupportsThinking. Let me also run a quick check on the lint/vet:Assistant
Let me verify the formatting with gofmt since the repo uses golangci-lint:
Assistant
Let me check the lint config for line-length rules:
Assistant
No lines over 120 chars. Let me check if golines is available:
Assistant
golines isn't installed. My lines are all under 120, so
lllpasses. Now let me clean up the temporary test files:Assistant
Let me do a final review of the full diff:
Assistant
The diff looks good, but calling
thinkingControlKind("")with an empty model is semantically awkward. Let me refactor to use a dedicated, cleaner helper shared by boththinkingControlKindandSupportsThinking:Assistant
Now update
SupportsThinkingto use the new helper:Assistant
There's a stray
}at line 364. Let me remove it:Assistant
Now let me rebuild and run gofmt, vet, and the tests to confirm everything is clean:
Assistant
Let me re-run my temporary verification tests one more time to confirm the refactored version works correctly, then remove them:
Assistant
All verification tests pass. Now let me also confirm the HTTPProvider.SupportsThinking propagates through the wrapper one more time, then remove all temp test files:
Assistant
Everything works. Now let me remove all the temporary test files:
Assistant
Let me run the full providers test suite one final time to ensure everything passes without the temp tests:
Assistant
All tests pass. Let me do a final review of the complete diff:
Assistant
The diff is clean. Let me verify the pre-existing build error in
cmd/picoclawis unrelated to my changes (it's an embed directive):Assistant
The
//go:embed workspaceerror is pre-existing and unrelated to my changes — it requires a generatedworkspacedirectory. My changes are isolated to the providers packages, which build and test cleanly.Let me do a final confirmation that git status only shows my intended changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.