Deferred from review of #357, where ai-code-review.yml was added.
The gap
ai-code-review.yml picks an agent at random and dispatches that agent's review workflow:
if gh workflow run "$agent_wf" --repo "$REPO" "${REF_ARGS[@]}" -f pr_number="$PR_NUMBER"; then
echo "Dispatched the review to $agent ($agent_wf)."
exit 0
fi
gh workflow run returns as soon as the run is queued, so a zero exit status
proves only that the dispatch was accepted --- not that the review ran, and not
that it produced a verdict. An agent that dispatches fine and then dies partway
through (quota exhaustion, an SDK error, the stub-review signature gha#185
covers for Claude) is never failed over to the next candidate: the loop has
already exited 0.
So the fallback currently covers exactly the dispatch-time cases:
- no API key/token secret configured for that agent
- the agent's review workflow file missing or disabled in the caller repo
Why it was not fixed in #357
Waiting synchronously is not a one-line change, and the obvious form does not
work. gh workflow run reports no run id, so gh run watch has nothing to
attach to; locating the dispatched run means polling
gh run list --workflow "$agent_wf" and matching on a heuristic (recent
created_at, the head SHA, the dispatch inputs), each of which can pick the
wrong run when two dispatches land close together --- which is the normal case
on a PR that gets several pushes.
There is also a real design question underneath, worth settling before
implementing: a synchronous wait turns this from a ~10 second dispatcher into a
job that occupies a runner for the whole length of a review, and the timeout it
would need is the review's timeout plus a margin.
Suggested approach, if picked up
- Have each per-agent review workflow report its own outcome somewhere
attributable (a check-run name, or a PR comment marker), and have this
workflow poll for that rather than for the run itself --- the outcome is what
the failover actually cares about, and it is not ambiguous between concurrent
runs the way a run-list heuristic is.
- Bound the wait explicitly and treat a timeout as "this agent did not deliver",
falling through to the next candidate.
- Decide whether a failed-over review should say so on the PR, so a reader can
tell a second agent's review from a first agent's.
Meanwhile
#357 documents the current scope rather than leaving it implied --- in the
workflow's own header comment, in website/workflows.qmd, and in
website/reference/ai-code-review.qmd --- so the README's summary no longer
reads as though a runtime failure is covered.
Deferred from review of #357, where
ai-code-review.ymlwas added.The gap
ai-code-review.ymlpicks an agent at random and dispatches that agent's review workflow:gh workflow runreturns as soon as the run is queued, so a zero exit statusproves only that the dispatch was accepted --- not that the review ran, and not
that it produced a verdict. An agent that dispatches fine and then dies partway
through (quota exhaustion, an SDK error, the stub-review signature gha#185
covers for Claude) is never failed over to the next candidate: the loop has
already exited 0.
So the fallback currently covers exactly the dispatch-time cases:
Why it was not fixed in #357
Waiting synchronously is not a one-line change, and the obvious form does not
work.
gh workflow runreports no run id, sogh run watchhas nothing toattach to; locating the dispatched run means polling
gh run list --workflow "$agent_wf"and matching on a heuristic (recentcreated_at, the head SHA, the dispatch inputs), each of which can pick thewrong run when two dispatches land close together --- which is the normal case
on a PR that gets several pushes.
There is also a real design question underneath, worth settling before
implementing: a synchronous wait turns this from a ~10 second dispatcher into a
job that occupies a runner for the whole length of a review, and the timeout it
would need is the review's timeout plus a margin.
Suggested approach, if picked up
attributable (a check-run name, or a PR comment marker), and have this
workflow poll for that rather than for the run itself --- the outcome is what
the failover actually cares about, and it is not ambiguous between concurrent
runs the way a run-list heuristic is.
falling through to the next candidate.
tell a second agent's review from a first agent's.
Meanwhile
#357 documents the current scope rather than leaving it implied --- in the
workflow's own header comment, in
website/workflows.qmd, and inwebsite/reference/ai-code-review.qmd--- so the README's summary no longerreads as though a runtime failure is covered.