[Bugfix][Frontend] Flush engine reasoning parser at engine-reasoning → tool streaming boundary (#47606)
Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com> Co-authored-by: Ben Browning <56071+bbrowning@users.noreply.github.com>
This commit is contained in:
@@ -851,19 +851,22 @@ class DelegatingParser(Parser):
|
||||
state.reasoning_ended = True
|
||||
reasoning_transitioned = True
|
||||
current_token_ids = self.extract_content_ids(delta_token_ids)
|
||||
# Flush whenever the reasoning parser is engine-based (not only
|
||||
# when _engine_based is True): it buffers the post-marker text
|
||||
# (e.g. the "<" of "<tool_call>"), surfaced via finish_streaming().
|
||||
flush_delta = (
|
||||
reasoning_parser.finish_streaming() # type: ignore[union-attr, attr-defined]
|
||||
if reasoning_parser is not None
|
||||
and reasoning_parser.engine_based_streaming
|
||||
else None
|
||||
)
|
||||
current_text = (
|
||||
(delta_message.content if delta_message else None) or ""
|
||||
) + ((flush_delta.content if flush_delta else None) or "")
|
||||
if self._engine_based:
|
||||
flush_delta = reasoning_parser.finish_streaming() # type: ignore[union-attr, attr-defined]
|
||||
current_text = (
|
||||
(delta_message.content if delta_message else None) or ""
|
||||
) + ((flush_delta.content if flush_delta else None) or "")
|
||||
if delta_message and self._tool_parser is not None:
|
||||
delta_message.content = None
|
||||
else:
|
||||
current_text = (
|
||||
delta_message.content
|
||||
if delta_message and delta_message.content
|
||||
else ""
|
||||
)
|
||||
delta_text = current_text
|
||||
|
||||
# Tool call extraction
|
||||
|
||||
Reference in New Issue
Block a user