Skip to content

Your lightweight open-source personal agent.

test: fix trailing-space mismatch and add regression tests for normal models

Xubin Ren63acfc4f2ffe
diff --git a/tests/providers/test_stepfun_reasoning.py b/tests/providers/test_stepfun_reasoning.py
index 0c39d9342..05e5416d4 100644
--- a/tests/providers/test_stepfun_reasoning.py
+++ b/tests/providers/test_stepfun_reasoning.py
@@ -121,7 +121,7 @@ def test_parse_chunks_dict_stepfun_reasoning_fallback() -> None:
{
"choices": [{
"finish_reason": None,
- "delta": {"content": None, "reasoning": "step 2. "},
+ "delta": {"content": None, "reasoning": "step 2."},
}],
},
{
@@ -138,6 +138,48 @@ def test_parse_chunks_dict_stepfun_reasoning_fallback() -> None:
assert result.reasoning_content == "Thinking step 1... step 2."
+# ── Regression: normal models unaffected ────────────────────────────────────
+
+
+def test_parse_dict_normal_model_with_reasoning_content_unaffected() -> None:
+ """Models that use reasoning_content (e.g. DeepSeek-R1) are not affected."""
+ with patch("nanobot.providers.openai_compat_provider.AsyncOpenAI"):
+ provider = OpenAICompatProvider()
+
+ response = {
+ "choices": [{
+ "message": {
+ "content": "The answer is 42.",
+ "reasoning_content": "Let me think step by step...",
+ },
+ "finish_reason": "stop",
+ }],
+ }
+
+ result = provider._parse(response)
+
+ assert result.content == "The answer is 42."
+ assert result.reasoning_content == "Let me think step by step..."
+
+
+def test_parse_dict_standard_model_no_reasoning_unaffected() -> None:
+ """Standard models (no reasoning fields at all) work exactly as before."""
+ with patch("nanobot.providers.openai_compat_provider.AsyncOpenAI"):
+ provider = OpenAICompatProvider()
+
+ response = {
+ "choices": [{
+ "message": {"content": "Hello!"},
+ "finish_reason": "stop",
+ }],
+ }
+
+ result = provider._parse(response)
+
+ assert result.content == "Hello!"
+ assert result.reasoning_content is None
+
+
def test_parse_chunks_dict_reasoning_precedence() -> None:
"""reasoning_content takes precedence over reasoning in dict chunks."""
chunks = [