-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: correct tool repetition detector to not block first tool call when limit is 1 #6836
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
…en limit is 1 - Changed initial count from 1 to 0 for new (non-repeated) tool calls - Updated test expectations to match correct behavior - A limit of N now correctly allows N consecutive identical calls before blocking - Fixes issue #6834 where setting limit to 1 incorrectly blocked the first tool call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.
this.consecutiveIdenticalToolCallCount++ | ||
} else { | ||
this.consecutiveIdenticalToolCallCount = 1 // Start with 1 for the first occurrence | ||
this.consecutiveIdenticalToolCallCount = 0 // Reset to 0 for a new tool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good fix! The change from 1 to 0 is correct - the first occurrence shouldn't count as a repetition. Consider adding a comment here to explain the counting logic for future maintainers, something like: // Start from 0 since this is the first occurrence, not a repetition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes issue #6834 where setting the "Errors and Repetition Limit" to 1 incorrectly blocks the first (non-repeated) tool call.
Problem
The tool repetition detector was incorrectly counting the first occurrence of a tool as 1, which meant that with a limit of 1, the very first tool call would be blocked even though it was not a repetition.
Solution
Testing
Related Issue
Fixes #6834
Important
Fixes tool repetition detection to correctly allow the first tool call when the limit is set to 1, updating logic and tests accordingly.
ToolRepetitionDetector.ts
.ToolRepetitionDetector.spec.ts
to reflect the corrected behavior.This description was created by
for 72691ac. You can customize this summary. It will automatically update as commits are pushed.