-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: ensure no XML parsing when protocol is native #9371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Contributor
All previously flagged issues have been resolved. The redundant non-null assertions have been successfully removed.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
mrubens
approved these changes
Nov 18, 2025
mini2s
added a commit
to zgsm-ai/costrict
that referenced
this pull request
Nov 19, 2025
Description
Fixes a bug where XML tool parsing would occur even when Native Tool Calling (NTC) was enabled, causing confusion for the model.
The Problem
The issue occurred because the code only checked for the existence of
this.assistantMessageParserto decide whether to parse XML content. However, the parser might exist due to:When a model (confused or otherwise) output XML-like text while in native mode, the presence of the parser would trigger XML parsing, even though the protocol was strictly native. This would cause the model to see parsed XML tools and continue using XML format instead of native tool calls.
The Fix
This PR introduces a robust check that verifies the current protocol before attempting any XML parsing:
shouldUseXmlParseronce at the start of the API request loop (efficient)This ensures that even if the parser object exists in memory, it will NEVER be used if the current protocol is native.
Testing
Important
Fixes bug in
Task.tsto prevent XML parsing when protocol is native by checking protocol before parsing.Task.tswhere XML parsing occurred even when protocol was native.shouldUseXmlParserflag to check protocol before parsing XML.shouldUseXmlParserat start of API request loop.shouldUseXmlParserin streaming loop and finalization step to guard XML parsing.This description was created by
for 3cc87d4. You can customize this summary. It will automatically update as commits are pushed.