fix: sanitize tool tags from XAI reasoning content #9042
Closed
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.
Description
This PR addresses Issue #9041 where the thinking block for Grok Code Fast 1 was displaying tool-related XML tags like
<appy_diff>and<switch_mode>instead of just the model's reasoning content.Problem
When using Grok Code Fast 1, the reasoning/thinking collapsible blocks sometimes showed tool command tags mixed with actual thinking content, making it difficult to read the model's actual reasoning process.
Solution
sanitizeReasoningContent()function in the XAI provider that removes known tool-related XML/HTML tags while preserving the text content between themTesting
Result
The thinking blocks now accurately display only the model's reasoning without extraneous tool command tags, as requested in the issue.
Fixes #9041
Important
Adds
sanitizeReasoningContent()to remove tool-related tags from reasoning content inXAIHandler, with tests for various scenarios.sanitizeReasoningContent()inxai.tsto remove tool-related XML/HTML tags from reasoning content.createMessage()inXAIHandlerto clean reasoning content before yielding.xai.spec.tsfor tag removal, nested tags, empty content, and clean content preservation.This description was created by
for 2ae05f9. You can customize this summary. It will automatically update as commits are pushed.