Repository navigation
[Bugfix][Tool Parser] Olmo3: stream plain text that starts with "<" - #65936
Merged
chaunceyjiang merged 2 commits intoNov 11, 2026
Merged
chaunceyjiang merged 2 commits into
chaunceyjiang merged 2 commits into
Conversation
The streaming path treated any output starting with "<" as a possible <function_calls> block, so plain text like "<p>hello" was withheld for the whole response while non-streaming returned it. Hold text back only while it can still become the tag, and release it once ruled out. Fixes vllm-project#65934 AI assistance was used for this change. Signed-off-by: cipheraxat <[email protected]>
cipheraxat
marked this pull request as ready for review
November 5, 2026 15:30
cipheraxat
requested review from
aarnphm,
bbrowning,
chaunceyjiang and
sfeng33
as code owners
November 5, 2026 15:30
smiyamoto3
approved these changes
Nov 5, 2026
smiyamoto3
left a comment
There was a problem hiding this comment.
LGTM. I tried character-sized and larger ones on top of per-token deltas. Streaming matches non-streaming for the new cases with all of them.
chaunceyjiang
left a comment
Member
There was a problem hiding this comment.
Could you provide some actual reproduction requests and their raw results, and paste them into the PR description?
Contributor
Author
|
Thanks for taking a look! I added the actual requests and raw outputs to the description, under "Raw requests and responses". Both runs are the same build, and the only difference is the olmo3 parser file (main vs this PR), so the outputs line up directly. |
chaunceyjiang
enabled auto-merge (squash)
November 11, 2026 07:19
|
✅ @cipheraxat, CI is now available for this PR.
|
Contributor
Author
|
/ci run |
|
✅ Triggered Buildkite CI #101720 for commit |
4 of 5 tasks
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #65934. With
--tool-call-parser olmo3, streaming dropped any assistant text that starts with<but is not a tool call (for example<p>hello). The response came back as HTTP 200 with empty content, while non-streaming returned the text. This PR holds text back only while it can still become<function_calls>, and releases it once that is ruled out. Real<function_calls>output streams as before, including when the tag is split across tokens, and non-streaming is unchanged.Validation
Unit tests (macOS, CPU). The new
test_no_tool_callcases fail onmainand pass with this change:main(463e23b)test_no_tool_call[True-<p>hello]None)test_no_tool_call[True-<b>bold</b>]None)test_no_tool_call[True-<function> is an HTML-like tag...]None)Raw requests and responses (Colab, 1x A100-SXM4-40GB). The server ran on the PR head
13c3c8e368(vllm 0.33.0rc1.dev855+g13c3c8e36, precompiled install). For themainrun, the only change was resettingvllm/tool_parsers/olmo3_tool_parser.pyto the merge-base82aeedf8db(git show 82aeedf8db:vllm/tool_parsers/olmo3_tool_parser.py > vllm/tool_parsers/olmo3_tool_parser.py), sosystem_fingerprintis the same build in both runs.Server:
Request body (
req.json). This is the reporter's payload; onlystructured_outputs.choiceandstreamchange between cases:{ "model": "qwen3", "messages": [ { "role": "user", "content": "Return the requested text." } ], "tools": [ { "type": "function", "function": { "name": "dummy", "description": "A dummy tool.", "parameters": { "type": "object", "properties": {} } } } ], "tool_choice": "auto", "temperature": 0, "max_tokens": 64, "chat_template_kwargs": { "enable_thinking": false }, "structured_outputs": { "choice": [ "<p>hello" ] }, "stream": true }curl -sN http://127.0.0.1:23101/v1/chat/completions -H 'Content-Type: application/json' -d @req.jsonchoicemain<p>hellofinish_reason: "stop"with no content"<p",">","hello"<p>hello"content": "<p>hello""content": "<p>hello"<b>bold</b>finish_reason: "stop"with no content"<b",">","bold","</","b",">"<function> is a tagfinish_reason: "stop"with no content"<function>"," ","is"," a"," ","tag"<function_calls>dummy()</function_calls>tool_callsdummy{},finish_reason: "tool_calls"Raw output:
mainparser (82aeedf8db)Raw output: this PR (
13c3c8e368)Per-delta parser output for
<function> is a tag(GPT-2 tokenization)Details
Root cause.
Olmo3PythonicToolParser.extract_tool_calls_streaminglet text through as content only whencurrent_textdid not start with<. Anything starting with<went to the pythonic parsing branch. For text like<p>hello, that branch fails and returnsNone. Because the accumulated text keeps its leading<, every later delta takes the same branch, so the whole response is swallowed. Non-streaming uses a<function_calls>(.*?)</function_calls>regex and falls back to the original text, which is why the two modes diverged.Fix. Text is withheld only while
current_textis still a prefix of<function_calls>. Once it is neither a prefix nor starts with the tag, the parser releases it. Ifprevious_textwas entirely withheld (it was itself a tag prefix), the parser returns all ofcurrent_text. Otherwise it returnsdelta_text. The tool-call branch is unchanged.Limitation (unchanged from
main). If a stream ends while the text is still a strict prefix of the tag (for example a bare<or<function_calls), that text is still withheld. Flushing it needs an end-of-stream hook, so I kept it out of scope.Duplicate check. No open or merged PR addresses this; I searched for olmo3,
Olmo3PythonicToolParserand the issue number. Open olmo3 parser PRs (#60433, #60436, #61633, #56846) touch other parts of the file and don't change this check.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.