Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
28c79dc8
Unverified
Commit
28c79dc8
authored
Sep 15, 2025
by
Jonas
Committed by
GitHub
Sep 15, 2025
Browse files
fix: gpt-oss streaming dropping normal content when tools are provided but not used (#9657)
parent
1fcccda4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
python/sglang/srt/function_call/gpt_oss_detector.py
python/sglang/srt/function_call/gpt_oss_detector.py
+23
-0
No files found.
python/sglang/srt/function_call/gpt_oss_detector.py
View file @
28c79dc8
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment