Skip to content

Your lightweight open-source personal agent.

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

DDTa88c333466f3
diff --git a/nanobot/providers/openai_responses/converters.py b/nanobot/providers/openai_responses/converters.py
index 0f3091bd0..2d9ddf5c9 100644
--- a/nanobot/providers/openai_responses/converters.py
+++ b/nanobot/providers/openai_responses/converters.py
@@ -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({
diff --git a/tests/providers/test_openai_responses.py b/tests/providers/test_openai_responses.py
index 5960a372d..55d7d1e3f 100644
--- a/tests/providers/test_openai_responses.py
+++ b/tests/providers/test_openai_responses.py
@@ -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"
# ======================================================================
diff --git a/tests/providers/test_responses_circuit_breaker.py b/tests/providers/test_responses_circuit_breaker.py
index 506c3e46b..b81550e86 100644
--- a/tests/providers/test_responses_circuit_breaker.py
+++ b/tests/providers/test_responses_circuit_breaker.py
@@ -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"