Fix spurious </think> tags caused by empty string reasoning_content in streaming (#7025)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
Copilot
2025-09-16 02:06:50 -07:00
committed by GitHub
parent 5216bf3737
commit 79d5d6ab47

View File

@@ -947,8 +947,8 @@ class BaseOpenAIChatCompletionClient(ChatCompletionClient):
is_reasoning = True
thought_deltas.append(reasoning_content)
yield reasoning_content
elif is_reasoning:
# Exit reasoning mode.
elif reasoning_content is None and is_reasoning:
# Exit reasoning mode only when reasoning_content is None (not when it's an empty string).
reasoning_content = "</think>"
thought_deltas.append(reasoning_content)
is_reasoning = False