[Bugfix] Drop incomplete tool-call markup in non-streaming to match streaming (#47562)
Signed-off-by: Suvrakamal Das <jyb2084.usa@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ben Browning <56071+bbrowning@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude
Ben Browning
parent
2f01039666
commit
e7cf4730d6
@@ -175,6 +175,14 @@ class ParserEngine(Parser):
|
||||
def skip_tool_parsing(self, value: bool) -> None:
|
||||
self._engine.skip_tool_parsing = value
|
||||
|
||||
@property
|
||||
def skip_reasoning_parsing(self) -> bool:
|
||||
return self._engine.skip_reasoning_parsing
|
||||
|
||||
@skip_reasoning_parsing.setter
|
||||
def skip_reasoning_parsing(self, value: bool) -> None:
|
||||
self._engine.skip_reasoning_parsing = value
|
||||
|
||||
@property
|
||||
def reasoning_ended(self) -> bool:
|
||||
return self._reasoning_ended
|
||||
@@ -714,6 +722,7 @@ class ParserEngine(Parser):
|
||||
content_parts: list[str] = []
|
||||
reasoning_parts: list[str] = []
|
||||
|
||||
carried_deferred = self._deferred_content
|
||||
seen_tool_event = False
|
||||
suppress = self._suppress_tool_calls
|
||||
for event in events:
|
||||
@@ -750,7 +759,14 @@ class ParserEngine(Parser):
|
||||
tool_call_deltas = self._coalesce_tool_call_deltas(tool_call_deltas)
|
||||
|
||||
if self._deferred_content and (not seen_tool_event or not tool_call_deltas):
|
||||
content_parts.insert(0, self._deferred_content)
|
||||
# Deferred content carried in from a previous delta precedes this
|
||||
# delta's content; content deferred during this call (text after
|
||||
# an unpromoted tool event) follows it.
|
||||
deferred_now = self._deferred_content[len(carried_deferred) :]
|
||||
if carried_deferred:
|
||||
content_parts.insert(0, carried_deferred)
|
||||
if deferred_now:
|
||||
content_parts.append(deferred_now)
|
||||
self._deferred_content = ""
|
||||
|
||||
content_str = "".join(content_parts)
|
||||
|
||||
Reference in New Issue
Block a user