Send empty assistant content when DeepSeek thinks without calling a tool.

A thinking-only turn was replayed as content=null with no tool_calls, which the API rejects with 400 and skipped IC review.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-28 02:31:42 +02:00
co-authored by Cursor
parent 08cbbdc422
commit 34bfe33cdf
2 changed files with 33 additions and 1 deletions
+6 -1
View File
@@ -111,8 +111,11 @@ def messages_to_openai(messages: list[Message], *, vision: bool) -> list[dict]:
tool_calls = [b for b in m.content if isinstance(b, ToolCall)]
msg: dict[str, Any] = {"role": "assistant"}
text = "".join(text_parts)
msg["content"] = text if text else None
# DeepSeek 400s with "content or tool_calls must be set" when
# thinking-mode returns reasoning only (content=null, no tools).
# Tool turns may keep content=null; text-only turns need "".
if tool_calls:
msg["content"] = text if text else None
msg["tool_calls"] = [
{
"id": tc.id,
@@ -124,6 +127,8 @@ def messages_to_openai(messages: list[Message], *, vision: bool) -> list[dict]:
}
for tc in tool_calls
]
else:
msg["content"] = text
reasoning = _reasoning_from_blocks(m.content)
if reasoning:
msg["reasoning_content"] = reasoning