GitHub News

GitHub CLI can now block until a pull request changes, so your agent can stop polling

gh 2.105.0 adds gh event listen, a preview command built on GitHub Event Streams. What it replaces, what it can't see, and a wait script to try once you have access.

A blueprint-style ring node at the centre of the frame with a glowing pulse travelling along a single line towards it

An agent opens a pull request, then has to find out whether CI passed and whether anyone reviewed it. The usual answer is a loop: gh pr view, sleep for 30 seconds, gh pr view again. Every pass costs tokens if the agent is driving it, and a rate-limit slice if a script is. The loop also tends to end in one of two ways. It gives up too early, or it keeps going long after the pull request merged.

GitHub CLI 2.105.0, released on 18 November 2026, adds a way to wait without looping. gh event listen subscribes to changes on one pull request and blocks until one arrives. It’s a preview, it needs access you may not have yet, and it can’t see everything. It’s still worth knowing how it works, because GitHub has already started steering the CLI’s own commands towards it.

What it is

The command sits on top of GitHub Event Streams, which pushes notifications over Server-Sent Events (SSE). Your client holds one connection open, GitHub sends a small event saying something changed, and the client then reads the current state from the REST API. There’s no public endpoint to expose, which is the point: webhooks need one, and a laptop or a CI runner doesn’t have one.

Per the GitHub docs, access is by waitlist, enabled per account, and it’s GitHub.com only, not GHE.com. An account without access gets a 403. Both the changelog and the docs call the feature a preview whose API and limits may change at short notice.

The gh side is short. gh event listen takes a pull request with --resource and one or more event types with --event. It creates the subscription, opens the stream, reconnects if the stream drops, and prints each event as one line of CloudEvent JSON. By default it exits after the first event. --count N waits for N, --follow keeps listening, --timeout stops waiting (exit status 8), and --jq or --template shape the output.

gh event listen --resource https://github.com/OWNER/REPO/pull/123 \
  --event com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1

That example is straight from the docs. Access is a waitlist, so none of what follows has been run against a live stream. It’s documented behaviour, labelled as such.

What it can watch

Five pull request event types, all documented:

  • review.submitted.v1: a review with an approval, a change request or a comment. Each review comment and reply counts too.
  • check_suite.status.changed.v1: a check suite on the head commit finishes, pass or fail. This is the only event that carries the outcome, in data.conclusion (success, failure, timed_out and so on).
  • head.changed.v1: the head commit moved, for example after a push.
  • state.changed.v1: merged, closed, reopened, marked ready for review or converted to draft.
  • merge_conflict.v1: GitHub found a conflict. Per the docs this can arrive late, because GitHub only checks for conflicts after the pull request is viewed or requested.

Most events say that something changed, not what. The data.api_url field points at the thing that changed, and the client fetches it. That’s a good fit for an agent: the event is a wake-up call, and the agent reads fresh state instead of trusting a payload.

What it can’t see

The docs list the gaps, and a couple matter for exactly the “is CI done?” question.

  • There’s no “all checks completed” event. Each check suite fires its own check_suite.status.changed.v1, so a pull request with four suites produces four events, and something has to count them. After each one, fetch the check suites and decide.
  • Commit statuses created through the REST API aren’t covered by check suite events. A legacy integration that reports with statuses instead of checks stays invisible to the stream.
  • Comments on the conversation tab produce no events. Review comments do.
  • There’s no replay. An event that fires before the stream opens, in a short window after subscribing, or while the connection is down is gone. The docs’ fix is to fetch the pull request once after the stream opens.
  • Duplicates and out-of-order delivery can happen, so treat the event as a prompt to look and use api_url to deduplicate.

None of this is fatal, but it rules out the naive version of the idea, where the agent runs gh event listen, sees one event and concludes CI is green.

A wait script to try

The shape that follows from those limits: open the stream, wait for the readiness line, read the state once, then block on the next event, and read state again. The CLI prints Listening for events. to stderr when the stream is open, per the docs, so that’s the signal to catch up.

#!/usr/bin/env bash
# usage: wait-for-pr.sh OWNER/REPO NUMBER
set -euo pipefail

pr="https://github.com/$1/pull/$2"
events="com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1"
out=$(mktemp); err=$(mktemp)
trap 'rm -f "$out" "$err"' EXIT

gh event listen --resource "$pr" --event "$events" --count 1 >"$out" 2>"$err" &
listener=$!

until grep -q 'Listening for events.' "$err"; do
  kill -0 "$listener" 2>/dev/null || { cat "$err" >&2; exit 1; }
  sleep 0.2
done

# Catch up: anything that happened before the stream opened is not replayed.
gh pr view "$pr" --json state,reviewDecision
wait "$listener"

# The event only says something changed. Read the state again.
cat "$out"
gh pr view "$pr" --json state,reviewDecision

Two things to adjust before it goes near an agent. First, put a ceiling on the wait. The script above doesn’t pass --timeout because the docs give no value format for it, so wrap the call in coreutils timeout or check gh event listen --help on your version. Second, add the check suite event type to events if the loop is about CI, and have the final step run a check-suite query instead of the review fields.

The instruction to the agent is then one line: run ./wait-for-pr.sh owner/repo 123, read the JSON it prints, and decide. That works with any coding agent that can run a shell, since it’s a script and not a feature of one tool.

Cleanup and limits

Each subscription covers one pull request, expires 24 hours after creation, and a token can hold up to 100 active ones, with a 422 beyond that. gh event listen doesn’t delete its subscription on exit, so long-lived automation should list and delete them with gh event subscription list and delete, which the release notes describe.

In Actions, GITHUB_TOKEN is an accepted installation token, but it can’t be renewed. The docs say to delete subscriptions before the job finishes. Personal tokens of the job’s members don’t enable streams, and apps authenticating as themselves aren’t supported.

Should you care yet

For most teams, not this week. The waitlist is the blocker, and a preview that “may change” is a poor foundation for a pipeline you’d have to maintain. Anything that’s already working with gh run watch or a plain poll can stay as it is.

The signal worth noting is where GitHub is pointing the CLI. Per the changelog, gh pr create, gh pr view, gh run view, gh run watch and gh api now suggest gh event listen instead of polling, and gh run view and gh run watch gained check suite event support. The CLI’s output is read by agents, so those hints will nudge agents towards the stream whether or not you’ve decided to.

This week, check which of your agent runs sit in a sleep loop on a pull request, and note how long each waits. That’s the list to move once your account has access.