-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
App Version
3.14.3
API Provider
OpenRouter
Model Used
Gemini 2.5 Pro
Actual vs. Expected Behavior
Actual Behavior:
- XML Special Character Handling: When the AI assistant (Roo) presents code or text containing XML special characters (specifically
<,>,&,",') within the XML structure of tool calls (e.g., as parameters forwrite_to_file,apply_diff,search_files, or even withinask_followup_question), these characters are sometimes displayed in their escaped forms (e.g.,&lt;,&gt;,&amp;,&quot;,&apos;). - This escaping causes confusion for the user, making it unclear whether this is expected behavior, a parsing requirement, or an error.
- Diff Marker Inclusion: The AI sometimes incorrectly includes diff markers (like a
+prefix) in theREPLACEcontent generated for theapply_difftool, indicating a potential misunderstanding of the required parameter format. - Tool Failures: Tools (especially
apply_diff, but potentially others likesearch_files) seem more prone to failure when dealing with these special characters or incorrect markers (e.g.,apply_difffailing to find a match), even when the target file content appears largely correct. It is suspected that inconsistencies in character handling or marker inclusion lead to matching or parsing failures.
Expected Behavior:
- There should be clear documentation or AI operational rules/tool usage instructions specifying whether XML special characters (
<,>,&,",') must be escaped when included in tool parameters (especially for code blocks). - The system should handle these characters consistently. Either:
- Escaping is strictly required, and all tools correctly interpret the escaped forms.
- Escaping is not required (or handled automatically by the system before parsing), and tools expect literal characters.
- For code clarity, the presentation layer should ideally display literal
<and>characters, unless escaping is absolutely necessary.
- Tools (like
apply_diff,search_files) should reliably handle content containing these special characters. For example, the diffing mechanism forapply_diffneeds to correctly account for potential escaping inconsistencies between the providedSEARCHblock and the actual file content. - The AI should never include any diff markers (like
+or-) in theREPLACEcontent generated forapply_diff; it should only contain the plain text lines intended for the final file.
Detailed Steps to Reproduce
- (For Character Handling):
- Instruct the AI assistant (Roo) to perform a task requiring it to include code or text with XML special characters (
<,>,&,",') within a tool call parameter (e.g., in thecontentordiffparameter ofask_followup_question,write_to_file,apply_diff). - Observe the AI's response and the tool call format. Note whether the special characters are escaped.
- If tools like
apply_difforsearch_filesare used, observe if they fail or produce incorrect results due to inconsistent character handling.
- Instruct the AI assistant (Roo) to perform a task requiring it to include code or text with XML special characters (
- (For
apply_diff'+' Marker):- Instruct the AI assistant (Roo) to use the
apply_difftool to modify a file, specifically adding new lines. - Inspect the
>>>>>>> REPLACEsection of theapply_diffcall generated by the AI. - Observe if the
REPLACEsection incorrectly contains lines prefixed with+.
- Instruct the AI assistant (Roo) to use the
Relevant API Request Output
Gemini 2.5 Pro Explanation:
Hello, regarding your question:
What are < and >?
Sorry for the confusion. When I display code, since the code is contained within an XML structure (required by the format of the tool), in order to prevent the < and > symbols in the code from conflicting with the XML tag symbols, I used their HTML entity representations:
< represents the less-than sign <
> represents the greater-than sign >
In an actual C++ code file, you should use the standard < and > symbols, such as #include <QObject> and std::function<void()>.Additional Context
Initially, I regarded the escaping of < / > and other characters as a potential bug in the AI's output generation.
The frequent failures of the apply_diff tool (and potential issues with other tools) severely hinder the development process when dealing with code or text that contains special characters.
The AI mistakenly includes the + marker when generating the REPLACE content for apply_diff, indicating that there may be a deviation in its understanding of the format of tool parameters.
Currently, it is unclear whether the XML parser at the underlying layer of the Roo Code system requires escaping, or whether the escaping occurs at other stages and interferes with the functionality of the tools.
Improving the tool usage guidelines or prompts regarding character handling and the format of tool parameters will be beneficial both for users and for the AI model itself.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status