mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #180] [MERGED] test: add unit tests for repeatingDetector and clearCallArguments #217
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/180
Author: @mason5052
Created: 3/5/2026
Status: ✅ Merged
Merged: 3/11/2026
Merged by: @asdek
Base:
feature/next_release← Head:test/repeating-detector-and-iteration-cap📝 Commits (2)
fc90e9dtest: add unit tests for repeatingDetector and clearCallArguments0ffe6a4fix: add named test constant and same-name-different-args edge case📊 Changes
1 file changed (+210 additions, -0 deletions)
View changed files
📝
backend/pkg/providers/helpers_test.go(+210 -0)📄 Description
Description of the Change
Problem
The
repeatingDetectorandclearCallArgumentsfunctions inhelpers.gohad no unit test coverage despite being critical safety logic for preventing infinite agent chain loops (#175, #178).Solution
Add 12 test cases covering the full behavior of repeating tool call detection:
TestRepeatingDetector (9 cases): nil function call handling, threshold triggering at
RepeatingToolCallThreshold=3, funcCalls accumulation and reset on different calls, escalation threshold validation (6 vs 7 consecutive calls), argument normalization (message field stripping, JSON key ordering)TestRepeatingDetectorEscalationThreshold: Validates the escalation math used in
performer.go-- abort triggers whenlen(funcCalls) >= RepeatingToolCallThreshold + 4 = 7, confirming 4 soft warnings before abort on the 7th consecutive identical callTestClearCallArguments (3 cases): message field stripping, alphabetical key sorting, invalid JSON passthrough
All tests follow the existing table-driven pattern in
helpers_test.gousingtestify/assert.Related to #175
Adds test coverage for #178
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
go test ./pkg/providers/ -run "TestRepeatingDetector|TestClearCallArguments" -v-- all 12 tests passgo test ./pkg/providers/ -v-- all existing tests continue to pass (no regressions)go vet ./pkg/providers/-- no warningsSecurity Considerations
No security impact. Test-only change.
Checklist
go fmtandgo vet🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.