Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(maker-core): 同回应内重复调用不取消进行中的循环复核

Dasheb64bd4475e7
diff --git a/packages/maker-core/src/agents/shared/loop-guard.ts b/packages/maker-core/src/agents/shared/loop-guard.ts
index 70935c0886..62fdc65228 100644
--- a/packages/maker-core/src/agents/shared/loop-guard.ts
+++ b/packages/maker-core/src/agents/shared/loop-guard.ts
@@ -534,7 +534,11 @@ export class ToolLoopGuard {
}
// 第 2/3 层: name+input 滑动窗口多样性坍缩(指纹不含 output)
- if (repeatedInResponse.call) return { kind: 'ok' };
+ if (repeatedInResponse.call) {
+ // 同回应内的重复既不推进也不打破窗口模式;不算参与判定,以免取消进行中的复核。
+ this.lastResultObservedValue = false;
+ return { kind: 'ok' };
+ }
this.callWindow.push(callFingerprint);
const bufferSize = Math.max(this.windowSize, this.rotationWindowSize);
if (this.callWindow.length > bufferSize) this.callWindow.shift();
diff --git a/packages/maker-core/src/agents/shared/tool-loop-review.test.ts b/packages/maker-core/src/agents/shared/tool-loop-review.test.ts
index 4595395b98..7bf0040adb 100644
--- a/packages/maker-core/src/agents/shared/tool-loop-review.test.ts
+++ b/packages/maker-core/src/agents/shared/tool-loop-review.test.ts
@@ -134,6 +134,23 @@ describe('ToolLoopMonitor', () => {
expect(t.stops).toEqual([]);
});
+ // greptile P1(#6388):同一模型回应内的重复调用不计数,但也不能当作「模式已打破」取消复核。
+ it('keeps a pending review when a repeat inside one model response is ignored', async () => {
+ const { reviewer, pending } = deferredReviewer();
+ const t = setup(reviewer);
+ for (let i = 0; i < 12; i++) {
+ t.monitor.onToolUse(`r${i}`, 'read', { path: 'same.ts' }, `response-${i}`);
+ expect(t.monitor.onToolResult(`r${i}`, `changed ${i}`).kind).toBe('ok');
+ }
+ expect(reviewer).toHaveBeenCalledTimes(1);
+ t.monitor.onToolUse('dup', 'read', { path: 'same.ts' }, 'response-11');
+ expect(t.monitor.onToolResult('dup', 'changed again').kind).toBe('ok');
+ expect(pending[0]?.signal.aborted).toBe(false);
+ pending[0]?.resolve('stop');
+ await vi.advanceTimersByTimeAsync(0);
+ expect(t.stops).toHaveLength(1);
+ });
+
it('discards a pending review once a different call replaces the flagged pattern', async () => {
const { reviewer, pending } = deferredReviewer();
const t = setup(reviewer);