Skip to content

[langchain-deepseek] Missing reasoning_content in request payload when using deepseek-reasoner with tool calling #34166

@yefengzi7

Description

@yefengzi7

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-cli
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-perplexity
  • langchain-prompty
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Example Code (Python)

### Checked other resources

- [x] I added a very descriptive title to this issue.
- [x] I searched the LangChain documentation with the integrated search.
- [x] I used the GitHub search to find a similar question and didn't find it.
- [x] I am sure that this is a bug in LangChain rather than my code.
- [x] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

### Example Code


from langchain_deepseek import ChatDeepSeek
from langchain_core.messages import HumanMessage, AIMessage, ToolMessage
from langchain_core.tools import tool

@tool
def calculator(a: float, b: float) -> float:
    """Add two numbers."""
    return a + b

llm = ChatDeepSeek(model="deepseek-reasoner")
llm_with_tools = llm.bind_tools([calculator])

# First call - works fine
messages = [HumanMessage(content="What is 1 + 2?")]
response = llm_with_tools.invoke(messages)
# response.additional_kwargs contains 'reasoning_content'

# Simulate tool execution
messages.append(response)
messages.append(ToolMessage(content="3", tool_call_id=response.tool_calls[0]["id"]))

# Second call - fails with 400 error
response2 = llm_with_tools.invoke(messages)  # ERROR!

Error Message and Stack Trace (if applicable)

Error code: 400 - {'error': {'message': 'Missing `reasoning_content` field in the assistant message at message index 1. For more information, please refer to https://api-docs.deepseek.com/guides/thinking_with_tools', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

Description

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from langchain_deepseek import ChatDeepSeek
from langchain_core.messages import HumanMessage, AIMessage, ToolMessage
from langchain_core.tools import tool

@tool
def calculator(a: float, b: float) -> float:
    """Add two numbers."""
    return a + b

llm = ChatDeepSeek(model="deepseek-reasoner")
llm_with_tools = llm.bind_tools([calculator])

# First call - works fine
messages = [HumanMessage(content="What is 1 + 2?")]
response = llm_with_tools.invoke(messages)
# response.additional_kwargs contains 'reasoning_content'

# Simulate tool execution
messages.append(response)
messages.append(ToolMessage(content="3", tool_call_id=response.tool_calls[0]["id"]))

# Second call - fails with 400 error
response2 = llm_with_tools.invoke(messages)  # ERROR!

### System Info

System Information
OS: Windows
OS Version: 10.0.22631
Python Version: 3.12.12

Package Information
langchain_core: 1.1.0
langchain: 1.1.0
langchain_deepseek: 1.0.1
langchain_openai: 1.1.0
langgraph: 1.0.3
openai: 2.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featuredeepseek

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions