[Bugfix][Parser] Emit REASONING_END for Inkling tool calls that follow no thinking block (#50528)
Signed-off-by: Jason Yao <wsyjh8@gmail.com>
This commit is contained in:
@@ -342,16 +342,12 @@ class StreamingParserEngine:
|
||||
self._in_skipped_tool_span = True
|
||||
elif is_exit:
|
||||
self._in_skipped_tool_span = False
|
||||
if self.state == ParserState.MESSAGE_HEADER:
|
||||
self.state = ParserState.CONTENT
|
||||
leaving_message_header = self.state == ParserState.MESSAGE_HEADER
|
||||
if leaving_message_header:
|
||||
self._message_header_buffer = ""
|
||||
return [
|
||||
SemanticEvent(
|
||||
EventType.TEXT_CHUNK,
|
||||
value=value,
|
||||
tool_index=self.tool_index,
|
||||
)
|
||||
]
|
||||
# A tool terminal that implicitly ends reasoning must report
|
||||
# that even from the header state, or the reasoning pass never
|
||||
# hands the block to the tool pass.
|
||||
if EventType.REASONING_END in transition.events:
|
||||
self.state = ParserState.CONTENT
|
||||
return [
|
||||
@@ -366,6 +362,15 @@ class StreamingParserEngine:
|
||||
tool_index=self.tool_index,
|
||||
),
|
||||
]
|
||||
elif leaving_message_header:
|
||||
self.state = ParserState.CONTENT
|
||||
return [
|
||||
SemanticEvent(
|
||||
EventType.TEXT_CHUNK,
|
||||
value=value,
|
||||
tool_index=self.tool_index,
|
||||
)
|
||||
]
|
||||
content_type = self.config.content_events.get(self.state)
|
||||
if content_type is not None:
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user