[Bugfix] Preserve empty K2 Horizon reasoning in chat responses (#42623)

Co-authored-by: BBuf <1182563586@qq.com>
This commit is contained in:
Yash Akhauri
2026-10-07 10:44:55 +08:00
committed by GitHub
co-authored by BBuf
parent d7190b0122
commit 9c8fc6a8e4
2 changed files with 143 additions and 1 deletions
@@ -2087,6 +2087,7 @@ class OpenAIServingChat(OpenAIServingBase):
# First chunk with role
if is_firsts.get(index, True):
is_firsts[index] = False
# K2 templates require preserved thinking, including empty reasoning.
yield build_sse_content(
chunk_id=content["meta_info"]["id"],
created=int(time.time()),
@@ -2094,6 +2095,12 @@ class OpenAIServingChat(OpenAIServingBase):
index=index,
role="assistant",
content="",
reasoning_content=(
""
if self.reasoning_parser == "k2_horizon"
and request.separate_reasoning
else None
),
)
stream_started = True
@@ -2446,7 +2453,7 @@ class OpenAIServingChat(OpenAIServingBase):
role="assistant",
content=text if text else "",
tool_calls=tool_calls,
reasoning_content=reasoning_text if reasoning_text else None,
reasoning_content=reasoning_text,
),
logprobs=choice_logprobs,
finish_reason=finish_reason["type"] if finish_reason else None,