DeepSeek Reasoning Model Support: Missing reasoning_content Field
Problem Description
When using DeepSeek's reasoning models (e.g., deepseek-reasoner) with tool calling enabled, ECA encounters the following error:
LLM response status: 400 body: {"error":{"message":"Missing reasoning_content field in the assistant message at message index 2."}}
This occurs during multi-turn conversations that involve tool calls.
Root Cause
DeepSeek's reasoning models return an additional reasoning_content field in assistant messages that contains the model's chain-of-thought reasoning. According to their API documentation:
- During multi-turn tool call sequences (e.g., questions requiring multiple tool calls to answer), this
reasoning_contentmust be sent back to the API to allow the model to continue its reasoning chain - ECA's current
openai_chat.cljimplementation strips out this field during message normalization
Technical Details
The issue is in /src/eca/llm_providers/openai_chat.clj:
transform-messagefunction (lines 135-148): When processing "assistant" role messages, it only preserves:contentbut not:reasoning_content:
"assistant" {:role "assistant"
:content (extract-content content supports-image?)}
valid-message?function (lines 176-184): This validation filter doesn't recognize messages with onlyreasoning_contentas valid, causing them to be excluded entirely.
Reference: DeepSeek API Behavior
"During the process of answering question 1 (Turn 1.1 - 1.3), the model performed multiple turns of thinking + tool calls before providing the answer. During this process, the user needs to send the reasoning content (reasoning_content) back to the API to allow the model to continue reasoning."
"At the beginning of Turn 2.1, the previous reasoning_content should be removed... If reasoning_content is retained and sent to the API, the API will ignore it."
The DeepSeek docs mention that reasoning_content should be cleared when starting a "new question" (Turn 2.x vs. Turn 1.x).
Open Question: Conversation Turn Management
Does ECA have a concept of "conversation boundaries" or "new questions" vs. "continuing the same question"?
Currently, ECA treats all message history as a continuous conversation. The DeepSeek API claims it will ignore reasoning_content when it's no longer needed, but we should verify this behavior works correctly for ECA's use cases.
But Deepseek API documentation also states:
We recommended clearing the reasoning_content in history messages so as to save network bandwidth
More info: https://api-docs.deepseek.com/guides/thinking_mode#api-example
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
@ericdallo What do you think about Conversation Turn Management? Is it something we should improve to save the network bandwidth? Or do you think that the propposed fix is enough?
@zikajk I think this is the same did for openai and anthropic APIs, where we store the reasoning content called external-id here, we use this generic field for reasonings ids that their API relates to reasoning content, I believe deepseek don't have ids and just return the raw reasoning content right?
We just need to do the same for openai-chat, the question is: is this a generic thing that other models do or just a deepseek api?
This is how it looks:
{:id "40ff5808-18b1-45e6-8b99-9dcd69623f97", :object "chat.completion", :created 1764688218, :model "deepseek-reasoner", :choices [{:index 0, :message {:role "assistant", :content "Implementing download", :reasoning_content "...."}, :logprobs nil, :finish_reason "stop"}], :usage {:prompt_tokens 383, :completion_tokens 165, :total_tokens 548, :prompt_tokens_details {:cached_tokens 320}, :completion_tokens_details {:reasoning_tokens 159}, :prompt_cache_hit_tokens 320, :prompt_cache_miss_tokens 63}, :system_fingerprint "fp_eaab8d114b_prod0820_fp8_kvcache"}
https://github.com/editor-code-assistant/eca/commit/f5d5e4f9e7dcef077f1c71f82d3417cda5ae8a26