[RL][TITO] Preserve whitespace in reasoning parser outputs (#24251)

This commit is contained in:
Yuzhen Zhou
2026-05-20 19:45:09 +00:00
committed by GitHub
parent 801d7e3eed
commit dac78768f0
4 changed files with 70 additions and 7 deletions
@@ -1228,6 +1228,37 @@ class ServingChatTestCase(unittest.TestCase):
req.reasoning_effort = effort
self.assertEqual(chat._get_reasoning_from_request(req), expected)
def test_non_stream_reasoning_response_preserves_payload_whitespace(self):
self.chat.reasoning_parser = "qwen3"
self.template_manager.force_reasoning = False
req = ChatCompletionRequest(
model="x",
messages=[{"role": "user", "content": "Hi?"}],
stream=False,
separate_reasoning=True,
)
ret = [
{
"text": "<think>\nLet me think\n</think>\n\nThe answer is 42.\n",
"meta_info": {
"id": "chatcmpl-test",
"prompt_tokens": 5,
"completion_tokens": 8,
"cached_tokens": 0,
"finish_reason": {"type": "stop", "matched": None},
"weight_version": "test",
},
"index": 0,
}
]
response = self.chat._build_chat_response(req, ret, created=123)
message = response.choices[0].message
self.assertEqual(message.reasoning_content, "\nLet me think\n")
self.assertEqual(message.content, "\n\nThe answer is 42.\n")
# ------------- reasoning config tests -------------
def test_get_reasoning_from_request_default_true_toggle(self):
self.tm.server_args.reasoning_parser = "qwen3"