Unverified Commit 28c79dc8 authored by Jonas's avatar Jonas Committed by GitHub
Browse files

fix: gpt-oss streaming dropping normal content when tools are provided but not used (#9657)

parent 1fcccda4
...@@ -81,6 +81,29 @@ class GptOssDetector(BaseFormatDetector): ...@@ -81,6 +81,29 @@ class GptOssDetector(BaseFormatDetector):
# Always use HarmonyParser for parsing to ensure proper filtering # Always use HarmonyParser for parsing to ensure proper filtering
events = self.harmony_parser.parse(new_text) events = self.harmony_parser.parse(new_text)
# If there are no parsed events and the chunk contains no Harmony structural
# markers, treat it as plain text and pass it through. This fixes a bug where
# normal content was held in the buffer when tools were provided but not used.
if not events:
has_harmony_markers = any(
marker in self._buffer
for marker in (
"<|start|>",
"<|channel|>",
"<|message|>",
"<|constrain|>",
"<|end|>",
"<|call|>",
"<|return|>",
"assistantfinal",
)
)
if not has_harmony_markers:
# Plain text with no tool markers — emit as normal content
out = self._buffer
self._buffer = ""
return StreamingParseResult(normal_text=out, calls=[])
# Quick check if we might have tool calls # Quick check if we might have tool calls
if ( if (
"<|channel|>commentary to=" not in self._buffer "<|channel|>commentary to=" not in self._buffer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment