You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 15, 2026. It is now read-only.
Currently, Roo Code uses XML tags for tool calling across all AI models, including top-tier models like Claude that have native tool calling capabilities. This approach results in:
High Failure Rate: Approximately 10% of tool calls fail when using XML tag-based tool calling with top-tier models
Increased Complexity Failures: Functions like apply_diff have significantly higher failure rates (>15%)
Multi-Turn Degradation: In agent mode with consecutive tool calls across multi-turn conversations, reliability decreases progressively
Suboptimal Performance: XML parsing by models not designed for it introduces latency and accuracy issues
Inconsistent User Experience: Users experience unpredictable tool behavior, particularly when editing large files
Quantitative data shows that XML tag-based approaches are less reliable than native tool calling implementations that top-tier models have specifically optimized for their architectures.
Describe the proposed solution in detail
Implement a tiered tool calling system that prioritizes native tool calling APIs for models that support them, while maintaining backward compatibility through XML tags for models that don't.
Key functionalities:
Provider/Model Detection: Automatically identify the model provider and specific model ID during runtime
Native Tool Routing: Route tool calls through native APIs when available:
Use Claude's native tool calling API for Claude 3.5/Sonnet/Opus models
Use OpenAI's function calling for GPT models
Use Gemini's function calling for Gemini models
Transparent Translation Layer: Create a unified interface that handles the appropriate method selection:
// Example API (simplified)asyncfunctionexecuteTool(toolName,params,modelProvider,modelId){if(supportsNativeToolCalling(modelProvider,modelId)){returnexecuteNativeTool(toolName,params,modelProvider,modelId);}else{returnexecuteXmlTagTool(toolName,params);}}
Tool Mapping System: Implement mappings between Roo Code tools and provider-specific tool formats:
Functionality
Anthropic Claude
Roo Code Current
Read File
view: path, view_range
read_file: path, start_line, end_line
Read Directory
view: path
list_files: path, recursive
Code Replacement
str_replace: path, old_str, new_str
apply_diff: path, diff
New File Creation
create: path, file_text
write_to_file: path, content, line_count
Code Insertion
insert: path, insert_line, new_str
insert_content: path, line, content
Progressive Rollout: Implement the feature in three phases:
Phase 1: Add native tool support for Claude models
Phase 2: Expand to other top-tier providers (Gemini, GPT)
Phase 3: XML tags are only used as a fallback for models that don't support tool use
Technical considerations or implementation details (optional)
Abstraction Layer Architecture:
Create a new ToolExecutionStrategy interface with model-specific implementations
Implement a ToolExecutionFactory that selects the appropriate strategy based on model provider and ID
Maintain the current XML tag processor as a fallback strategy
Parameter Translation:
Build a bidirectional mapping system between Roo Code parameters and native tool parameters
For complex operations like apply_diff, we need specialized translation logic:
// Example translation for apply_diff to Claude's str_replacefunctiontranslateApplyDiffToStrReplace(path,diff){const{ oldStr, newStr }=parseDiff(diff);return{tool: "str_replace",params: { path,old_str: oldStr,new_str: newStr}};}
Error Handling and Retries:
Implement intelligent fallback: if a native tool call fails, attempt XML format as backup
Add telemetry to track success rates of different approaches (with user permission)
Create specialized error types for better debugging
Required Dependencies:
Updated client libraries for each provider's API
Structured response parsers for each tool call format
Implementation Phases:
Phase 1: Claude integration
Phase 2: GPT and Gemini integration
Phase 3: Optimization and fallback mechanism refinement
Describe alternatives considered (if any)
Enhanced XML Tag Processing:
Could improve the current XML tag approach with better formatting and context
Would still have fundamental limitations since models aren't optimized for XML parsing
Rejected because it wouldn't address the root cause of failures
Custom Intermediary Format:
Could create a new intermediate format specifically designed for AI models
Would require significant research to optimize
Rejected due to high development cost and lack of clear advantage over native tools
Model-Specific Prompting:
Could use tailored prompts for each model instead of changing the tool calling method
Tests showed only marginal improvements (2-3% reduction in failures)
Rejected because native tools provide much greater reliability improvements (>90%)
Hybrid XML/JSON Approach:
Using JSON for structured data within XML tags
Complexity outweighed benefits in testing
Rejected because it adds complexity without addressing fundamental model capabilities
"You see shallow copies of apply elsewhere and it just breaks most of the time because you think you can try to do some deterministic matching and then it fails at least 40% of the time and that just results in a terrible product experience."
"We've implemented support for OpenAI's apply patch editing format (GPT 4.1 and o4-mini) and Anthropic's replace string tool (Claude Sonnet 3.7 and 3.5) in agent mode. This means that you benefit from significantly faster edits, especially in large files."
"We will open source the code in the GitHub Copilot Chat extension under the MIT license... This is the next and logical step for us in making VS Code an open source AI editor." This will have an impact on other AI coding tools, whether they are open source or not. In short, it raises the average baseline for open source products, so hopefully Roo Code will see this and optimize especially the weak points in the agent mode or the frustration of users.
What problem does this proposed feature solve?
Currently, Roo Code uses XML tags for tool calling across all AI models, including top-tier models like Claude that have native tool calling capabilities. This approach results in:
apply_diffhave significantly higher failure rates (>15%)Quantitative data shows that XML tag-based approaches are less reliable than native tool calling implementations that top-tier models have specifically optimized for their architectures.
Describe the proposed solution in detail
Implement a tiered tool calling system that prioritizes native tool calling APIs for models that support them, while maintaining backward compatibility through XML tags for models that don't.
Key functionalities:
Provider/Model Detection: Automatically identify the model provider and specific model ID during runtime
Native Tool Routing: Route tool calls through native APIs when available:
Transparent Translation Layer: Create a unified interface that handles the appropriate method selection:
Tool Mapping System: Implement mappings between Roo Code tools and provider-specific tool formats:
view: path, view_rangeread_file: path, start_line, end_lineview: pathlist_files: path, recursivestr_replace: path, old_str, new_strapply_diff: path, diffcreate: path, file_textwrite_to_file: path, content, line_countinsert: path, insert_line, new_strinsert_content: path, line, contentProgressive Rollout: Implement the feature in three phases:
Technical considerations or implementation details (optional)
Abstraction Layer Architecture:
ToolExecutionStrategyinterface with model-specific implementationsToolExecutionFactorythat selects the appropriate strategy based on model provider and IDParameter Translation:
apply_diff, we need specialized translation logic:Error Handling and Retries:
Required Dependencies:
Implementation Phases:
Describe alternatives considered (if any)
Enhanced XML Tag Processing:
Custom Intermediary Format:
Model-Specific Prompting:
Hybrid XML/JSON Approach:
Additional Context & Mockups
Industry Evidence
Cursor Team Research (Lex Fridman Interview):
From the YouTube interview: Apply Part:
GitHub Copilot's Implementation (May 2025):
From the VSCode v1.100 update: Faster agent mode edits:
VSCode's AI Strategy:
From the May 2025 blog post:
Technical Documentation
Claude Text Editor Tool Curl Demo
Proposal Checklist
Are you interested in implementing this feature if approved?