-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Disable XML parser for native tool protocol #9277
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
Conversation
Review completed. No new issues found. The PR correctly implements conditional parser initialization and abort controller support for request cancellation. All changes follow good practices and maintain proper null-safe access patterns. Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
17b2a3b to
73d2c5c
Compare
| const toolProtocol = vscode.workspace.getConfiguration(Package.name).get<ToolProtocol>("toolProtocol", "xml") | ||
| this.assistantMessageParser = toolProtocol === "xml" ? new AssistantMessageParser() : undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow-up I think we should probably centralize these toolProtocol checks into a single shared method that we import
- Make assistantMessageParser optional (undefined for native protocol) - Only initialize parser when toolProtocol is 'xml' - Add conditional checks before calling parser methods - Handle native protocol text chunks separately from XML parsing This prevents unnecessary XML parsing when using native tool calls, which come as structured tool_call chunks instead of XML text.
73d2c5c to
c6d315d
Compare
This PR fixes the assistant message parser initialization to only use XML parsing when the tool protocol is set to 'xml'.
Problem
When using native tool protocol, models like Claude Sonnet were sometimes getting confused and attempting to use XML-formatted tool calls instead of the native tool format. The XML parser would then parse these incorrect tool calls, which further confused the model and created a feedback loop of incorrect tool usage.
Changes
Why
With native tool protocol, the model returns tool calls as structured tool_call chunks that don't require XML parsing. By disabling the XML parser for native protocol, we prevent the parser from inadvertently processing and validating malformed XML tool calls that the model might generate, eliminating the confusion feedback loop.
Important
Conditionally initialize
AssistantMessageParserinTask.tsbased ontoolProtocolto support both XML and native protocols.Task.ts,AssistantMessageParseris conditionally initialized based ontoolProtocolsetting.toolProtocolset to 'native',assistantMessageParseris set toundefined.toolProtocolset to 'xml',assistantMessageParseris initialized as before.?.) forassistantMessageParserinreset()andfinalizeContentBlocks()calls.recursivelyMakeClineRequests()to handle both XML and native protocols.presentAssistantMessage()logic to differentiate between XML and native text handling.This description was created by
for 73d2c5c. You can customize this summary. It will automatically update as commits are pushed.