Skip to content

Commit 79d5d6a

Browse files
Copilotekzhu
andauthored
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>
1 parent 5216bf3 commit 79d5d6a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,8 @@ async def create_stream(
947947
is_reasoning = True
948948
thought_deltas.append(reasoning_content)
949949
yield reasoning_content
950-
elif is_reasoning:
951-
# Exit reasoning mode.
950+
elif reasoning_content is None and is_reasoning:
951+
# Exit reasoning mode only when reasoning_content is None (not when it's an empty string).
952952
reasoning_content = "</think>"
953953
thought_deltas.append(reasoning_content)
954954
is_reasoning = False

0 commit comments

Comments
 (0)