From 748bbef3b50372ed9d2c34573bcb8e2087324904 Mon Sep 17 00:00:00 2001 From: Hyo Date: Thu, 19 Nov 2026 01:13:50 +0900 Subject: [PATCH] fix: give review turns four minutes before the action's end --- convex/pullRequests/workflow.ts | 12 +++++++++++- test/convex/pullRequests/recovery.test.ts | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/convex/pullRequests/workflow.ts b/convex/pullRequests/workflow.ts index b1b378c..a4a9c2d 100644 --- a/convex/pullRequests/workflow.ts +++ b/convex/pullRequests/workflow.ts @@ -211,6 +211,11 @@ const REVIEW_TURNS = 8; // SLOW_REQUEST_MIN_MS is not sent, since it would likely be cut off. const LATE_REQUEST_END_MS = 8 * 60_000; const SLOW_REQUEST_MIN_MS = 90_000; +// A reasoning model can spend over two minutes on the turn that writes its +// findings. Cutting it off leaves its usage unknown and blocks the account's +// AI work for 30 minutes, so review requests wait this long by default, +// still never past ACTION_REQUEST_END_MS. +const REVIEW_REQUEST_TIMEOUT_MS = 4 * 60_000; const ACTION_REQUEST_END_MS = 9 * 60_000; // After the main review, focused second looks at the same source. Each one // resends the main review's last request with only its closing state @@ -356,7 +361,12 @@ export async function reviewWithContext(args: { { operation: `Request AI review (${options.billingLabel ?? "generation"})`, }, - () => args.provider.chat(messages, { endBy, ...options }), + () => + args.provider.chat(messages, { + endBy, + timeoutMs: REVIEW_REQUEST_TIMEOUT_MS, + ...options, + }), ); }; let readBudget = 0; diff --git a/test/convex/pullRequests/recovery.test.ts b/test/convex/pullRequests/recovery.test.ts index f42d068..d66e2f6 100644 --- a/test/convex/pullRequests/recovery.test.ts +++ b/test/convex/pullRequests/recovery.test.ts @@ -523,7 +523,9 @@ describe("uncertain review candidates", () => { // The closing synthesis may run past the usual two minutes. expect(requestOptions[8].timeoutMs).toBeGreaterThan(120_000); expect(requestOptions[8].timeoutMs).toBeLessThanOrEqual(300_000); - expect(requestOptions[7]).not.toHaveProperty("timeoutMs"); + // A main turn waits up to four minutes, never past the action's end. + expect(requestOptions[7].timeoutMs).toBe(240_000); + expect(requestOptions[7].endBy).toBeGreaterThan(Date.now()); expect(requests[8][0].content).toContain("Commit suggestions are disabled"); });