How an AI Agent Can Wait for PR Reviews Without Polling
I tested a one-line fix for senpi and opened a pull request. After submitting it, I wanted to know whether there was anything else to do or whether I could just wait. At the time, I made a one-off check of the PR and its reviews through the public GitHub API.
One lookup is enough when you just want to know the current state. But if an agent needs to start follow-up work when a review arrives, GitHub Event Streams lets it wait for a change instead of asking the same question at intervals. The key is to distinguish the review notification from the current state of the PR.
Checking state is different from waiting for a change
Section titled “Checking state is different from waiting for a change”gh pr view shows the current state of a PR. Polling means repeating that lookup at intervals. gh event listen waits for a specific event on a specific PR. The two work together: use the event to decide when to look, and the lookup to decide what to do.
Source: original illustration. The left side checks on a timer; the right side checks after an event or reconnection.
What to check when a review arrives
Section titled “What to check when a review arrives”This example follows the official GitHub CLI manual. It is not a record of receiving an event on the senpi PR.
gh event listen \ --resource https://github.com/OWNER/REPO/pull/123 \ --event com.github.pull_request.review.submitted.v1 \ --timeout 30mBy default, the command writes the first event to standard output as one line of JSON, then exits. This example waits for a formal PR review. Ordinary comments in the PR conversation do not trigger this event.
A submitted review is not necessarily an approval. Fetch the review pointed to by the event’s data.api_url to distinguish an approval, a request for changes, and a comment. Even if that review approved the PR, whether the PR as a whole is ready to merge is a separate question. If the next action depends on the overall PR state, query it again with gh pr view. The same principle applies to CI: one completed check suite does not mean all checks passed.
Check state after connecting and when the wait times out
Section titled “Check state after connecting and when the wait times out”The stream does not replay events from before it connected. When the CLI reports the connection on standard error, keep the listener running and read the current PR state with a separate query. A review might have arrived between an earlier lookup and the connection.
The CLI reconnects after a disconnect, but it does not deliver events that happened during the gap. Check the current state again after reconnecting. If --timeout is reached first, the command exits with status 8. That means the listener did not receive an event before the deadline. If the report needs to say whether there is a review, perform one last lookup and say when you checked.
Which approach fits?
Section titled “Which approach fits?”| Situation | Choice |
|---|---|
| You just want to know whether there is a new review now | Check once with gh pr view. |
| Follow-up work should start when a particular PR receives a review | Wait for the event with a timeout, then check the current state. |
| Streaming is unavailable, but you still need to monitor changes | Poll at a defined interval with a stopping condition. |
As documented on November 20, 2026, the feature is in preview on GitHub.com and requires gh v2.105.0 or later and access to Event Streams. It does not support PRs on GitHub Enterprise Server or GHE.com. Receiving events is separate from having the authority to approve or merge a PR.