Skip to content

Conversation

@daniel-lxs
Copy link
Member

Problem

Fixes false positive 'stuck in a loop' error for native protocol tools like read_file that store parameters in nativeArgs instead of params.

Previously, the ToolRepetitionDetector only compared the params object, which was empty for native protocol tools. This caused all read_file calls to appear identical, triggering false loop detection even when reading different files.

Root Cause

  1. In NativeToolCallParser.ts: For native protocol, the files parameter (an array) is intentionally NOT added to the legacy params object since it can't be meaningfully stringified. Instead, it's stored in nativeArgs.
  2. In ToolRepetitionDetector.ts: The serializeToolUse() method only looked at toolUse.params to compare tools, completely ignoring nativeArgs.

Result: Every read_file call serialized to {"name":"read_file","parameters":{}} regardless of which files were being read.

Solution

Updated ToolRepetitionDetector.serializeToolUse() to also include nativeArgs in the serialization when present. Now read_file calls with different files are properly differentiated while still detecting true repetitions.

Changes

  • Updated serializeToolUse() method to include nativeArgs in comparison
  • Added comprehensive tests for native protocol scenarios
  • Maintains backward compatibility with XML protocol tools that don't have nativeArgs

Testing

  • Added 5 new test cases covering native protocol scenarios
  • All 32 tests in ToolRepetitionDetector.spec.ts pass
  • Verified different files are treated as different calls
  • Ensures identical calls are still detected as repetitions

Closes: Issue reported in Discord about read_file loop detection

Fixes false positive 'stuck in a loop' error for native protocol tools
like read_file that store parameters in nativeArgs instead of params.

Previously, the ToolRepetitionDetector only compared the params object,
which was empty for native protocol tools. This caused all read_file
calls to appear identical, triggering false loop detection even when
reading different files.

Changes:
- Updated serializeToolUse() to include nativeArgs in comparison
- Added comprehensive tests for native protocol scenarios
- Maintains backward compatibility with XML protocol tools

Closes: Issue reported in Discord about read_file loop detection
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 19, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 19, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly addresses the false positive loop detection for native protocol tools by including nativeArgs in the serialization. The fix is well-tested with comprehensive coverage of native protocol scenarios while maintaining backward compatibility with XML protocol tools.

Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the bug Something isn't working label Nov 19, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 19, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 19, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 19, 2025
@mrubens mrubens merged commit 89068c4 into main Nov 19, 2025
10 checks passed
@mrubens mrubens deleted the fix/tool-repetition-native-args branch November 19, 2025 02:20
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 19, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 19, 2025
mini2s added a commit to zgsm-ai/costrict that referenced this pull request Nov 19, 2025