Skip to content

Commit e12a1b7

Browse files
janhilgardclaude
andcommitted
fix: Update Qwen3 parser tests to match fork reasoning behavior
Tests expected reasoning=None for no-tag and start-tag-only outputs, but fork's Qwen3 parser intentionally treats these as reasoning (enable_thinking=True injects <think> in prompt, so output without </think> = reasoning that hit max_tokens). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6b543d1 commit e12a1b7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/test_reasoning_parser.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,22 @@ def test_extract_multiline_reasoning(self, parser):
100100
assert "Step 3" in reasoning
101101
assert content == "Result: 42"
102102

103-
def test_no_tags_returns_content_only(self, parser):
104-
"""Qwen3 requires both tags - no tags means pure content."""
103+
def test_no_tags_returns_reasoning(self, parser):
104+
"""Qwen3 with enable_thinking=True: no tags means reasoning hit max_tokens."""
105105
output = "Just a regular response without thinking."
106106
reasoning, content = parser.extract_reasoning(output)
107-
assert reasoning is None
108-
assert content == output
107+
# enable_thinking=True injects <think> in prompt, so output without
108+
# tags = reasoning that hit max_tokens before </think>
109+
assert reasoning == output
110+
assert content is None
109111

110-
def test_only_start_tag_no_reasoning(self, parser):
111-
"""Qwen3 requires both tags - missing end tag means no reasoning."""
112+
def test_only_start_tag_incomplete_reasoning(self, parser):
113+
"""Qwen3: only <think> without </think> = incomplete reasoning (still generating)."""
112114
output = "<think>Started thinking but never finished"
113115
reasoning, content = parser.extract_reasoning(output)
114-
assert reasoning is None
115-
assert content == output
116+
# Only start tag = reasoning in progress, no content yet
117+
assert reasoning == "Started thinking but never finished"
118+
assert content is None
116119

117120
def test_only_end_tag_implicit_mode(self, parser):
118121
"""Qwen3 supports implicit mode - when <think> is in prompt, only </think> in output."""
@@ -651,12 +654,11 @@ def test_qwen3_implicit_mode_support(self, parser):
651654
assert content == "more text"
652655

653656
# Only start tag - no </think> means model is still generating
654-
# Qwen3 requires </think> to extract reasoning (treats as pure content until then)
655657
output2 = "<think>incomplete reasoning"
656658
reasoning, content = parser.extract_reasoning(output2)
657-
# No </think> = no reasoning extraction, entire output is content
658-
assert reasoning is None
659-
assert content == output2
659+
# Only <think> without </think> = reasoning in progress, no content yet
660+
assert reasoning == "incomplete reasoning"
661+
assert content is None
660662

661663
def test_qwen3_empty_think_tags(self, parser):
662664
"""Test empty think tags."""

0 commit comments

Comments
 (0)