diff --git a/.github/workflows/cursor-automation.yml b/.github/workflows/cursor-automation.yml index 2e0bf316d..745bf1e1d 100644 --- a/.github/workflows/cursor-automation.yml +++ b/.github/workflows/cursor-automation.yml @@ -4682,7 +4682,7 @@ jobs: const dispatchedAt = Date.parse(priorDispatch.created_at || '') || 0; if ( dispatchedAt > 0 && - Date.now() - dispatchedAt < auto.CODEX_REQUEST_RETRY_MS + Date.now() - dispatchedAt < auto.CODEX_LOOP_TIMEOUT_MS ) { continue; } diff --git a/scripts/cursor-automation.cjs b/scripts/cursor-automation.cjs index 331271c02..6f543ccbe 100644 --- a/scripts/cursor-automation.cjs +++ b/scripts/cursor-automation.cjs @@ -1896,6 +1896,8 @@ function hasAutomationCodexRequest(comments = [], options = {}) { */ /** Default age after which a still-unanswered @codex request may be retried. */ const CODEX_REQUEST_RETRY_MS = 30 * 60 * 1000; +/** Maximum runtime of the codex_loop job; dispatch markers must outlive it. */ +const CODEX_LOOP_TIMEOUT_MS = 120 * 60 * 1000; function decideCodexLoopAction({ eligible, @@ -3234,6 +3236,7 @@ module.exports = { parseCodexReviewOutcome, hasAutomationCodexRequest, CODEX_REQUEST_RETRY_MS, + CODEX_LOOP_TIMEOUT_MS, decideCodexLoopAction, shouldReTriageIssueComment, mentionsIssueBot, diff --git a/scripts/cursor-automation.test.cjs b/scripts/cursor-automation.test.cjs index 4e03840a8..efb44574b 100644 --- a/scripts/cursor-automation.test.cjs +++ b/scripts/cursor-automation.test.cjs @@ -82,7 +82,8 @@ test('Codex polling dispatches actionable submitted reviews to the fix loop', () assert.match(poll, /\['fix', 'give_up', 'mark_ready'\]\.includes\(decision\.action\)/); assert.match(poll, /cursor-codex-dispatch:review-id=/); assert.match(poll, /const priorDispatch/); - assert.match(poll, /Date\.now\(\) - dispatchedAt < auto\.CODEX_REQUEST_RETRY_MS/); + assert.match(poll, /Date\.now\(\) - dispatchedAt < auto\.CODEX_LOOP_TIMEOUT_MS/); + assert.equal(auto.CODEX_LOOP_TIMEOUT_MS, 120 * 60 * 1000); assert.match(poll, /let dispatchRejected = false/); assert.match(poll, /authorization: `Bearer \$\{process\.env\.DISPATCH_TOKEN\}`/); assert.match(poll, /actions\/workflows\/cursor-automation\.yml\/dispatches/);