Repository navigation
Event streaming (7/11): Suggest gh event listen to agents in gh pr and gh api - #15077
Merged
Merged
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: bbce5a7f-103c-4e67-99c9-2d6dc3f6a02b
… pr help Co-authored-by: Copilot <[email protected]> Copilot-Session: bbce5a7f-103c-4e67-99c9-2d6dc3f6a02b
…oints Co-authored-by: Copilot <[email protected]> Copilot-Session: bbce5a7f-103c-4e67-99c9-2d6dc3f6a02b
babakks
requested review from
sergiou87
and
a balanced review from Copilot
and removed request for
a team
November 17, 2026 17:11
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The API tests discard command errors, allowing no-hint cases to pass despite early failures and leaving exit-status preservation unverified.
1 open issue
What changed in this PR
This layer of the event-streaming stack makes gh event listen discoverable from commands agents already use to read or create pull requests, encouraging event-driven waiting instead of polling.
Changes:
- Add agent-only stderr hints after pull request creation, eligible views, and successful pull request API reads.
- Extend pull request help with listener guidance and document timeout, preview, and missed-event limitations.
- Add tests for hint eligibility and preservation of requested JSON output.
| File | Description |
|---|---|
pkg/cmd/pr/view/view.go |
Wire agent hints and fetch state when needed for JSON views. |
pkg/cmd/pr/view/view_test.go |
Test hint eligibility and requested JSON fields. |
pkg/cmd/pr/view/hint.go |
Select the pull request resource and suppress hints for closed or merged requests. |
pkg/cmd/pr/pr.go |
Add event-listening guidance to command help. |
pkg/cmd/pr/create/create.go |
Print agent hints after pull request creation. |
pkg/cmd/pr/create/create_test.go |
Test creation hints and unchanged stdout. |
pkg/cmd/event/shared/hint.go |
Centralize hint text and supported-host filtering. |
pkg/cmd/api/hint.go |
Recognize eligible pull request REST paths and absolute API URLs. |
pkg/cmd/api/api.go |
Emit hints after successful response processing. |
pkg/cmd/api/api_test.go |
Test API hint eligibility across methods, hosts, paths, and responses. |
Review effort: Balanced
2 of 6 tasks
BagToad
approved these changes
Nov 17, 2026
This was referenced Nov 18, 2026
Merged
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.

Layer 7 of 11 in the stack tracked by #15070.
Description
Coding agents asked to wait for a pull request to be reviewed or merged reach for what they know: a loop over
gh pr vieworgh api repos/OWNER/REPO/pulls/Nwithsleep. They do not discovergh event listenon their own. This PR points them at it from the commands they already use.When
ghdetects an agent caller (the existingInvokingAgentdetection), these print a hint on stderr:gh pr create, after creating a github.com pull request.gh pr view, for a github.com pull request that is not merged or closed. When--jsonis used withoutstate, the state is fetched anyway to make that decision, and only the requested fields are printed.gh api, after a successfulGETofrepos/OWNER/REPO/pulls/NUMBERor any of its subpaths on github.com, given as a path or as an absolutehttps://api.github.comURL, such as an event'sdata.api_url.The hint gives a copyable
gh event listencommand for that pull request with review and state change events, and short notes: it prints the first event and exits,--timeoutbounds the wait with status 8, events carry no details, changes made before it starts are missed so the pull request should be read once it runs, and the feature is in preview. Thegh prandgh pr viewhelp texts also point togh event listenfor everyone.Human invocations, other hosts, stdout, JSON output, and exit statuses are unchanged.
How did you test this change?
I ran the agent evals from the next PR, which give a Copilot agent (
gpt-5.6-luna) a task that requires waiting on a sandbox pull request while a second account reviews, merges, or closes it. Without theghskill, agents only hadgh's own help and these hints to go on. In one full run, they usedgh event listenand passed all four graders in five of six scenarios; in a second run, four of six. Every failing trial polled. In both runs, thelisten-at-limitagent polled instead of freeing a subscription slot and listening. In the second run, thenotify-reviewagent loopedgh pr viewwithsleep 30and saw the hint on every read without acting on it.Key points
--follow. Agents offered it chose it even for one-off waits, ran it in the background, and were never resumed, because their harness waits for the command to exit. The default exit on the first event fits that model.--json.gh apicannot tell the pull request's state, so its hint also appears for merged or closed pull requests. It only appears forGETrequests, which is when an agent is reading state.Notes for reviewers
Stack, bottom to top (this is 7 of 11, based on
babakks/event-sub-delete):babakks/event-client,babakks/event-listen,babakks/event-sub-list,babakks/event-sub-create,babakks/event-sub-view,babakks/event-sub-delete,babakks/event-hints,babakks/event-evals,babakks/event-listen-flush,babakks/event-listen-deleted-sub,babakks/event-check-suite.Start with
pkg/cmd/event/shared/hint.go, the shared hint text. Then read where each command calls it:pkg/cmd/pr/view/hint.go, the end ofcreateRuninpkg/cmd/pr/create/create.go, andpkg/cmd/api/hint.go, whose regular expression decides which endpoints qualify.Authorship and follow-up
Who wrote this:
Who answers review comments: