Babysitting PRs
Monitor open pull requests, respond to reviewer comments, fix CI failures, and keep PRs moving toward merge — without human intervention.
Workflow
runPipeline(
listOpenPRs
.iterate()
.map(
loop((recur, done) =>
checkPRStatus.then(classifyStatus).branch({
CIFailing: diagnoseCIFailure.then(applyFix).then(pushAndWait).then(recur),
ReviewComments: addressComments.then(pushAndWait).then(recur),
Approved: done,
Stale: rebase.then(pushAndWait).then(recur),
}),
),
)
.collect(),
);
Stages
- List open PRs — query GitHub for PRs opened by the bot or assigned to it.
- Check status — for each PR, check CI status, review comments, and staleness.
- Classify — route to the appropriate handler:
- CI failing: diagnose the failure from logs, apply a fix, push, wait for CI to re-run.
- Review comments: address each comment, push the changes.
- Approved: exit the loop — the PR is ready.
- Stale: rebase onto the latest base branch and re-check.
- Loop — after each action, re-check the PR status and loop until approved.
Key points
- Each PR is babysit independently and concurrently via
.iterate().map(). - The CI diagnosis agent only sees the failure logs — it doesn't know about review comments or the PR's history.
loop+branchcreates a state machine that handles the full lifecycle of a PR.- Consider adding
withTimeoutaround the outer loop to abandon PRs that can't be fixed within a time budget.