[Bugfix] Qwen3 XML parser: interleaved text emission and streaming ID management#40787
Closed
ExtReMLapin wants to merge 6 commits into
Closed
[Bugfix] Qwen3 XML parser: interleaved text emission and streaming ID management#40787ExtReMLapin wants to merge 6 commits into
ExtReMLapin wants to merge 6 commits into
Conversation
Signed-off-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Qwen3XMLToolParser to ensure that text content appearing between multiple tool calls is correctly emitted by removing the tool_call_index == 0 constraint. A new test case is added to verify this behavior. Feedback suggests that the fix is incomplete as a similar check exists elsewhere that might block text after the final tool call. Furthermore, the test should be refactored to use the provided tokenizer fixture instead of downloading one from the hub, and the unnecessary async markers should be removed.
added 2 commits
April 24, 2026 10:48
Signed-off-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
…er tool calls Signed-off-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
Contributor
Author
|
Step 3.5 seems to have the same issue @csy0225 |
qwen3_xml
added 2 commits
April 24, 2026 15:24
Signed-off-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
Signed-off-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
qwen3_xml
Contributor
Author
|
CC : @bbrowning re-enabled your xfail tests ! |
… fallback Signed-off-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
Contributor
Author
|
superseded by #40861 |
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.
Purpose
This PR fixes critical ordering and buffering issues in the
qwen3_xmltool parser during streaming. It ensures that free text appearing before or between tool calls is emitted immediately rather than being delayed until the end of the generation. It also corrects how tool call IDs are handled in the OpenAI-compatible stream.Key Changes
text_content_bufferas soon as a new<tool_call>is detected. This allows for correct interleaving of text and tool calls in the output.id_emittedstate to ensure that the tool callidis only sent in the first delta of a call. Subsequent deltas for the same call will haveid=None, following the OpenAI streaming protocol and preventing client-side issues._merge_new_deltas_to_single_responseto merge tool call fragments based on theirindexrather than theirid. This is necessary because IDs are now only present in the initial fragment.xfailmarkers from the test suite as this refactor resolves the underlying streaming bugs that were previously causing failures.Test Plan
test_qwen3xml_async_streaming_free_textto verify that text between tool calls is emitted in the correct order.test_qwen3xml_streaming_text_after_tool_callto ensure trailing text is not lost.qwen3_xmltests now pass withoutxfail.