[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
Now let me check how the Gemini provider handles thinking levels, for consistency:
Assistant
Now I have the full picture. Let me implement the changes in openai_compat/provider.go:
Assistant
Now expose SupportsThinking on the HTTPProvider in httpapi/http_provider.go per the interface spec:
Assistant
Let me check the facade in pkg/providers/httpapi_facade.go to see if HTTPProvider is re-exported or wrapped there:
Assistant
The type alias picks up the new method automatically. Now add tests in openai_compat/provider_test.go:
Assistant
Now I can add the tests:
Assistant
Done. The cmd/picoclaw embed failure (pattern workspace: no matching files found) exists on clean HEAD too — it's pre-existing and unrelated.
Summary of changes
pkg/providers/openai_compat/provider.go
applyThinkingControl now branches on DeepSeek first: any recognized thinking_level (not just ) triggers DeepSeek request shaping; other providers keep the existing off-only disable behavior.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
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.
off
New applyDeepSeekThinkingControl maps internal levels to DeepSeek's documented OpenAI-compatible fields:
off → thinking: {"type": "disabled"}
low/medium/high/adaptive → thinking: {"type": "enabled"} + reasoning_effort: "high" (per DeepSeek's documented compatibility behavior; adaptive follows the Gemini precedent of mapping to high)
New isDeepSeek() helper (provider name deepseek or *.deepseek.com host), reused by requiresToolRoundReasoningReplay, so host-based fallback/rewrite candidates get the mapping even when named openai.
New SupportsThinking() implementing providers.ThinkingCapable, returning true only for DeepSeek — this lets the agent loop forward thinking-enabled levels instead of dropping them with a warning, while explicit off continues to be sent unconditionally (existing behavior in pkg/agent/thinking.go:94).
extra_body still merges last, so manual overrides take precedence over the mapping.
pkg/providers/httpapi/http_provider.go
HTTPProvider.SupportsThinking() per the interface spec: nil-safe delegation to the underlying openai_compat.Provider. The providers.HTTPProvider type alias and the toolSchemaTransformProvider wrapper pick it up automatically.
Tests (openai_compat/provider_test.go, new httpapi/http_provider_test.go)
Level-mapping table test for all six levels, host-based detection with generic provider name (fallback path), unknown/absent level left untouched, extra_body precedence, SupportsThinking matrix, an end-to-end Chat request-shaping test, and HTTPProvider delegation + nil-safety tests.
Verified: go vet clean, gofmt clean, and go test passes for pkg/providers/openai_compat, pkg/providers/httpapi, pkg/providers, and pkg/agent.