Describe the bug
When using the latest DeepSeek V4 models (deepseek-v4-flash or deepseek-v4-pro) via the OpenAI-compatible provider, claw-code fails on the second turn of a conversation or after a tool call.
The API returns a 400 Bad Request error:
api returned 400 Bad Request (invalid_request_error): The reasoning_content in the thinking mode must be passed back to the API.
Interestingly, using the legacy model name deepseek-reasoner does not trigger this error, even though it also involves a thinking process. This suggests that claw-code is dropping the reasoning_content field from the message history when constructing the next request, which is strictly required by the newer DeepSeek V4 API contract.
To Reproduce
Set OPENAI_BASE_URL to https://api.deepseek.com.
Run: claw --model openai/deepseek-v4-flash prompt "Analyze the code in this directory"
The model performs a read_file or ls call.
On the next turn, the API returns the 400 error.
Expected behavior
claw-code should preserve and pass back the reasoning_content field in the message history, as required by the DeepSeek API for models in thinking/reasoning mode.
Actual behavior
The reasoning_content is lost in the message context, causing the DeepSeek API to reject the request for breaking the "Thinking Chain" continuity.
Environment
OS: Windows (PowerShell)
Model: openai/deepseek-v4-flash / openai/deepseek-v4-pro
Claw-code version: 0.1.0
Describe the bug
When using the latest DeepSeek V4 models (deepseek-v4-flash or deepseek-v4-pro) via the OpenAI-compatible provider, claw-code fails on the second turn of a conversation or after a tool call.
The API returns a 400 Bad Request error:
api returned 400 Bad Request (invalid_request_error): The reasoning_content in the thinking mode must be passed back to the API.
Interestingly, using the legacy model name deepseek-reasoner does not trigger this error, even though it also involves a thinking process. This suggests that claw-code is dropping the reasoning_content field from the message history when constructing the next request, which is strictly required by the newer DeepSeek V4 API contract.
To Reproduce
Set OPENAI_BASE_URL to https://api.deepseek.com.
Run: claw --model openai/deepseek-v4-flash prompt "Analyze the code in this directory"
The model performs a read_file or ls call.
On the next turn, the API returns the 400 error.
Expected behavior
claw-code should preserve and pass back the reasoning_content field in the message history, as required by the DeepSeek API for models in thinking/reasoning mode.
Actual behavior
The reasoning_content is lost in the message context, causing the DeepSeek API to reject the request for breaking the "Thinking Chain" continuity.
Environment
OS: Windows (PowerShell)
Model: openai/deepseek-v4-flash / openai/deepseek-v4-pro
Claw-code version: 0.1.0