From 7ee915bbeb7a641cf7b1a529324581372d95c708 Mon Sep 17 00:00:00 2001 From: Eyejoker Date: Mon, 30 Mar 2026 21:09:41 +0900 Subject: [PATCH] fix: only reset round_trip_count on human messages The counter was being reset to 0 on every owner turn, including bot-only ping-pong turns. This prevented the 3-round-trip echo loop breaker from ever triggering. Now only human messages reset the counter. --- src/paired-execution-context.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/paired-execution-context.ts b/src/paired-execution-context.ts index d9b859e..faf6168 100644 --- a/src/paired-execution-context.ts +++ b/src/paired-execution-context.ts @@ -222,15 +222,17 @@ export function preparePairedExecutionContext(args: { // turn. merge_ready is only reset when a human message is present — // without it, this is a finalize turn after reviewer approval and // resetting would prevent task completion. - const needsReset = - latestTask.round_trip_count > 0 || - (latestTask.status === 'merge_ready' && args.hasHumanMessage === true) || + // Only reset round_trip_count when a human message is present — + // bot-only ping-pong must accumulate the counter for loop detection. + const hasHuman = args.hasHumanMessage === true; + const needsStatusReset = + (latestTask.status === 'merge_ready' && hasHuman) || latestTask.status === 'review_ready' || latestTask.status === 'in_review'; - if (needsReset) { + if (hasHuman || needsStatusReset) { updatePairedTask(latestTask.id, { - round_trip_count: 0, - status: 'active', + ...(hasHuman ? { round_trip_count: 0 } : {}), + ...(needsStatusReset ? { status: 'active' as const } : {}), updated_at: now, }); }