-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Include nativeArgs in tool repetition detection #9377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
Review complete. No issues found. The implementation correctly addresses the false positive loop detection for native protocol tools by including Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Problem
Fixes false positive 'stuck in a loop' error for native protocol tools like
read_filethat store parameters innativeArgsinstead ofparams.Previously, the
ToolRepetitionDetectoronly compared theparamsobject, which was empty for native protocol tools. This caused allread_filecalls to appear identical, triggering false loop detection even when reading different files.Root Cause
NativeToolCallParser.ts: For native protocol, thefilesparameter (an array) is intentionally NOT added to the legacyparamsobject since it can't be meaningfully stringified. Instead, it's stored innativeArgs.ToolRepetitionDetector.ts: TheserializeToolUse()method only looked attoolUse.paramsto compare tools, completely ignoringnativeArgs.Result: Every
read_filecall serialized to{"name":"read_file","parameters":{}}regardless of which files were being read.Solution
Updated
ToolRepetitionDetector.serializeToolUse()to also includenativeArgsin the serialization when present. Nowread_filecalls with different files are properly differentiated while still detecting true repetitions.Changes
serializeToolUse()method to includenativeArgsin comparisonnativeArgsTesting
ToolRepetitionDetector.spec.tspassCloses: Issue reported in Discord about read_file loop detection