Log prompt id when a loop is detected (#4765)

Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
Sandy Tao
2025-07-23 22:37:28 -07:00
committed by GitHub
parent 6380bfe35c
commit 0ef9c0b792
5 changed files with 23 additions and 13 deletions

View File

@@ -168,21 +168,21 @@ describe('LoopDetectionService', () => {
);
}
service.reset();
service.reset('');
for (let i = 0; i < CONTENT_LOOP_THRESHOLD + 2; i++) {
expect(service.addAndCheck(createContentEvent('obj.method()'))).toBe(
false,
);
}
service.reset();
service.reset('');
for (let i = 0; i < CONTENT_LOOP_THRESHOLD + 2; i++) {
expect(
service.addAndCheck(createContentEvent('arr.filter().map()')),
).toBe(false);
}
service.reset();
service.reset('');
for (let i = 0; i < CONTENT_LOOP_THRESHOLD + 2; i++) {
expect(
service.addAndCheck(
@@ -203,7 +203,7 @@ describe('LoopDetectionService', () => {
service.addAndCheck(createContentEvent('This is a sentence.')),
).toBe(true);
service.reset();
service.reset('');
for (let i = 0; i < CONTENT_LOOP_THRESHOLD - 1; i++) {
expect(
service.addAndCheck(createContentEvent('Is this a question? ')),
@@ -213,7 +213,7 @@ describe('LoopDetectionService', () => {
service.addAndCheck(createContentEvent('Is this a question? ')),
).toBe(true);
service.reset();
service.reset('');
for (let i = 0; i < CONTENT_LOOP_THRESHOLD - 1; i++) {
expect(
service.addAndCheck(createContentEvent('What excitement!\n')),