fix(providers): use reasoning_text for DeepSeek Responses reasoning replay

DeepSeek's Responses API documents reasoning content blocks as
reasoning_text. Full-history replay of assistant reasoning_content was
emitting output_text inside the reasoning item. Assistant message
content stays output_text.

Fixes #6411

Co-authored-by: DDT <1786035110@qq.com>
This commit is contained in:
DDTandDDT authored and chengyongru committed 2026-10-23 22:14:56 +08:00
1 parent cab2af7e94
commit a88c333466
3 files changed
+15 -11

No files matched your search

@@ -44,7 +44,7 @@ def convert_messages(
if isinstance(reasoning, str) and reasoning:
input_items.append({
"type": "reasoning",
"content": [{"type": "output_text", "text": reasoning}],
"content": [{"type": "reasoning_text", "text": reasoning}],
})
if isinstance(content, str) and content:
input_items.append({
+7 -5
View File
@@ -190,7 +190,7 @@ class TestConvertMessages:
assert items == [
{
"type": "reasoning",
"content": [{"type": "output_text", "text": "think first"}],
"content": [{"type": "reasoning_text", "text": "think first"}],
},
{
"type": "message",
@@ -222,7 +222,7 @@ class TestConvertMessages:
assert items[0]["type"] == "reasoning"
assert items[0]["content"] == [
{"type": "output_text", "text": "Michael topped up DeepSeek with $10."},
{"type": "reasoning_text", "text": "Michael topped up DeepSeek with $10."},
]
assert items[1]["type"] == "function_call"
@@ -1041,9 +1041,11 @@ class TestResponsesConversationState:
assert replayed is True
reasoning_items = [item for item in items if item.get("type") == "reasoning"]
assert len(reasoning_items) == 2 # one replayed, one converted delta
for item in reasoning_items:
assert isinstance(item["content"], list)
assert item["content"][0]["type"] == "output_text"
assert isinstance(reasoning_items[0]["content"], list)
# Stored replay items keep their original block type.
assert reasoning_items[0]["content"][0]["type"] == "output_text"
assert isinstance(reasoning_items[1]["content"], list)
assert reasoning_items[1]["content"][0]["type"] == "reasoning_text"
# ======================================================================
@@ -94,7 +94,7 @@ def test_responses_behavior_is_declared_by_capabilities(provider):
assert {
"type": "reasoning",
"content": [{"type": "output_text", "text": "think first"}],
"content": [{"type": "reasoning_text", "text": "think first"}],
} in body["input"]
assert "include" not in body
@@ -262,7 +262,7 @@ def test_deepseek_full_history_body_keeps_reasoning_content_as_array(provider):
reasoning_items = [item for item in body["input"] if item.get("type") == "reasoning"]
assert len(reasoning_items) == 1
assert reasoning_items[0]["content"] == [
{"type": "output_text", "text": "Michael topped up DeepSeek with $10."},
{"type": "reasoning_text", "text": "Michael topped up DeepSeek with $10."},
]
@@ -317,6 +317,8 @@ def test_deepseek_replay_body_keeps_reasoning_content_as_array(provider):
reasoning_items = [item for item in body["input"] if item.get("type") == "reasoning"]
assert len(reasoning_items) == 2 # one replayed from state, one converted
for item in reasoning_items:
assert isinstance(item["content"], list)
assert item["content"][0]["type"] == "output_text"
assert isinstance(reasoning_items[0]["content"], list)
# Stored replay items keep their original block type.
assert reasoning_items[0]["content"][0]["type"] == "output_text"
assert isinstance(reasoning_items[1]["content"], list)
assert reasoning_items[1]["content"][0]["type"] == "reasoning_text"