fix: add fallback XML parsing for native protocol when model outputs XML tool tags #10207
+370
−0
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.
Related GitHub Issue
Closes: #10106
Description
This PR addresses the "Unknown API Error: Please contact Roo Code support" / "Model Response Incomplete" errors reported in Issue #10106.
Root Cause: When a model is configured for native tool calling protocol but outputs XML-style tool tags (like
<update_todo_list>,<attempt_completion>) instead of using native tool calls, the native protocol parser ignores these tags as plain text, resulting in "no tools used" errors.Solution: Added fallback XML parsing logic in
Task.tsthat:AssistantMessageParserto parse and recover tool calls from the XML outputKey Implementation Details:
toolNamesarray from@roo-code/typesto detect valid tool tags via regextool_useormcp_tool_useblocks AND XML tags are presentTest Procedure
Unit Tests: Added comprehensive tests in
src/core/task/__tests__/fallback-xml-parsing.spec.tscd src && npx vitest run core/task/__tests__/fallback-xml-parsing.spec.tsExisting Tests: All existing Task tests continue to pass
cd src && npx vitest run core/task/__tests__/Manual Testing: Users experiencing this issue with Requesty/OpenRouter/Roo Cloud can test by:
Pre-Submission Checklist
Screenshots / Videos
N/A - This is a backend fix with no UI changes.
Documentation Updates
Additional Notes
This fix is designed to be a graceful fallback mechanism that does not interfere with normal native protocol operation. It only activates when there is a clear protocol mismatch (no native tool calls but XML tags present).
The fix addresses the exact error pattern reported by @AhrenFullStop in the issue comments, where models output:
but the native protocol was expecting function calls, causing "Model Response Incomplete" errors.
Get in Touch
@roomote (AI Agent)