deepseek-think

n8n community node: DeepSeek Chat Model with thinking mode ON that passes reasoning_content back on every assistant message, so tool calls never fail with the 'reasoning_content must be passed back' 400

Package Information

Released: this month
Downloads: 0 weekly / 0 monthly
Latest Version: 0.1.0
Author: João Pedro Galera

Documentation

n8n-nodes-deepseek-think

DeepSeek Chat Model (Thinking) — an n8n community sub-node for the AI Agent and LLM chains that runs DeepSeek with
thinking mode on and passes reasoning_content back to the API on every assistant message, so tool calls never
fail with:

400 The reasoning_content in the thinking mode must be passed back to the API

It reuses the built-in DeepSeek credential and exposes the same options as the native DeepSeek Chat Model node.

The problem

With thinking enabled and tools in the request, DeepSeek requires the reasoning_content of assistant messages to
come back in the conversation. The built-in n8n node is a thin ChatOpenAI wrapper, and @langchain/openai:

  • captures reasoning_content from the response (it lands in additional_kwargs of the AIMessage), but
  • drops it when building the request body: the outbound converter (convertMessagesToCompletionsMessageParams) is a
    module-level function with no override point.

@langchain/deepseek inherits the same converter, so switching the class does not help either.

Observed behaviour of the API (measured against deepseek-flash, October 2026): the 400 fires when an assistant
message arrives without the field; an empty string satisfies the check.

How it works

ChatOpenAI delegates chat/completions to a completions object (ChatOpenAICompletions) that can be injected
through its fields. This node injects the DeepSeekCompletions subclass:

  • _generate / _streamResponseChunks receive the original BaseMessages and keep the reasoning_content of each
    one by index (the conversion is 1:1 and order-preserving);
  • completionWithRetry receives the ready body (streaming and non-streaming) and writes reasoning_content on every
    assistant message: the real value when the AIMessage brought one (the tool loop of the current turn, which
    keeps the chain of thought going between tool calls) and "" when it did not (chat memory history, prefill).

Inside the agent loop no extra state is needed: the AIMessage with tool_calls returned by the model is the same
object the AgentExecutor sends back on the next round, so additional_kwargs.reasoning_content travels with it.

The execution panel also shows a reasoning field for each generation.

Install

From the n8n UI (Settings → Community Nodes → Install):

n8n-nodes-deepseek-think

From a local build (self-hosted, no registry):

npm install
npm pack                     # produces n8n-nodes-deepseek-think-0.1.0.tgz

Then, inside the n8n container / pod (the package lands in ~/.n8n/nodes/node_modules and survives image upgrades):

mkdir -p ~/.n8n/nodes
npm install --no-audit --no-fund --prefix ~/.n8n/nodes /path/to/n8n-nodes-deepseek-think-0.1.0.tgz
# restart n8n

Community packages are unverified by n8n, so keep N8N_UNVERIFIED_PACKAGES_ENABLED=true in the environment.

Usage

  • Add DeepSeek Chat Model (Thinking) (AI → Language Models) as the model of an AI Agent or chain.
  • Pick the built-in DeepSeek credential.
  • Default model deepseek-flash; the list is loaded from /models.
  • Options: temperature, top P, penalties, max tokens, JSON mode, timeout, retries — same as the native node.

Tests

npm install
npm test        # builds, then runs node:test against a local mock of /chat/completions

The mock captures the real request bodies and asserts: thinking: { type: "enabled" }; a tool loop with history (old
assistant goes with "", the current-turn assistant goes with its real reasoning_content and tool_calls;
user / system / tool never carry the field); streaming (reasoning deltas concatenated into the AIMessageChunk
and passed back on the next call); tracing with reasoning and tokenUsage.

Compatibility

Dependencies are pinned to the versions shipped in the n8nio/n8n:2.36.x image (@langchain/openai@1.4.4,
@langchain/core@1.2.0). n8n-workflow is a peer dependency (n8n injects its own copy into community nodes).

License

MIT

Discussion