Untitled conversation
- User
[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.
- explicit
- Assistant
Now I have a full picture. Implementing the changes:
1. DeepSeek thinking mapping in
openai_compat/provider.go: - Assistant
2. Expose
SupportsThinkingon the HTTP API provider: - Assistant
3. Test for the
HTTPProvider.SupportsThinkingpassthrough: - Assistant
The full-repo build fails on a pre-existing embed issue in
cmd/picoclawunrelated to this change. Building and testing the affected packages: - Assistant
The environment hit fork limits with parallel compilation, and
pkg/channelsneeds libolm (cgo). Restricting to the affected packages with lower parallelism: - Assistant
All tests pass and
go vetis clean. The implementation is complete.Summary of changes
pkg/providers/openai_compat/provider.goapplyThinkingControlnow branches on DeepSeek (detected via provider namedeepseekor*.deepseek.comAPI host, reusing the existingisDeepSeekHosthelper) before the generic explicit-offpath, and shapes requests for all thinking levels — not justoff.- New
applyDeepSeekThinkingmaps the internalthinking_levelto DeepSeek's documented OpenAI-compatible fields:off→thinking: {"type": "disabled"}low/medium/high→thinking: {"type": "enabled"}+reasoning_effort: "high"xhigh→thinking: {"type": "enabled"}+reasoning_effort: "max"adaptive→thinking: {"type": "enabled"}(provider default effort)
- New
Provider.SupportsThinking()implementsproviders.ThinkingCapable, returning true only for DeepSeek. This makes the agent loop (pkg/agent/thinking.go:98) actually forward non-offlevels to DeepSeek instead of dropping them with a warning; explicitoffwas already forwarded unconditionally. - Since
extraBodyis merged after thinking shaping inbuildRequestBody, userextra_bodyoverrides still take precedence.
pkg/providers/httpapi/http_provider.go- New
HTTPProvider.SupportsThinking()(the interface from the issue) — nil-safe passthrough to the openai_compat delegate, matching the existingSetProviderNamestyle. BothChatandChatStream/ChatStreamEventsgo through the samebuildRequestBody, so shaping applies to streaming and non-streaming paths alike.
Tests
openai_compat/provider_test.go: full level→fields mapping table, host-only detection without a provider name (explicitoffsent even withoutSetProviderName), no shaping for unknown/absent levels,extra_bodyprecedence,SupportsThinkingcapability matrix, and an end-to-endChatrequest-body assertion.httpapi/http_provider_test.go(new):HTTPProvider.SupportsThinkingdelegation for name/host/non-DeepSeek/nil cases.
Verified:
go test ./pkg/providers/openai_compat/ ./pkg/providers/httpapi/ ./pkg/providers/ ./pkg/agent/all pass. (Note: full-repogo build ./...fails on a pre-existingcmd/picoclawembed pattern and a cgo libolm dependency in unrelated packages — both present before this change.)
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
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →