fix(loop-tick): exclude drain cycles from zero-PR backoff (Codex P1 follow-up on #4146)#4148
Merged
AceHack merged 1 commit intoMay 18, 2026
Conversation
…dex P1 follow-up on #4146) PR #4146 was merged before this Codex P1 fix could land on its branch. The finding: zero-PR backoff in #4146 increments on every produced_pr= false, but drain-mode runs (thread-resolution / merge work on existing PRs) never set produced_pr=true. So a healthy drain-only period would falsely look like consecutive zero-PR failures and ratchet to 30x slowdown — delaying review-thread handling and merges. Fix: filter the counter on r.mode === 'pickup' — skip drain cycles entirely when counting. Drain mode is excluded because the success signal there is NOT produced_pr (no new PR is created) but rather thread-resolution + merge, which we don't currently track as a discrete success metric (could be future work). Backoff now only triggers when pickup-mode (the cycle that's SUPPOSED to create new PRs) consistently fails. Healthy drain operation no longer slows it down. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up on #4146: the zero-PR backoff Codex flagged as a P1 issue shipped to main before this fix could land on its branch.
Finding (Codex on #4146)
Zero-PR backoff increments on every
produced_pr=false, but drain-mode runs (thread-resolution / merge work on existing PRs) NEVER setproduced_pr=true. A healthy drain-only period (e.g., 5 PRs all going through review) would falsely look like consecutive zero-PR failures and ratchet to 30x slowdown — delaying review-thread handling and merges.Fix
if (r.mode !== "pickup") continue;— skip drain cycles entirely when counting.Drain mode is excluded because its success signal is NOT
produced_pr(no new PR is created) but rather thread-resolution + merge — which we don't currently track as a discrete success metric. Future work could add aproduced_merge: truefield to drain ratings and unify the counter.Backoff now only triggers when pickup-mode (the cycle that's SUPPOSED to create new PRs) consistently fails. Healthy drain operation no longer slows the loop down.
Why this took a follow-up PR
I was authoring the fix-commit when #4146 auto-merged. My fix-commit (
bb75cf2) was created butPATCH /refs/heads/<branch>returned 422 because the branch had already been auto-deleted on merge. Created a fresh branch off main with the same fix instead. The fix-commit on the orphan branch is functionally equivalent to this PR's0d6c5bd.Composes with #4146 (merged); applies the Codex P1 correction.
Co-Authored-By: Claude noreply@anthropic.com