Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✅ test: pin the polling regression with a fixed-count case (#18997)

Arvin Xu3905dd29de23
diff --git a/packages/agent-runtime/src/utils/toolCallRepeatGuard.test.ts b/packages/agent-runtime/src/utils/toolCallRepeatGuard.test.ts
index 1bb566aaed7..98c4df94536 100644
--- a/packages/agent-runtime/src/utils/toolCallRepeatGuard.test.ts
+++ b/packages/agent-runtime/src/utils/toolCallRepeatGuard.test.ts
@@ -16,6 +16,22 @@ const createToolCall = (argumentsValue: string): ChatToolPayload => ({
});
describe('toolCallRepeatGuard', () => {
+ // Deliberately hardcoded (not derived from TOOL_CALL_REPEAT_LIMIT): a
+ // fixed-argument polling loop — same jobId polled until the job finishes —
+ // must survive well past the old limit of 5. Reverting the limit makes this
+ // fail, which the self-referential tests below cannot do.
+ it('lets a fixed-argument polling loop run to 19 calls and blocks the 20th', () => {
+ let guard: ReturnType<typeof updateToolCallRepeatGuard> | undefined;
+
+ for (let index = 0; index < 19; index++) {
+ guard = updateToolCallRepeatGuard(guard, [createToolCall('{"jobId":"job-1"}')]);
+ expect(hasRepeatedToolCall(guard)).toBe(false);
+ }
+
+ guard = updateToolCallRepeatGuard(guard, [createToolCall('{"jobId":"job-1"}')]);
+ expect(hasRepeatedToolCall(guard)).toBe(true);
+ });
+
it('allows limit-1 consecutive calls and blocks the next with canonically equivalent arguments', () => {
let guard: ReturnType<typeof updateToolCallRepeatGuard> | undefined;