Skip to content

fix(adapters/deepseek): enable tool capabilities for reasoner model and handle reasoning_content#2687

Draft
nabiu256 wants to merge 3 commits intoolimorris:mainfrom
nabiu256:update-deepseek-reasoner
Draft

fix(adapters/deepseek): enable tool capabilities for reasoner model and handle reasoning_content#2687
nabiu256 wants to merge 3 commits intoolimorris:mainfrom
nabiu256:update-deepseek-reasoner

Conversation

@nabiu256
Copy link

Description

Fixes two issues in the DeepSeek adapter:

  1. Enables tool capabilities for DeepSeek Reasoner model: The DeepSeek Reasoner model (deepseek-reasoner) supports function calling/tools but was incorrectly configured with can_use_tools = false.

  2. Adds proper handling of reasoning_content field: DeepSeek's API expects a non-standard reasoning_content field for reasoning models instead of the standard reasoning field used by other providers. This change:

    • Converts reasoning table/string to reasoning_content
    • Ensures reasoning_content exists for assistant messages in reasoning mode
    • Maintains compatibility with existing CodeCompanion reasoning interface

AI Usage

Used opencode to implement the changes based on DeepSeek API documentation and existing adapter patterns.

Testing

  • Run make test_file FILE=tests/adapters/http/test_deepseek.lua
  • All deepseek adapter tests pass

Checklist

  • I've read the contributing guidelines
  • I've verified the deepseek adapter tests pass
  • (optional) Existing test coverage is sufficient
  • (optional) No documentation updates needed for this bug fix

@olimorris
Copy link
Owner

Thanks for the PR.

but was incorrectly configured with can_use_tools = false.

FYI, this was added when the reasoning models did not support tool calling

Before I can merge this I'll need test coverage of the reasoning output, as we have for the other adapters.

@nabiu256
Copy link
Author

FYI, this was added when the reasoning models did not support tool calling
Yes sorry, I didn't mean it was originally wrong but that since DeepSeek Reasoner recently got tools capabilities it needed to be changed.

I'll get on testing asap. Thank you for the quick answer.

@olimorris olimorris marked this pull request as draft January 29, 2026 08:01
@cairijun
Copy link

Hi @nabiu256 are you still working on this? I tried your patch recently (on develop branch) and I think it need some modifications to ensure reasoning_contents are sent back to LLM:

     form_messages = function(self, messages)
-      messages = adapter_utils.merge_messages(messages)
+      messages = adapter_utils.merge_messages(messages, { "tools", "reasoning" })
       messages = adapter_utils.merge_system_messages(messages)
+    form_reasoning = function(self, data)
+      local content = vim
+        .iter(data)
+        :map(function(item)
+          return item.content
+        end)
+        :join("")
+      return { content = content }
+    end,
     parse_message_meta = function(self, data)
       local extra = data.extra
-      if extra.reasoning_content then
+      if extra.reasoning_content and extra.reasoning_content ~= "" then
         data.output.reasoning = { content = extra.reasoning_content }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants