Missing `reasoning_content` field

Deepseek with reasoning

Error code: 400 - {‘error’: {‘message’: ‘Missing reasoning_content field in the assistant message at message index 2. 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’}}

Code:

prompt = ChatPromptTemplate.from_messages(messages)
chain = prompt | llm

res = chain.invoke(
    {"chat_history": chat_history}
)

Message:

{
  "role": "assistant",
  "content": "",
  "tool_calls": [
    {
      "name": "sum",
      "args": {
        "a": 235324,
        "b": 432432
      },
      "id": "call_00_ioodMHzdzdKM5q3hMQ4PmgAl",
      "type": "tool_call"
    }
  ],
  "additional_kwargs": {
    "refusal": null,
    "reasoning_content": "O usuário está perguntando sobre uma soma: 235324 + 432432. Posso usar a função \"sum\" para calcular isso. Vou invocar a função com os parâmetros a e b."
  }
}

reasoning_content is being sent within additional_kwargs, how can I send it at the same level as the content?

The ChatDeepDeek’s implementation of _get_request_payload heavily depends on BaseChatOpenAI, which doesn’t do anything special when it comes to extracting reasoning_content from additional_kwargs in the message before sending it to the endpoint. There doesn’t seem to be a way for users to override this behavior without directly modifying the class itself.