Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. 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_level abstraction 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_level config without needing manual extra_body overrides

    💡 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 / 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

    • 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_level abstraction.

    💬 Additional Context

    https://api-docs.deepseek.com/zh-cn/guides/thinking_mode

    DeepSeek's documented OpenAI-compatible thinking controls use:

    • thinking.type
    • reasoning_effort
    • reasoning_content in responses

    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.

  2. Assistant

    Now I have a full picture. Implementing the changes:

    1. DeepSeek thinking mapping in openai_compat/provider.go:

  3. Assistant

    2. Expose SupportsThinking on the HTTP API provider:

  4. Assistant

    3. Test for the HTTPProvider.SupportsThinking passthrough:

  5. Assistant

    The full-repo build fails on a pre-existing embed issue in cmd/picoclaw unrelated to this change. Building and testing the affected packages:

  6. Assistant

    The environment hit fork limits with parallel compilation, and pkg/channels needs libolm (cgo). Restricting to the affected packages with lower parallelism:

  7. Assistant

    All tests pass and go vet is clean. The implementation is complete.

    Summary of changes

    pkg/providers/openai_compat/provider.go

    • applyThinkingControl now branches on DeepSeek (detected via provider name deepseek or *.deepseek.com API host, reusing the existing isDeepSeekHost helper) before the generic explicit-off path, and shapes requests for all thinking levels — not just off.
    • New applyDeepSeekThinking maps the internal thinking_level to 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() implements providers.ThinkingCapable, returning true only for DeepSeek. This makes the agent loop (pkg/agent/thinking.go:98) actually forward non-off levels to DeepSeek instead of dropping them with a warning; explicit off was already forwarded unconditionally.
    • Since extraBody is merged after thinking shaping in buildRequestBody, user extra_body overrides 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 existing SetProviderName style. Both Chat and ChatStream/ChatStreamEvents go through the same buildRequestBody, 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 (explicit off sent even without SetProviderName), no shaping for unknown/absent levels, extra_body precedence, SupportsThinking capability matrix, and an end-to-end Chat request-body assertion.
    • httpapi/http_provider_test.go (new): HTTPProvider.SupportsThinking delegation 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-repo go build ./... fails on a pre-existing cmd/picoclaw embed pattern and a cgo libolm dependency in unrelated packages — both present before this change.)

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.